Replace some magic numbers with enum values (#692)

This commit is contained in:
Christian Semmler 2024-03-19 07:45:29 -04:00 committed by GitHub
parent 52d74647be
commit 44bc575a2d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 44 additions and 20 deletions

View file

@ -13,6 +13,15 @@ struct Character {
MxBool m_active; // 0x14 MxBool m_active; // 0x14
}; };
namespace IsleScript
{
#ifdef COMPAT_MODE
enum Script : int;
#else
enum Script;
#endif
} // namespace IsleScript
// VTABLE: LEGO1 0x100d8c18 // VTABLE: LEGO1 0x100d8c18
// SIZE 0x500 // SIZE 0x500
class LegoAnimationManager : public MxCore { class LegoAnimationManager : public MxCore {
@ -47,7 +56,7 @@ class LegoAnimationManager : public MxCore {
MxResult ReadModelInfo(LegoFile* p_file, ModelInfo* p_info); MxResult ReadModelInfo(LegoFile* p_file, ModelInfo* p_info);
void FUN_100603c0(); void FUN_100603c0();
undefined4 FUN_10060dc0( undefined4 FUN_10060dc0(
undefined4, IsleScript::Script,
undefined4, undefined4,
undefined, undefined,
undefined, undefined,

View file

@ -345,8 +345,17 @@ void LegoAnimationManager::FUN_100603c0()
} }
// STUB: LEGO1 0x10060dc0 // STUB: LEGO1 0x10060dc0
undefined4 LegoAnimationManager:: undefined4 LegoAnimationManager::FUN_10060dc0(
FUN_10060dc0(undefined4, undefined4, undefined, undefined, undefined4, undefined, undefined, undefined, undefined) IsleScript::Script,
undefined4,
undefined,
undefined,
undefined4,
undefined,
undefined,
undefined,
undefined
)
{ {
// TODO // TODO
return 0; return 0;

View file

@ -873,6 +873,7 @@ void LegoGameState::SwitchArea(Area p_area)
case e_unk28: { case e_unk28: {
Act1State* state = (Act1State*) GameState()->GetState("Act1State"); Act1State* state = (Act1State*) GameState()->GetState("Act1State");
LoadIsle(); LoadIsle();
if (state->GetUnknown18() == 7) { if (state->GetUnknown18() == 7) {
VideoManager()->Get3DManager()->SetFrustrum(90, 0.1f, 250.0f); VideoManager()->Get3DManager()->SetFrustrum(90, 0.1f, 250.0f);
} }
@ -881,6 +882,7 @@ void LegoGameState::SwitchArea(Area p_area)
CurrentActor()->ResetWorldTransform(TRUE); CurrentActor()->ResetWorldTransform(TRUE);
AnimationManager()->FUN_1005f0b0(); AnimationManager()->FUN_1005f0b0();
} }
CurrentActor()->VTable0xe8(p_area, TRUE, 7); CurrentActor()->VTable0xe8(p_area, TRUE, 7);
break; break;
} }
@ -921,22 +923,26 @@ void LegoGameState::SwitchArea(Area p_area)
break; break;
case e_act2main: { case e_act2main: {
LegoWorld* act2main = FindWorld(*g_act2mainScript, 0); LegoWorld* act2main = FindWorld(*g_act2mainScript, 0);
if (act2main == NULL) { if (act2main == NULL) {
InvokeAction(Extra::ActionType::e_opendisk, *g_act2mainScript, 0, NULL); InvokeAction(Extra::ActionType::e_opendisk, *g_act2mainScript, 0, NULL);
} }
else { else {
act2main->Enable(TRUE); act2main->Enable(TRUE);
} }
break; break;
} }
case e_act3script: { case e_act3script: {
LegoWorld* act3 = FindWorld(*g_act3Script, 0); LegoWorld* act3 = FindWorld(*g_act3Script, 0);
if (act3 == NULL) { if (act3 == NULL) {
InvokeAction(Extra::ActionType::e_opendisk, *g_act3Script, 0, NULL); InvokeAction(Extra::ActionType::e_opendisk, *g_act3Script, 0, NULL);
} }
else { else {
act3->Enable(TRUE); act3->Enable(TRUE);
} }
break; break;
} }
case e_jukeboxw: case e_jukeboxw:

View file

@ -79,8 +79,8 @@ Isle::~Isle()
MxResult Isle::Create(MxDSAction& p_dsAction) MxResult Isle::Create(MxDSAction& p_dsAction)
{ {
GameState()->FindLoadedAct(); GameState()->FindLoadedAct();
MxResult result = LegoWorld::Create(p_dsAction); MxResult result = LegoWorld::Create(p_dsAction);
if (result == SUCCESS) { if (result == SUCCESS) {
ControlManager()->Register(this); ControlManager()->Register(this);
InputManager()->SetWorld(this); InputManager()->SetWorld(this);
@ -102,11 +102,11 @@ MxResult Isle::Create(MxDSAction& p_dsAction)
} }
LegoGameState* gameState = GameState(); LegoGameState* gameState = GameState();
Act1State* state = (Act1State*) gameState->GetState("Act1State"); Act1State* act1state = (Act1State*) gameState->GetState("Act1State");
if (state == NULL) { if (act1state == NULL) {
state = (Act1State*) gameState->CreateState("Act1State"); act1state = (Act1State*) gameState->CreateState("Act1State");
} }
m_act1state = state; m_act1state = act1state;
FUN_1003ef00(TRUE); FUN_1003ef00(TRUE);
GameState()->SetDirty(TRUE); GameState()->SetDirty(TRUE);
@ -128,7 +128,7 @@ MxLong Isle::Notify(MxParam& p_param)
break; break;
case c_notificationButtonUp: case c_notificationButtonUp:
case c_notificationButtonDown: case c_notificationButtonDown:
switch (m_act1state->GetUnknown18()) { switch (m_act1state->m_unk0x018) {
case 3: case 3:
result = m_pizza->Notify(p_param); result = m_pizza->Notify(p_param);
break; break;
@ -141,7 +141,7 @@ MxLong Isle::Notify(MxParam& p_param)
result = HandleClick((LegoControlManagerEvent&) p_param); result = HandleClick((LegoControlManagerEvent&) p_param);
break; break;
case c_notificationType18: case c_notificationType18:
switch (m_act1state->GetUnknown18()) { switch (m_act1state->m_unk0x018) {
case 4: case 4:
result = CurrentActor()->Notify(p_param); result = CurrentActor()->Notify(p_param);
break; break;
@ -681,21 +681,21 @@ void Isle::Enable(MxBool p_enable)
JetskiRaceState* raceState = (JetskiRaceState*) GameState()->GetState("JetskiRaceState"); JetskiRaceState* raceState = (JetskiRaceState*) GameState()->GetState("JetskiRaceState");
if (raceState->GetUnknown0x28() == 2) { if (raceState->GetUnknown0x28() == 2) {
undefined4 und = -1; IsleScript::Script script = IsleScript::c_noneIsle;
switch (raceState->GetState(GameState()->GetActorId())->GetUnknown0x02()) { switch (raceState->GetState(GameState()->GetActorId())->GetUnknown0x02()) {
case 1: case 1:
und = 0x35e; script = IsleScript::c_sjs014in_RunAnim;
break; break;
case 2: case 2:
und = 0x35d; script = IsleScript::c_sjs013in_RunAnim;
break; break;
case 3: case 3:
und = 0x35c; script = IsleScript::c_sjs012in_RunAnim;
break; 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; m_act1state->m_unk0x018 = 0;
@ -709,21 +709,21 @@ void Isle::Enable(MxBool p_enable)
CarRaceState* raceState = (CarRaceState*) GameState()->GetState("CarRaceState"); CarRaceState* raceState = (CarRaceState*) GameState()->GetState("CarRaceState");
if (raceState->GetUnknown0x28() == 2) { if (raceState->GetUnknown0x28() == 2) {
undefined4 und = -1; IsleScript::Script script = IsleScript::c_noneIsle;
switch (raceState->GetState(GameState()->GetActorId())->GetUnknown0x02()) { switch (raceState->GetState(GameState()->GetActorId())->GetUnknown0x02()) {
case 1: case 1:
und = 0x362; script = IsleScript::c_srt003in_RunAnim;
break; break;
case 2: case 2:
und = 0x361; script = IsleScript::c_srt002in_RunAnim;
break; break;
case 3: case 3:
und = 0x360; script = IsleScript::c_srt001in_RunAnim;
break; 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; m_act1state->m_unk0x018 = 0;