From 5da883f0f0fa8d0dd728fc7aebe578478cf836b9 Mon Sep 17 00:00:00 2001 From: Christian Semmler Date: Wed, 31 Jan 2024 07:29:03 -0500 Subject: [PATCH] Rename stuff, add default arg --- LEGO1/lego/legoomni/include/legogamestate.h | 12 ++++++------ .../legoomni/src/common/legogamestate.cpp | 19 ++++++++++--------- LEGO1/lego/legoomni/src/common/legoutil.cpp | 3 +++ .../src/infocenter/elevatorbottom.cpp | 4 ++-- .../legoomni/src/infocenter/infocenter.cpp | 2 +- .../src/infocenter/infocenterdoor.cpp | 2 +- LEGO1/lego/legoomni/src/infocenter/score.cpp | 4 ++-- LEGO1/lego/legoomni/src/isle/isle.cpp | 8 ++++---- LEGO1/lego/legoomni/src/police/police.cpp | 2 +- 9 files changed, 30 insertions(+), 26 deletions(-) diff --git a/LEGO1/lego/legoomni/include/legogamestate.h b/LEGO1/lego/legoomni/include/legogamestate.h index 6940ede3..27ba2da8 100644 --- a/LEGO1/lego/legoomni/include/legogamestate.h +++ b/LEGO1/lego/legoomni/include/legogamestate.h @@ -32,15 +32,15 @@ class LegoGameState { LegoState* CreateState(const char* p_stateName); void GetFileSavePath(MxString* p_outPath, MxULong p_slotn); - void StopPreviousAction(MxU32); - void HandleAction(MxU32); + void StopArea(MxU32 p_area = 0); + void SwitchArea(MxU32 p_area); inline MxU8 GetUnknownC() { return m_unk0x0c; } inline MxU32 GetUnknown10() { return m_unk0x10; } inline MxS32 GetCurrentAct() { return m_currentAct; } - inline undefined4 GetUnknown424() { return m_unk0x424; } + inline undefined4 GetUnknown424() { return m_currentArea; } inline void SetDirty(MxBool p_dirty) { m_isDirty = p_dirty; } - inline void SetUnknown424(undefined4 p_unk0x424) { m_unk0x424 = p_unk0x424; } + inline void SetUnknown424(undefined4 p_unk0x424) { m_currentArea = p_unk0x424; } void SetSomeEnumState(undefined4 p_state); void FUN_1003ceb0(); @@ -75,8 +75,8 @@ class LegoGameState { ScoreStruct m_unk0xa6; // 0xa6 undefined m_unk0x41a[8]; // 0x41a - might be part of the structure at 0xa6 MxBool m_isDirty; // 0x420 - undefined4 m_unk0x424; // 0x424 - undefined4 m_prevArea; // 0x428 + undefined4 m_currentArea; // 0x424 + undefined4 m_previousArea; // 0x428 undefined4 m_unk0x42c; // 0x42c }; diff --git a/LEGO1/lego/legoomni/src/common/legogamestate.cpp b/LEGO1/lego/legoomni/src/common/legogamestate.cpp index aaab8dbc..789cf7c8 100644 --- a/LEGO1/lego/legoomni/src/common/legogamestate.cpp +++ b/LEGO1/lego/legoomni/src/common/legogamestate.cpp @@ -69,8 +69,8 @@ LegoGameState::LegoGameState() this->m_stateCount = 0; this->m_unk0x0c = 0; this->m_savePath = NULL; - this->m_unk0x424 = 0; - this->m_prevArea = 0; + this->m_currentArea = 0; + this->m_previousArea = 0; this->m_unk0x42c = 0; this->m_isDirty = FALSE; this->m_currentAct = -1; @@ -257,10 +257,10 @@ void LegoGameState::SerializePlayersInfo(MxS16) } // FUNCTION: LEGO1 0x1003a720 -void LegoGameState::StopPreviousAction(MxU32 p_area) +void LegoGameState::StopArea(MxU32 p_area) { if (p_area == 0) { - p_area = m_prevArea; + p_area = m_previousArea; } switch (p_area) { @@ -397,13 +397,13 @@ void LegoGameState::StopPreviousAction(MxU32 p_area) InvokeAction(Extra::e_close, *g_racecarScript, 0, NULL); break; case 0x2e: - if (m_unk0x424 != 2) { + if (m_currentArea != 2) { InvokeAction(Extra::e_stop, *g_act2mainScript, 0, NULL); InvokeAction(Extra::e_close, *g_act2mainScript, 0, NULL); } break; case 0x2f: - if (m_unk0x424 != 2) { + if (m_currentArea != 2) { InvokeAction(Extra::e_stop, *g_act3Script, 0, NULL); InvokeAction(Extra::e_close, *g_act3Script, 0, NULL); } @@ -421,10 +421,11 @@ void LegoGameState::StopPreviousAction(MxU32 p_area) } // STUB: LEGO1 0x1003b060 -void LegoGameState::HandleAction(MxU32 p_area) +void LegoGameState::SwitchArea(MxU32 p_area) { - m_prevArea = m_unk0x424; - m_unk0x424 = p_area; + m_previousArea = m_currentArea; + m_currentArea = p_area; + BackgroundAudioManager()->Stop(); AnimationManager()->FUN_1005ef10(); VideoManager()->SetUnk0x554(0); diff --git a/LEGO1/lego/legoomni/src/common/legoutil.cpp b/LEGO1/lego/legoomni/src/common/legoutil.cpp index 66409899..9f388ad5 100644 --- a/LEGO1/lego/legoomni/src/common/legoutil.cpp +++ b/LEGO1/lego/legoomni/src/common/legoutil.cpp @@ -199,8 +199,10 @@ MxBool FUN_1003ee00(MxAtomId& p_atomId, MxS32 p_id) MxBool RemoveFromWorld(MxAtomId& p_entityAtom, MxS32 p_entityId, MxAtomId& p_worldAtom, MxS32 p_worldEntityId) { LegoWorld* world = FindWorld(p_worldAtom, p_worldEntityId); + if (world) { MxCore* object = world->Find(p_entityAtom, p_entityId); + if (object) { world->Remove(object); @@ -218,6 +220,7 @@ MxBool RemoveFromWorld(MxAtomId& p_entityAtom, MxS32 p_entityId, MxAtomId& p_wor return TRUE; } } + return FALSE; } diff --git a/LEGO1/lego/legoomni/src/infocenter/elevatorbottom.cpp b/LEGO1/lego/legoomni/src/infocenter/elevatorbottom.cpp index 3ddab4a0..27c57d3e 100644 --- a/LEGO1/lego/legoomni/src/infocenter/elevatorbottom.cpp +++ b/LEGO1/lego/legoomni/src/infocenter/elevatorbottom.cpp @@ -39,7 +39,7 @@ MxResult ElevatorBottom::Create(MxDSAction& p_dsAction) SetIsWorldActive(FALSE); GameState()->SetUnknown424(5); - GameState()->StopPreviousAction(0); + GameState()->StopArea(); return result; } @@ -56,7 +56,7 @@ MxLong ElevatorBottom::Notify(MxParam& p_param) ret = HandleNotification17(p_param); break; case c_notificationTransitioned: - GameState()->HandleAction(m_unk0xf8); + GameState()->SwitchArea(m_unk0xf8); break; } } diff --git a/LEGO1/lego/legoomni/src/infocenter/infocenter.cpp b/LEGO1/lego/legoomni/src/infocenter/infocenter.cpp index 651f06a6..3dca5c64 100644 --- a/LEGO1/lego/legoomni/src/infocenter/infocenter.cpp +++ b/LEGO1/lego/legoomni/src/infocenter/infocenter.cpp @@ -139,7 +139,7 @@ MxLong Infocenter::Notify(MxParam& p_param) } else if (m_unk0x104 != 0) { BackgroundAudioManager()->RaiseVolume(); - GameState()->HandleAction(m_unk0x104); + GameState()->SwitchArea(m_unk0x104); m_unk0x104 = 0; } break; diff --git a/LEGO1/lego/legoomni/src/infocenter/infocenterdoor.cpp b/LEGO1/lego/legoomni/src/infocenter/infocenterdoor.cpp index 2348397d..0037fee6 100644 --- a/LEGO1/lego/legoomni/src/infocenter/infocenterdoor.cpp +++ b/LEGO1/lego/legoomni/src/infocenter/infocenterdoor.cpp @@ -40,7 +40,7 @@ MxResult InfocenterDoor::Create(MxDSAction& p_dsAction) SetIsWorldActive(FALSE); GameState()->SetUnknown424(3); - GameState()->StopPreviousAction(0); + GameState()->StopArea(); return result; } diff --git a/LEGO1/lego/legoomni/src/infocenter/score.cpp b/LEGO1/lego/legoomni/src/infocenter/score.cpp index cc48344f..e20c0a5e 100644 --- a/LEGO1/lego/legoomni/src/infocenter/score.cpp +++ b/LEGO1/lego/legoomni/src/infocenter/score.cpp @@ -53,7 +53,7 @@ MxResult Score::Create(MxDSAction& p_dsAction) ScoreState* state = (ScoreState*) gs->GetState("ScoreState"); m_state = state ? state : (ScoreState*) gs->CreateState("ScoreState"); GameState()->SetUnknown424(0xd); - GameState()->StopPreviousAction(0); + GameState()->StopArea(); } return result; @@ -97,7 +97,7 @@ MxLong Score::Notify(MxParam& p_param) case c_notificationTransitioned: DeleteObjects(g_infoscorScript, 7, 9); if (m_unk0xf8) - GameState()->HandleAction(m_unk0xf8); + GameState()->SwitchArea(m_unk0xf8); ret = 1; break; default: diff --git a/LEGO1/lego/legoomni/src/isle/isle.cpp b/LEGO1/lego/legoomni/src/isle/isle.cpp index 01d94a9b..492dca14 100644 --- a/LEGO1/lego/legoomni/src/isle/isle.cpp +++ b/LEGO1/lego/legoomni/src/isle/isle.cpp @@ -62,14 +62,14 @@ MxResult Isle::Create(MxDSAction& p_dsAction) if (result == SUCCESS) { ControlManager()->Register(this); InputManager()->SetWorld(this); - GameState()->StopPreviousAction(0); + GameState()->StopArea(); switch (GameState()->GetCurrentAct()) { case 1: - GameState()->StopPreviousAction(0x2e); + GameState()->StopArea(0x2e); break; case 2: - GameState()->StopPreviousAction(0x2e); + GameState()->StopArea(0x2e); break; case -1: m_unk0x13c = 2; @@ -158,7 +158,7 @@ void Isle::ReadyWorld() LegoWorld::ReadyWorld(); if (m_act1state->GetUnknown21()) { - GameState()->HandleAction(2); + GameState()->SwitchArea(2); m_act1state->SetUnknown18(0); m_act1state->SetUnknown21(0); } diff --git a/LEGO1/lego/legoomni/src/police/police.cpp b/LEGO1/lego/legoomni/src/police/police.cpp index 824c53af..e1045bf1 100644 --- a/LEGO1/lego/legoomni/src/police/police.cpp +++ b/LEGO1/lego/legoomni/src/police/police.cpp @@ -56,7 +56,7 @@ MxResult Police::Create(MxDSAction& p_dsAction) m_policeState = policeState; GameState()->SetUnknown424(0x22); - GameState()->StopPreviousAction(0); + GameState()->StopArea(); return ret; }