Attempt 4 to fix ScriptLayerController for Tom

This commit is contained in:
Phillip Stephens 2020-10-21 15:55:45 -07:00
parent 528c96b2c0
commit b963ce1e85
Signed by: Antidote
GPG Key ID: F8BEE4C83DACA60D
9 changed files with 26 additions and 23 deletions

View File

@ -35,7 +35,7 @@ bool CSaveWorldIntermediate::InitializePump() {
xc_areaIds.reserve(areaCount);
for (u32 i = 0; i < areaCount; ++i) {
const IGameArea* area = wld.IGetAreaAlways(i);
xc_areaIds.emplace_back(area->IGetAreaId());
xc_areaIds.emplace_back(area->IGetAreaSaveId());
}
CAssetId mlvlId = wld.IGetWorldAssetId();

View File

@ -24,7 +24,7 @@ class CSaveWorldMemory {
CAssetId x0_strgId;
CAssetId x4_savwId;
u32 x8_areaCount;
std::vector<CAssetId> xc_areaIds;
std::vector<s32> xc_areaIds;
std::vector<CWorldLayers::Area> x1c_defaultLayerStates;
TLockedToken<CStringTable> x2c_worldName; /* used to be optional */
TLockedToken<CSaveWorld> x3c_saveWorld; /* used to be optional */
@ -48,7 +48,7 @@ class CSaveWorldIntermediate {
CAssetId x0_mlvlId;
CAssetId x4_strgId;
CAssetId x8_savwId;
std::vector<CAssetId> xc_areaIds;
std::vector<s32> xc_areaIds;
std::vector<CWorldLayers::Area> x1c_defaultLayerStates;
std::unique_ptr<CDummyWorld> x2c_dummyWorld;
TLockedToken<CSaveWorld> x34_saveWorld; /* Used to be auto_ptr */

View File

@ -2004,7 +2004,7 @@ void CStateManager::UpdateAreaSounds() {
occState = area.GetOcclusionState();
}
if (occState == CGameArea::EOcclusionState::Visible) {
areas.push_back(area.GetAreaIndex());
areas.push_back(area.GetAreaId());
}
}
CSfxManager::SetActiveAreas(areas);

View File

@ -183,7 +183,7 @@ bool CActorLights::BuildAreaLightList(const CStateManager& mgr, const CGameArea&
}
zeus::CVector3f vec;
if (!x298_24_dirty && x294_aid == area.GetAreaIndex()) {
if (!x298_24_dirty && x294_aid == area.GetAreaId()) {
/* Early return if not ready for update */
if (mgr.GetInputFrameIdx() - x2a4_lastUpdateFrame < x2a8_areaUpdateFramePeriod)
return false;
@ -193,7 +193,7 @@ bool CActorLights::BuildAreaLightList(const CStateManager& mgr, const CGameArea&
return false;
x2c0_lastActorPos = vec;
} else {
if (x294_aid != area.GetAreaIndex())
if (x294_aid != area.GetAreaId())
x2d8_brightLightIdx = -1;
x2a4_lastUpdateFrame = sFrameSchedulerCount + mgr.GetInputFrameIdx();
vec = aabb.center() + x2ac_actorPosBias;
@ -203,7 +203,7 @@ bool CActorLights::BuildAreaLightList(const CStateManager& mgr, const CGameArea&
/* Reset lighting state */
x2d4_worldLightingLevel = worldLightingLevel;
x298_24_dirty = false;
x294_aid = area.GetAreaIndex();
x294_aid = area.GetAreaId();
x29c_shadowLightArrIdx = -1;
x288_ambientColor = zeus::skClear;

View File

@ -305,8 +305,11 @@ CDummyGameArea::CDummyGameArea(CInputStream& in, int idx, int mlvlVersion) {
zeus::CAABox aabb;
aabb.readBoundingBoxBig(in);
xc_mrea = in.readUint32Big();
if (mlvlVersion > 15)
x10_areaId = CAssetId(in);
if (mlvlVersion > 15) {
x10_areaId = in.readUint32Big();
} else {
x10_areaId = -1;
}
u32 attachAreaCount = in.readUint32Big();
x44_attachedAreaIndices.reserve(attachAreaCount);
@ -332,7 +335,7 @@ std::pair<std::unique_ptr<u8[]>, s32> CDummyGameArea::IGetScriptingMemoryAlways(
return GetScriptingMemoryAlways(*this);
}
CAssetId CDummyGameArea::IGetAreaId() const { return x10_areaId; }
s32 CDummyGameArea::IGetAreaSaveId() const { return x10_areaId; }
CAssetId CDummyGameArea::IGetAreaAssetId() const { return xc_mrea; }
@ -354,9 +357,9 @@ CGameArea::CGameArea(CInputStream& in, int idx, int mlvlVersion) : x4_selfIdx(id
x84_mrea = in.readUint32Big();
if (mlvlVersion > 15)
x88_areaId = CAssetId(in);
x88_areaId = in.readUint32Big();
else
x88_areaId = CAssetId();
x88_areaId = INT_MAX;
const u32 attachedCount = in.readUint32Big();
x8c_attachedAreaIndices.reserve(attachedCount);
@ -782,7 +785,7 @@ bool CGameArea::Invalidate(CStateManager* mgr) {
}
if (mgr)
mgr->PrepareAreaUnload(GetAreaIndex());
mgr->PrepareAreaUnload(GetAreaId());
#if 0
dword_805a8eb0 -= GetPostConstructedSize();
@ -797,7 +800,7 @@ bool CGameArea::Invalidate(CStateManager* mgr) {
KillmAreaData();
ClearTokenList();
if (mgr)
mgr->AreaUnloaded(GetAreaIndex());
mgr->AreaUnloaded(GetAreaId());
return true;
}

View File

@ -47,7 +47,7 @@ class CDummyGameArea final : public IGameArea {
int x4_mlvlVersion;
CAssetId x8_nameSTRG;
CAssetId xc_mrea;
CAssetId x10_areaId;
s32 x10_areaId;
zeus::CTransform x14_transform;
std::vector<u16> x44_attachedAreaIndices;
std::vector<Dock> x54_docks;
@ -56,7 +56,7 @@ public:
CDummyGameArea(CInputStream& in, int idx, int mlvlVersion);
std::pair<std::unique_ptr<u8[]>, s32> IGetScriptingMemoryAlways() const override;
CAssetId IGetAreaId() const override;
s32 IGetAreaSaveId() const override;
CAssetId IGetAreaAssetId() const override;
bool IIsActive() const override;
TAreaId IGetAttachedAreaId(int) const override;
@ -104,7 +104,7 @@ class CGameArea final : public IGameArea {
zeus::CTransform x3c_invTransform;
zeus::CAABox x6c_aabb;
CAssetId x84_mrea;
CAssetId x88_areaId;
s32 x88_areaId;
std::vector<u16> x8c_attachedAreaIndices;
std::vector<SObjectTag> x9c_deps1;
std::vector<SObjectTag> xac_deps2;
@ -278,8 +278,8 @@ public:
void SetLoadPauseState(bool paused);
std::pair<std::unique_ptr<u8[]>, s32> IGetScriptingMemoryAlways() const override;
TAreaId GetAreaIndex() const { return x4_selfIdx; }
CAssetId IGetAreaId() const override { return x88_areaId; }
TAreaId GetAreaId() const { return x4_selfIdx; }
s32 IGetAreaSaveId() const override { return x88_areaId; }
CAssetId IGetAreaAssetId() const override { return x84_mrea; }
bool IIsActive() const override;
TAreaId IGetAttachedAreaId(int) const override;

View File

@ -16,7 +16,7 @@ void CMorphBallShadow::GatherAreas(const CStateManager& mgr) {
if (area.IsPostConstructed())
occState = area.GetPostConstructed()->x10dc_occlusionState;
if (occState == CGameArea::EOcclusionState::Visible)
x18_areas.push_back(area.GetAreaIndex());
x18_areas.push_back(area.GetAreaId());
}
}
@ -105,7 +105,7 @@ bool CMorphBallShadow::AreasValid(const CStateManager& mgr) const {
continue;
if (it == x18_areas.end())
return false;
if (*it != area.GetAreaIndex())
if (*it != area.GetAreaId())
return false;
++it;
}

View File

@ -364,7 +364,7 @@ CScriptDoor::EDoorOpenCondition CScriptDoor::GetDoorOpenCondition(CStateManager&
}
for (const CGameArea& aliveArea : *world) {
if (aliveArea.GetAreaIndex() == area->GetAreaIndex()) {
if (aliveArea.GetAreaId() == area->GetAreaId()) {
continue;
}

View File

@ -49,7 +49,7 @@ public:
};
virtual std::pair<std::unique_ptr<u8[]>, s32> IGetScriptingMemoryAlways() const = 0;
virtual CAssetId IGetAreaId() const = 0;
virtual s32 IGetAreaSaveId() const = 0;
virtual CAssetId IGetAreaAssetId() const = 0;
virtual bool IIsActive() const = 0;
virtual TAreaId IGetAttachedAreaId(int) const = 0;