CScriptPlayerActor: Remove two usages of const_cast

While we're at it, we can also simplify the implementation of
GetPostConstructed().
This commit is contained in:
Lioncash 2020-04-09 20:05:31 -04:00
parent c796cf5315
commit a2f7527388
2 changed files with 6 additions and 9 deletions

View File

@ -347,11 +347,8 @@ public:
s32 GetDockCount() const { return xcc_docks.size(); } s32 GetDockCount() const { return xcc_docks.size(); }
bool IsPostConstructed() const { return xf0_24_postConstructed; } bool IsPostConstructed() const { return xf0_24_postConstructed; }
const CPostConstructed* GetPostConstructed() const { CPostConstructed* GetPostConstructed() { return x12c_postConstructed.get(); }
if (!x12c_postConstructed) const CPostConstructed* GetPostConstructed() const { return x12c_postConstructed.get(); }
return nullptr;
return x12c_postConstructed.get();
}
bool IsValidated() const { return xf0_28_validated; } bool IsValidated() const { return xf0_28_validated; }

View File

@ -211,8 +211,8 @@ void CScriptPlayerActor::Think(float dt, CStateManager& mgr) {
if (x354_29_loading && !x354_28_suitModelLoading && !x354_27_beamModelLoading && x64_modelData && if (x354_29_loading && !x354_28_suitModelLoading && !x354_27_beamModelLoading && x64_modelData &&
!x64_modelData->IsNull() && x64_modelData->IsLoaded(0)) { !x64_modelData->IsNull() && x64_modelData->IsLoaded(0)) {
if (x355_24_areaTrackingLoad) { if (x355_24_areaTrackingLoad) {
const CGameArea* area = mgr.GetWorld()->GetAreaAlways(x4_areaId); CGameArea* area = mgr.GetWorld()->GetArea(x4_areaId);
--const_cast<CGameArea::CPostConstructed*>(area->GetPostConstructed())->x113c_playerActorsLoading; --area->GetPostConstructed()->x113c_playerActorsLoading;
x355_24_areaTrackingLoad = false; x355_24_areaTrackingLoad = false;
} }
x354_29_loading = false; x354_29_loading = false;
@ -285,8 +285,8 @@ void CScriptPlayerActor::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid
case EScriptObjectMessage::InitializedInArea: case EScriptObjectMessage::InitializedInArea:
x354_31_deferOnlineLoad = true; x354_31_deferOnlineLoad = true;
if (x350_flags & 0x8) { if (x350_flags & 0x8) {
const CGameArea* area = mgr.GetWorld()->GetAreaAlways(x4_areaId); CGameArea* area = mgr.GetWorld()->GetArea(x4_areaId);
++const_cast<CGameArea::CPostConstructed*>(area->GetPostConstructed())->x113c_playerActorsLoading; ++area->GetPostConstructed()->x113c_playerActorsLoading;
x355_24_areaTrackingLoad = true; x355_24_areaTrackingLoad = true;
} }
if (GetActive()) { if (GetActive()) {