From 180d4949da5862a6881b408e4bcaaa2a50cbae1b Mon Sep 17 00:00:00 2001 From: Fabian Neundorf Date: Tue, 10 Jun 2025 20:51:21 +0200 Subject: [PATCH 1/2] Clear unknowns in `PoliceState` (#1551) --- LEGO1/lego/legoomni/include/police.h | 8 ++++---- LEGO1/lego/legoomni/src/worlds/police.cpp | 24 +++++++++++------------ 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/LEGO1/lego/legoomni/include/police.h b/LEGO1/lego/legoomni/include/police.h index 39294cb1..ad56ccfa 100644 --- a/LEGO1/lego/legoomni/include/police.h +++ b/LEGO1/lego/legoomni/include/police.h @@ -38,15 +38,15 @@ class PoliceState : public LegoState { // SYNTHETIC: LEGO1 0x1005e920 // PoliceState::`scalar deleting destructor' - undefined4 GetUnknown0x0c() { return m_unk0x0c; } - void SetUnknown0x0c(undefined4 p_unk0x0c) { m_unk0x0c = p_unk0x0c; } + MxS32 GetPlayAnimation() { return m_playAnimation; } + void SetPlayAnimation(MxS32 p_playAnimation) { m_playAnimation = p_playAnimation; } - void FUN_1005ea40(); + void StartAnimation(); // TODO: Most likely getters/setters are not used according to BETA. PoliceScript::Script m_policeScript; // 0x08 - undefined4 m_unk0x0c; // 0x0c + MxS32 m_playAnimation; // 0x0c }; // VTABLE: LEGO1 0x100d8a80 diff --git a/LEGO1/lego/legoomni/src/worlds/police.cpp b/LEGO1/lego/legoomni/src/worlds/police.cpp index c1298bf3..08d567f0 100644 --- a/LEGO1/lego/legoomni/src/worlds/police.cpp +++ b/LEGO1/lego/legoomni/src/worlds/police.cpp @@ -105,7 +105,7 @@ MxLong Police::HandleControl(LegoControlManagerNotificationParam& p_param) switch (p_param.m_clickedObjectId) { case PoliceScript::c_LeftArrow_Ctl: case PoliceScript::c_RightArrow_Ctl: - if (m_policeState->GetUnknown0x0c() == 1) { + if (m_policeState->GetPlayAnimation() == 1) { DeleteObjects(&m_atomId, PoliceScript::c_nps001ni_RunAnim, PoliceScript::c_nps002la_RunAnim); } @@ -114,7 +114,7 @@ MxLong Police::HandleControl(LegoControlManagerNotificationParam& p_param) TransitionManager()->StartTransition(MxTransitionManager::e_mosaic, 50, FALSE, FALSE); break; case PoliceScript::c_Info_Ctl: - if (m_policeState->GetUnknown0x0c() == 1) { + if (m_policeState->GetPlayAnimation() == 1) { DeleteObjects(&m_atomId, PoliceScript::c_nps001ni_RunAnim, PoliceScript::c_nps002la_RunAnim); } @@ -123,7 +123,7 @@ MxLong Police::HandleControl(LegoControlManagerNotificationParam& p_param) TransitionManager()->StartTransition(MxTransitionManager::e_mosaic, 50, FALSE, FALSE); break; case PoliceScript::c_Door_Ctl: - if (m_policeState->GetUnknown0x0c() == 1) { + if (m_policeState->GetPlayAnimation() == 1) { DeleteObjects(&m_atomId, PoliceScript::c_nps001ni_RunAnim, PoliceScript::c_nps002la_RunAnim); } @@ -132,7 +132,7 @@ MxLong Police::HandleControl(LegoControlManagerNotificationParam& p_param) TransitionManager()->StartTransition(MxTransitionManager::e_mosaic, 50, FALSE, FALSE); break; case PoliceScript::c_Donut_Ctl: - m_policeState->FUN_1005ea40(); + m_policeState->StartAnimation(); } } @@ -145,8 +145,8 @@ MxLong Police::HandleEndAction(MxEndActionNotificationParam& p_param) MxDSAction* action = p_param.GetAction(); if (m_radio.Notify(p_param) == 0 && m_atomId == action->GetAtomId()) { - if (m_policeState->GetUnknown0x0c() == 1) { - m_policeState->SetUnknown0x0c(0); + if (m_policeState->GetPlayAnimation() == 1) { + m_policeState->SetPlayAnimation(0); return 1; } @@ -161,9 +161,9 @@ MxLong Police::HandleKeyPress(LegoEventNotificationParam& p_param) { MxLong result = 0; - if (p_param.GetKey() == VK_SPACE && m_policeState->GetUnknown0x0c() == 1) { + if (p_param.GetKey() == VK_SPACE && m_policeState->GetPlayAnimation() == 1) { DeleteObjects(&m_atomId, PoliceScript::c_nps001ni_RunAnim, PoliceScript::c_nps002la_RunAnim); - m_policeState->SetUnknown0x0c(0); + m_policeState->SetPlayAnimation(0); return 1; } @@ -197,7 +197,7 @@ MxBool Police::Escape() // FUNCTION: LEGO1 0x1005e7c0 PoliceState::PoliceState() { - m_unk0x0c = 0; + m_playAnimation = 0; m_policeScript = (rand() % 2 == 0) ? PoliceScript::c_nps002la_RunAnim : PoliceScript::c_nps001ni_RunAnim; } @@ -218,11 +218,11 @@ MxResult PoliceState::Serialize(LegoStorage* p_storage) } // FUNCTION: LEGO1 0x1005ea40 -void PoliceState::FUN_1005ea40() +void PoliceState::StartAnimation() { PoliceScript::Script policeScript; - if (m_unk0x0c == 1) { + if (m_playAnimation == 1) { return; } @@ -248,5 +248,5 @@ void PoliceState::FUN_1005ea40() Start(&action); } - m_unk0x0c = 1; + m_playAnimation = 1; } From 99ff92e49eb2907742f8f35786b719b943484693 Mon Sep 17 00:00:00 2001 From: Fabian Neundorf Date: Wed, 11 Jun 2025 01:07:10 +0200 Subject: [PATCH 2/2] Use enum for states in `PoliceState` (#1552) --- LEGO1/lego/legoomni/include/police.h | 11 ++++++++--- LEGO1/lego/legoomni/src/worlds/police.cpp | 20 ++++++++++---------- 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/LEGO1/lego/legoomni/include/police.h b/LEGO1/lego/legoomni/include/police.h index ad56ccfa..8d8d7840 100644 --- a/LEGO1/lego/legoomni/include/police.h +++ b/LEGO1/lego/legoomni/include/police.h @@ -16,6 +16,11 @@ class MxDSAction; // SIZE 0x10 class PoliceState : public LegoState { public: + enum { + e_noAnimation = 0, + e_playingAnimation = 1, + }; + PoliceState(); ~PoliceState() override {} @@ -38,15 +43,15 @@ class PoliceState : public LegoState { // SYNTHETIC: LEGO1 0x1005e920 // PoliceState::`scalar deleting destructor' - MxS32 GetPlayAnimation() { return m_playAnimation; } - void SetPlayAnimation(MxS32 p_playAnimation) { m_playAnimation = p_playAnimation; } + MxS32 GetState() { return m_state; } + void SetState(MxS32 p_state) { m_state = p_state; } void StartAnimation(); // TODO: Most likely getters/setters are not used according to BETA. PoliceScript::Script m_policeScript; // 0x08 - MxS32 m_playAnimation; // 0x0c + MxS32 m_state; // 0x0c }; // VTABLE: LEGO1 0x100d8a80 diff --git a/LEGO1/lego/legoomni/src/worlds/police.cpp b/LEGO1/lego/legoomni/src/worlds/police.cpp index 08d567f0..f1936ead 100644 --- a/LEGO1/lego/legoomni/src/worlds/police.cpp +++ b/LEGO1/lego/legoomni/src/worlds/police.cpp @@ -105,7 +105,7 @@ MxLong Police::HandleControl(LegoControlManagerNotificationParam& p_param) switch (p_param.m_clickedObjectId) { case PoliceScript::c_LeftArrow_Ctl: case PoliceScript::c_RightArrow_Ctl: - if (m_policeState->GetPlayAnimation() == 1) { + if (m_policeState->GetState() == PoliceState::e_playingAnimation) { DeleteObjects(&m_atomId, PoliceScript::c_nps001ni_RunAnim, PoliceScript::c_nps002la_RunAnim); } @@ -114,7 +114,7 @@ MxLong Police::HandleControl(LegoControlManagerNotificationParam& p_param) TransitionManager()->StartTransition(MxTransitionManager::e_mosaic, 50, FALSE, FALSE); break; case PoliceScript::c_Info_Ctl: - if (m_policeState->GetPlayAnimation() == 1) { + if (m_policeState->GetState() == PoliceState::e_playingAnimation) { DeleteObjects(&m_atomId, PoliceScript::c_nps001ni_RunAnim, PoliceScript::c_nps002la_RunAnim); } @@ -123,7 +123,7 @@ MxLong Police::HandleControl(LegoControlManagerNotificationParam& p_param) TransitionManager()->StartTransition(MxTransitionManager::e_mosaic, 50, FALSE, FALSE); break; case PoliceScript::c_Door_Ctl: - if (m_policeState->GetPlayAnimation() == 1) { + if (m_policeState->GetState() == PoliceState::e_playingAnimation) { DeleteObjects(&m_atomId, PoliceScript::c_nps001ni_RunAnim, PoliceScript::c_nps002la_RunAnim); } @@ -145,8 +145,8 @@ MxLong Police::HandleEndAction(MxEndActionNotificationParam& p_param) MxDSAction* action = p_param.GetAction(); if (m_radio.Notify(p_param) == 0 && m_atomId == action->GetAtomId()) { - if (m_policeState->GetPlayAnimation() == 1) { - m_policeState->SetPlayAnimation(0); + if (m_policeState->GetState() == PoliceState::e_playingAnimation) { + m_policeState->SetState(PoliceState::e_noAnimation); return 1; } @@ -161,9 +161,9 @@ MxLong Police::HandleKeyPress(LegoEventNotificationParam& p_param) { MxLong result = 0; - if (p_param.GetKey() == VK_SPACE && m_policeState->GetPlayAnimation() == 1) { + if (p_param.GetKey() == VK_SPACE && m_policeState->GetState() == PoliceState::e_playingAnimation) { DeleteObjects(&m_atomId, PoliceScript::c_nps001ni_RunAnim, PoliceScript::c_nps002la_RunAnim); - m_policeState->SetPlayAnimation(0); + m_policeState->SetState(PoliceState::e_noAnimation); return 1; } @@ -197,7 +197,7 @@ MxBool Police::Escape() // FUNCTION: LEGO1 0x1005e7c0 PoliceState::PoliceState() { - m_playAnimation = 0; + m_state = PoliceState::e_noAnimation; m_policeScript = (rand() % 2 == 0) ? PoliceScript::c_nps002la_RunAnim : PoliceScript::c_nps001ni_RunAnim; } @@ -222,7 +222,7 @@ void PoliceState::StartAnimation() { PoliceScript::Script policeScript; - if (m_playAnimation == 1) { + if (m_state == PoliceState::e_playingAnimation) { return; } @@ -248,5 +248,5 @@ void PoliceState::StartAnimation() Start(&action); } - m_playAnimation = 1; + m_state = PoliceState::e_playingAnimation; }