From a3868e3808dbe3e74636578ef6d207bf953f49cd Mon Sep 17 00:00:00 2001 From: Christian Semmler Date: Fri, 26 Jan 2024 12:03:29 -0500 Subject: [PATCH] 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;