From a3868e3808dbe3e74636578ef6d207bf953f49cd Mon Sep 17 00:00:00 2001 From: Christian Semmler Date: Fri, 26 Jan 2024 12:03:29 -0500 Subject: [PATCH 1/3] Implement/match LegoWorld::FUN_10021790 (#486) * Implement/match LegoWorld::FUN_10021790 * Improve match * Match * Specify python package versions * Use wildcard version * Use const atom * Use const atom --- .github/workflows/format.yml | 2 +- LEGO1/lego/legoomni/include/legoentitylist.h | 5 ++- LEGO1/lego/legoomni/include/legoworld.h | 2 +- LEGO1/lego/legoomni/src/entity/legoworld.cpp | 43 ++++++++++++++++++- .../legoomni/src/infocenter/infocenter.cpp | 30 ++++++------- 5 files changed, 62 insertions(+), 20 deletions(-) diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml index 6e4e724e..10e85e0d 100644 --- a/.github/workflows/format.yml +++ b/.github/workflows/format.yml @@ -29,7 +29,7 @@ jobs: - name: Install python libraries shell: bash run: | - pip install black pylint pytest -r tools/requirements.txt + pip install black==23.* pylint==3.* pytest==7.* -r tools/requirements.txt - name: Run pylint and black shell: bash diff --git a/LEGO1/lego/legoomni/include/legoentitylist.h b/LEGO1/lego/legoomni/include/legoentitylist.h index 1d29e65d..04935769 100644 --- a/LEGO1/lego/legoomni/include/legoentitylist.h +++ b/LEGO1/lego/legoomni/include/legoentitylist.h @@ -86,7 +86,10 @@ class LegoEntityListCursor : public MxPtrListCursor { // FUNCTION: LEGO1 0x1001f2b0 // MxListCursor::~MxListCursor -// FUNCTION: LEGO1 0x1001edc6 +// FUNCTION: LEGO1 0x1001f300 // LegoEntityListCursor::~LegoEntityListCursor +// TEMPLATE: LEGO1 0x100207d0 +// MxListCursor::MxListCursor + #endif // LEGOENTITYLIST_H diff --git a/LEGO1/lego/legoomni/include/legoworld.h b/LEGO1/lego/legoomni/include/legoworld.h index 115aeef4..72fc69b6 100644 --- a/LEGO1/lego/legoomni/include/legoworld.h +++ b/LEGO1/lego/legoomni/include/legoworld.h @@ -66,7 +66,7 @@ class LegoWorld : public LegoEntity { void FUN_10073430(); MxS32 GetCurrPathInfo(LegoPathBoundary** p_path, MxS32& p_value); MxPresenter* FindPresenter(const char* p_presenter, const char* p_name); - MxPresenter* FUN_10021790(MxAtomId& p_atom, MxS32 p_entityId); + MxCore* FUN_10021790(const MxAtomId& p_atom, MxS32 p_entityId); // SYNTHETIC: LEGO1 0x1001dee0 // LegoWorld::`scalar deleting destructor' diff --git a/LEGO1/lego/legoomni/src/entity/legoworld.cpp b/LEGO1/lego/legoomni/src/entity/legoworld.cpp index 60cb941d..6cc2363a 100644 --- a/LEGO1/lego/legoomni/src/entity/legoworld.cpp +++ b/LEGO1/lego/legoomni/src/entity/legoworld.cpp @@ -168,9 +168,48 @@ MxPresenter* LegoWorld::FindPresenter(const char* p_presenter, const char* p_nam return NULL; } -// STUB: LEGO1 0x10021790 -MxPresenter* LegoWorld::FUN_10021790(MxAtomId& p_atom, MxS32 p_entityId) +// FUNCTION: LEGO1 0x10021790 +MxCore* LegoWorld::FUN_10021790(const MxAtomId& p_atom, MxS32 p_entityId) { + LegoEntityListCursor entityCursor(m_entityList); + LegoEntity* entity; + + while (entityCursor.Next(entity)) { + if (entity->GetAtom() == p_atom && entity->GetEntityId() == p_entityId) + return entity; + } + + MxPresenterListCursor presenterCursor0xb8(&m_list0xb8); + MxPresenter* presenter; + + while (presenterCursor0xb8.Next(presenter)) { + MxDSAction* action = presenter->GetAction(); + + if (action->GetAtomId() == p_atom && action->GetObjectId() == p_entityId) + return presenter; + } + + MxPresenterListCursor presenterCursor0x80(&m_list0x80); + + while (presenterCursor0x80.Next(presenter)) { + MxDSAction* action = presenter->GetAction(); + + if (action && action->GetAtomId() == p_atom && action->GetObjectId() == p_entityId) + return presenter; + } + + for (MxPresenterSet::iterator it = m_set0xa8.begin(); it != m_set0xa8.end(); it++) { + MxCore* core = *it; + + if (core->IsA("MxPresenter")) { + MxPresenter* presenter = (MxPresenter*) *it; + MxDSAction* action = presenter->GetAction(); + + if (action->GetAtomId() == p_atom && action->GetObjectId() == p_entityId) + return *it; + } + } + return NULL; } diff --git a/LEGO1/lego/legoomni/src/infocenter/infocenter.cpp b/LEGO1/lego/legoomni/src/infocenter/infocenter.cpp index 5d3722c1..6b14b8af 100644 --- a/LEGO1/lego/legoomni/src/infocenter/infocenter.cpp +++ b/LEGO1/lego/legoomni/src/infocenter/infocenter.cpp @@ -365,22 +365,22 @@ void Infocenter::InitializeBitmaps() { m_radio.Initialize(TRUE); - FUN_10021790(m_atom, c_leftArrowCtl)->Enable(TRUE); - FUN_10021790(m_atom, c_rightArrowCtl)->Enable(TRUE); - FUN_10021790(m_atom, c_infoCtl)->Enable(TRUE); - FUN_10021790(m_atom, c_boatCtl)->Enable(TRUE); - FUN_10021790(m_atom, c_raceCtl)->Enable(TRUE); - FUN_10021790(m_atom, c_pizzaCtl)->Enable(TRUE); - FUN_10021790(m_atom, c_gasCtl)->Enable(TRUE); - FUN_10021790(m_atom, c_medCtl)->Enable(TRUE); - FUN_10021790(m_atom, c_copCtl)->Enable(TRUE); + ((MxPresenter*) FUN_10021790(m_atom, c_leftArrowCtl))->Enable(TRUE); + ((MxPresenter*) FUN_10021790(m_atom, c_rightArrowCtl))->Enable(TRUE); + ((MxPresenter*) FUN_10021790(m_atom, c_infoCtl))->Enable(TRUE); + ((MxPresenter*) FUN_10021790(m_atom, c_boatCtl))->Enable(TRUE); + ((MxPresenter*) FUN_10021790(m_atom, c_raceCtl))->Enable(TRUE); + ((MxPresenter*) FUN_10021790(m_atom, c_pizzaCtl))->Enable(TRUE); + ((MxPresenter*) FUN_10021790(m_atom, c_gasCtl))->Enable(TRUE); + ((MxPresenter*) FUN_10021790(m_atom, c_medCtl))->Enable(TRUE); + ((MxPresenter*) FUN_10021790(m_atom, c_copCtl))->Enable(TRUE); - FUN_10021790(m_atom, c_mamaCtl)->Enable(TRUE); - FUN_10021790(m_atom, c_papaCtl)->Enable(TRUE); - FUN_10021790(m_atom, c_pepperCtl)->Enable(TRUE); - FUN_10021790(m_atom, c_nickCtl)->Enable(TRUE); - FUN_10021790(m_atom, c_lauraCtl)->Enable(TRUE); - FUN_10021790(m_atom, c_radioCtl)->Enable(TRUE); + ((MxPresenter*) FUN_10021790(m_atom, c_mamaCtl))->Enable(TRUE); + ((MxPresenter*) FUN_10021790(m_atom, c_papaCtl))->Enable(TRUE); + ((MxPresenter*) FUN_10021790(m_atom, c_pepperCtl))->Enable(TRUE); + ((MxPresenter*) FUN_10021790(m_atom, c_nickCtl))->Enable(TRUE); + ((MxPresenter*) FUN_10021790(m_atom, c_lauraCtl))->Enable(TRUE); + ((MxPresenter*) FUN_10021790(m_atom, c_radioCtl))->Enable(TRUE); m_mapAreas[0].m_presenter = (MxStillPresenter*) FindPresenter("MxStillPresenter", "Info_A_Bitmap"); m_mapAreas[0].m_unk0x08 = 391; From 88fd1e658d3d680e57468e482d66bf8c221cbfad Mon Sep 17 00:00:00 2001 From: Joshua Peisach Date: Fri, 26 Jan 2024 12:09:59 -0500 Subject: [PATCH 2/3] HelicopterState vtable (#487) * HelicopterState vtable * Move functions --------- Co-authored-by: Christian Semmler --- LEGO1/lego/legoomni/include/helicopterstate.h | 11 +++++++++-- LEGO1/lego/legoomni/src/build/helicopterstate.cpp | 14 -------------- 2 files changed, 9 insertions(+), 16 deletions(-) diff --git a/LEGO1/lego/legoomni/include/helicopterstate.h b/LEGO1/lego/legoomni/include/helicopterstate.h index eb104c93..52a92192 100644 --- a/LEGO1/lego/legoomni/include/helicopterstate.h +++ b/LEGO1/lego/legoomni/include/helicopterstate.h @@ -21,8 +21,15 @@ class HelicopterState : public LegoState { return !strcmp(p_name, HelicopterState::ClassName()) || LegoState::IsA(p_name); } - virtual MxBool VTable0x14() override; // vtable+0x14 - virtual MxBool SetFlag() override; // vtable+0x18 + // FUNCTION: LEGO1 0x1000e0b0 + virtual MxBool VTable0x14() override { return FALSE; }; // vtable+0x14 + + // FUNCTION: LEGO1 0x1000e0c0 + virtual MxBool SetFlag() override + { + m_unk0x8 = 0; + return TRUE; + }; // vtable+0x18 inline void SetUnknown8(MxU32 p_unk0x8) { m_unk0x8 = p_unk0x8; } inline MxU32 GetUnkown8() { return m_unk0x8; } diff --git a/LEGO1/lego/legoomni/src/build/helicopterstate.cpp b/LEGO1/lego/legoomni/src/build/helicopterstate.cpp index 368edfad..70d71a0c 100644 --- a/LEGO1/lego/legoomni/src/build/helicopterstate.cpp +++ b/LEGO1/lego/legoomni/src/build/helicopterstate.cpp @@ -1,15 +1 @@ #include "helicopterstate.h" - -// STUB: LEGO1 0x1000e0b0 -MxBool HelicopterState::VTable0x14() -{ - // TODO - return FALSE; -} - -// STUB: LEGO1 0x1000e0c0 -MxBool HelicopterState::SetFlag() -{ - // TODO - return FALSE; -} From 0a672d21468086cc72f0057195bfce263280f6a8 Mon Sep 17 00:00:00 2001 From: Joshua Peisach Date: Fri, 26 Jan 2024 12:13:09 -0500 Subject: [PATCH 3/3] RaceCar destructor (#488) * RaceCar destructor * Fixes --------- Co-authored-by: Christian Semmler --- LEGO1/lego/legoomni/src/build/racecar.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/LEGO1/lego/legoomni/src/build/racecar.cpp b/LEGO1/lego/legoomni/src/build/racecar.cpp index 02f3a09d..a057b8a4 100644 --- a/LEGO1/lego/legoomni/src/build/racecar.cpp +++ b/LEGO1/lego/legoomni/src/build/racecar.cpp @@ -1,17 +1,21 @@ #include "racecar.h" +#include "legocontrolmanager.h" +#include "legoomni.h" + DECOMP_SIZE_ASSERT(RaceCar, 0x164); // FUNCTION: LEGO1 0x10028200 RaceCar::RaceCar() { - this->m_unk0x13c = 40.0; + m_unk0x13c = 40.0; } -// STUB: LEGO1 0x10028420 +// FUNCTION: LEGO1 0x10028420 RaceCar::~RaceCar() { - // TODO + ControlManager()->Unregister(this); + VTable0xe4(); } // STUB: LEGO1 0x10028490