From 556c7698d825e96433ee9c7d1d6da099987fee5d Mon Sep 17 00:00:00 2001 From: Misha <106913236+MishaProductions@users.noreply.github.com> Date: Tue, 19 Mar 2024 16:07:07 -0400 Subject: [PATCH] implement RemoveFromCurrentWorld (#700) * implement RemoveFromCurrentWorld * Replace magic values --------- Co-authored-by: Christian Semmler --- LEGO1/lego/legoomni/include/legoutils.h | 2 +- LEGO1/lego/legoomni/src/actors/bike.cpp | 11 ++++--- LEGO1/lego/legoomni/src/actors/helicopter.cpp | 20 ++++++------ LEGO1/lego/legoomni/src/common/legoutils.cpp | 31 ++++++++++++++++--- 4 files changed, 44 insertions(+), 20 deletions(-) diff --git a/LEGO1/lego/legoomni/include/legoutils.h b/LEGO1/lego/legoomni/include/legoutils.h index 66d2a319..4e2652c3 100644 --- a/LEGO1/lego/legoomni/include/legoutils.h +++ b/LEGO1/lego/legoomni/include/legoutils.h @@ -20,7 +20,7 @@ Extra::ActionType MatchActionString(const char*); void InvokeAction(Extra::ActionType p_actionId, MxAtomId& p_pAtom, MxS32 p_targetEntityId, LegoEntity* p_sender); void SetCameraControllerFromIsle(); void ConvertHSVToRGB(float p_h, float p_s, float p_v, float* p_rOut, float* p_bOut, float* p_gOut); -MxBool FUN_1003ee00(MxAtomId& p_atomId, MxS32 p_id); +MxBool RemoveFromCurrentWorld(MxAtomId& p_atomId, MxS32 p_id); void FUN_1003ef00(MxBool); void SetAppCursor(WPARAM p_wparam); MxBool FUN_1003ef60(); diff --git a/LEGO1/lego/legoomni/src/actors/bike.cpp b/LEGO1/lego/legoomni/src/actors/bike.cpp index b0dcab1f..4ee38159 100644 --- a/LEGO1/lego/legoomni/src/actors/bike.cpp +++ b/LEGO1/lego/legoomni/src/actors/bike.cpp @@ -1,5 +1,6 @@ #include "bike.h" +#include "isle_actions.h" #include "legocontrolmanager.h" #include "legogamestate.h" #include "legoomni.h" @@ -35,11 +36,11 @@ void Bike::VTable0xe4() { IslePathActor::VTable0xe4(); GameState()->SetCurrentArea(LegoGameState::Area::e_bike); - FUN_1003ee00(*g_isleScript, 11); - FUN_1003ee00(*g_isleScript, 12); - FUN_1003ee00(*g_isleScript, 15); - FUN_1003ee00(*g_isleScript, 14); - FUN_1003ee00(*g_isleScript, 13); + RemoveFromCurrentWorld(*g_isleScript, IsleScript::c_BikeDashboard_Bitmap); + RemoveFromCurrentWorld(*g_isleScript, IsleScript::c_BikeArms_Ctl); + RemoveFromCurrentWorld(*g_isleScript, IsleScript::c_BikeHorn_Ctl); + RemoveFromCurrentWorld(*g_isleScript, IsleScript::c_BikeHorn_Sound); + RemoveFromCurrentWorld(*g_isleScript, IsleScript::c_BikeInfo_Ctl); ControlManager()->Unregister(this); } diff --git a/LEGO1/lego/legoomni/src/actors/helicopter.cpp b/LEGO1/lego/legoomni/src/actors/helicopter.cpp index 0b3a0878..6b473ba4 100644 --- a/LEGO1/lego/legoomni/src/actors/helicopter.cpp +++ b/LEGO1/lego/legoomni/src/actors/helicopter.cpp @@ -79,16 +79,16 @@ void Helicopter::VTable0xe4() } m_state->SetUnknown8(0); - FUN_1003ee00(m_script, 0x16); - FUN_1003ee00(m_script, 0x17); - FUN_1003ee00(m_script, 0x18); - FUN_1003ee00(m_script, 0x19); - FUN_1003ee00(m_script, 0x1a); - FUN_1003ee00(m_script, 0x1b); - FUN_1003ee00(m_script, 0x1c); - FUN_1003ee00(m_script, 0x1d); - FUN_1003ee00(m_script, 0x1e); - FUN_1003ee00(m_script, 0x1f); + RemoveFromCurrentWorld(m_script, IsleScript::c_HelicopterDashboard_Bitmap); + RemoveFromCurrentWorld(m_script, IsleScript::c_HelicopterArms_Ctl); + RemoveFromCurrentWorld(m_script, IsleScript::c_Helicopter_TakeOff_Ctl); + RemoveFromCurrentWorld(m_script, IsleScript::c_Helicopter_Land_Ctl); + RemoveFromCurrentWorld(m_script, Act3Script::c_Helicopter_Pizza_Ctl); + RemoveFromCurrentWorld(m_script, Act3Script::c_Helicopter_Donut_Ctl); + RemoveFromCurrentWorld(m_script, Act3Script::c_Helicopter_Info_Ctl); + RemoveFromCurrentWorld(m_script, 0x1d); + RemoveFromCurrentWorld(m_script, 0x1e); + RemoveFromCurrentWorld(m_script, 0x1f); AnimationManager()->FUN_1005f6d0(TRUE); ControlManager()->Unregister(this); } diff --git a/LEGO1/lego/legoomni/src/common/legoutils.cpp b/LEGO1/lego/legoomni/src/common/legoutils.cpp index 5aa9d663..b87e5d60 100644 --- a/LEGO1/lego/legoomni/src/common/legoutils.cpp +++ b/LEGO1/lego/legoomni/src/common/legoutils.cpp @@ -95,7 +95,7 @@ void InvokeAction(Extra::ActionType p_actionId, MxAtomId& p_pAtom, MxS32 p_targe break; case Extra::ActionType::e_stop: action.SetUnknown24(-2); - if (!FUN_1003ee00(p_pAtom, p_targetEntityId)) { + if (!RemoveFromCurrentWorld(p_pAtom, p_targetEntityId)) { DeleteObject(action); } break; @@ -238,10 +238,33 @@ void ConvertHSVToRGB(float p_h, float p_s, float p_v, float* p_rOut, float* p_bO } } -// STUB: LEGO1 0x1003ee00 -MxBool FUN_1003ee00(MxAtomId& p_atomId, MxS32 p_id) +// FUNCTION: LEGO1 0x1003ee00 +MxBool RemoveFromCurrentWorld(MxAtomId& p_atomId, MxS32 p_id) { - return TRUE; + LegoWorld* world = CurrentWorld(); + + if (world) { + MxCore* object = world->Find(p_atomId, p_id); + + if (object) { + world->Remove(object); + + if (!object->IsA("MxPresenter")) { + delete object; + } + else { + if (((MxPresenter*) object)->GetAction()) { + FUN_100b7220(((MxPresenter*) object)->GetAction(), MxDSAction::c_world, FALSE); + } + + ((MxPresenter*) object)->EndAction(); + } + + return TRUE; + } + } + + return FALSE; } // FUNCTION: LEGO1 0x1003ee80