From 44bc575a2da70de35c4efe69d794b90e3e1d7290 Mon Sep 17 00:00:00 2001 From: Christian Semmler Date: Tue, 19 Mar 2024 07:45:29 -0400 Subject: [PATCH] Replace some magic numbers with enum values (#692) --- .../legoomni/include/legoanimationmanager.h | 11 +++++- .../src/common/legoanimationmanager.cpp | 13 +++++-- .../legoomni/src/common/legogamestate.cpp | 6 ++++ LEGO1/lego/legoomni/src/worlds/isle.cpp | 34 +++++++++---------- 4 files changed, 44 insertions(+), 20 deletions(-) diff --git a/LEGO1/lego/legoomni/include/legoanimationmanager.h b/LEGO1/lego/legoomni/include/legoanimationmanager.h index 2feb7a6d..e46e1f72 100644 --- a/LEGO1/lego/legoomni/include/legoanimationmanager.h +++ b/LEGO1/lego/legoomni/include/legoanimationmanager.h @@ -13,6 +13,15 @@ struct Character { MxBool m_active; // 0x14 }; +namespace IsleScript +{ +#ifdef COMPAT_MODE +enum Script : int; +#else +enum Script; +#endif +} // namespace IsleScript + // VTABLE: LEGO1 0x100d8c18 // SIZE 0x500 class LegoAnimationManager : public MxCore { @@ -47,7 +56,7 @@ class LegoAnimationManager : public MxCore { MxResult ReadModelInfo(LegoFile* p_file, ModelInfo* p_info); void FUN_100603c0(); undefined4 FUN_10060dc0( - undefined4, + IsleScript::Script, undefined4, undefined, undefined, diff --git a/LEGO1/lego/legoomni/src/common/legoanimationmanager.cpp b/LEGO1/lego/legoomni/src/common/legoanimationmanager.cpp index c9ac8136..5cf614bf 100644 --- a/LEGO1/lego/legoomni/src/common/legoanimationmanager.cpp +++ b/LEGO1/lego/legoomni/src/common/legoanimationmanager.cpp @@ -345,8 +345,17 @@ void LegoAnimationManager::FUN_100603c0() } // STUB: LEGO1 0x10060dc0 -undefined4 LegoAnimationManager:: - FUN_10060dc0(undefined4, undefined4, undefined, undefined, undefined4, undefined, undefined, undefined, undefined) +undefined4 LegoAnimationManager::FUN_10060dc0( + IsleScript::Script, + undefined4, + undefined, + undefined, + undefined4, + undefined, + undefined, + undefined, + undefined +) { // TODO return 0; diff --git a/LEGO1/lego/legoomni/src/common/legogamestate.cpp b/LEGO1/lego/legoomni/src/common/legogamestate.cpp index 442dd32a..8442c698 100644 --- a/LEGO1/lego/legoomni/src/common/legogamestate.cpp +++ b/LEGO1/lego/legoomni/src/common/legogamestate.cpp @@ -873,6 +873,7 @@ void LegoGameState::SwitchArea(Area p_area) case e_unk28: { Act1State* state = (Act1State*) GameState()->GetState("Act1State"); LoadIsle(); + if (state->GetUnknown18() == 7) { VideoManager()->Get3DManager()->SetFrustrum(90, 0.1f, 250.0f); } @@ -881,6 +882,7 @@ void LegoGameState::SwitchArea(Area p_area) CurrentActor()->ResetWorldTransform(TRUE); AnimationManager()->FUN_1005f0b0(); } + CurrentActor()->VTable0xe8(p_area, TRUE, 7); break; } @@ -921,22 +923,26 @@ void LegoGameState::SwitchArea(Area p_area) break; case e_act2main: { LegoWorld* act2main = FindWorld(*g_act2mainScript, 0); + if (act2main == NULL) { InvokeAction(Extra::ActionType::e_opendisk, *g_act2mainScript, 0, NULL); } else { act2main->Enable(TRUE); } + break; } case e_act3script: { LegoWorld* act3 = FindWorld(*g_act3Script, 0); + if (act3 == NULL) { InvokeAction(Extra::ActionType::e_opendisk, *g_act3Script, 0, NULL); } else { act3->Enable(TRUE); } + break; } case e_jukeboxw: diff --git a/LEGO1/lego/legoomni/src/worlds/isle.cpp b/LEGO1/lego/legoomni/src/worlds/isle.cpp index c3d8a6ad..85d87809 100644 --- a/LEGO1/lego/legoomni/src/worlds/isle.cpp +++ b/LEGO1/lego/legoomni/src/worlds/isle.cpp @@ -79,8 +79,8 @@ Isle::~Isle() MxResult Isle::Create(MxDSAction& p_dsAction) { GameState()->FindLoadedAct(); - MxResult result = LegoWorld::Create(p_dsAction); + if (result == SUCCESS) { ControlManager()->Register(this); InputManager()->SetWorld(this); @@ -102,11 +102,11 @@ MxResult Isle::Create(MxDSAction& p_dsAction) } LegoGameState* gameState = GameState(); - Act1State* state = (Act1State*) gameState->GetState("Act1State"); - if (state == NULL) { - state = (Act1State*) gameState->CreateState("Act1State"); + Act1State* act1state = (Act1State*) gameState->GetState("Act1State"); + if (act1state == NULL) { + act1state = (Act1State*) gameState->CreateState("Act1State"); } - m_act1state = state; + m_act1state = act1state; FUN_1003ef00(TRUE); GameState()->SetDirty(TRUE); @@ -128,7 +128,7 @@ MxLong Isle::Notify(MxParam& p_param) break; case c_notificationButtonUp: case c_notificationButtonDown: - switch (m_act1state->GetUnknown18()) { + switch (m_act1state->m_unk0x018) { case 3: result = m_pizza->Notify(p_param); break; @@ -141,7 +141,7 @@ MxLong Isle::Notify(MxParam& p_param) result = HandleClick((LegoControlManagerEvent&) p_param); break; case c_notificationType18: - switch (m_act1state->GetUnknown18()) { + switch (m_act1state->m_unk0x018) { case 4: result = CurrentActor()->Notify(p_param); break; @@ -681,21 +681,21 @@ void Isle::Enable(MxBool p_enable) JetskiRaceState* raceState = (JetskiRaceState*) GameState()->GetState("JetskiRaceState"); if (raceState->GetUnknown0x28() == 2) { - undefined4 und = -1; + IsleScript::Script script = IsleScript::c_noneIsle; switch (raceState->GetState(GameState()->GetActorId())->GetUnknown0x02()) { case 1: - und = 0x35e; + script = IsleScript::c_sjs014in_RunAnim; break; case 2: - und = 0x35d; + script = IsleScript::c_sjs013in_RunAnim; break; case 3: - und = 0x35c; + script = IsleScript::c_sjs012in_RunAnim; break; } - AnimationManager()->FUN_10060dc0(und, 0, 1, 1, 0, 0, 0, 1, 0); + AnimationManager()->FUN_10060dc0(script, 0, 1, 1, 0, 0, 0, 1, 0); } m_act1state->m_unk0x018 = 0; @@ -709,21 +709,21 @@ void Isle::Enable(MxBool p_enable) CarRaceState* raceState = (CarRaceState*) GameState()->GetState("CarRaceState"); if (raceState->GetUnknown0x28() == 2) { - undefined4 und = -1; + IsleScript::Script script = IsleScript::c_noneIsle; switch (raceState->GetState(GameState()->GetActorId())->GetUnknown0x02()) { case 1: - und = 0x362; + script = IsleScript::c_srt003in_RunAnim; break; case 2: - und = 0x361; + script = IsleScript::c_srt002in_RunAnim; break; case 3: - und = 0x360; + script = IsleScript::c_srt001in_RunAnim; break; } - AnimationManager()->FUN_10060dc0(und, 0, 1, 1, 0, 0, 0, 1, 0); + AnimationManager()->FUN_10060dc0(script, 0, 1, 1, 0, 0, 0, 1, 0); } m_act1state->m_unk0x018 = 0;