From b68f8a5c6d455935209d2fba8c1df2c2c5dbf6f3 Mon Sep 17 00:00:00 2001 From: Christian Semmler Date: Fri, 26 Jan 2024 12:03:18 -0500 Subject: [PATCH] Implement LegoWorld::FUN_100213a0 --- .../lego/legoomni/include/legoanimpresenter.h | 2 +- LEGO1/lego/legoomni/include/legoworld.h | 2 +- LEGO1/lego/legoomni/src/entity/legoworld.cpp | 57 ++++++++++++++++++- .../legoomni/src/infocenter/infocenter.cpp | 20 +++---- .../legoomni/src/video/legoanimpresenter.cpp | 6 ++ LEGO1/lego/sources/roi/legoroi.h | 9 ++- LEGO1/omni/include/mxdsobject.h | 1 + 7 files changed, 79 insertions(+), 18 deletions(-) diff --git a/LEGO1/lego/legoomni/include/legoanimpresenter.h b/LEGO1/lego/legoomni/include/legoanimpresenter.h index 94832a61..394147e5 100644 --- a/LEGO1/lego/legoomni/include/legoanimpresenter.h +++ b/LEGO1/lego/legoomni/include/legoanimpresenter.h @@ -40,7 +40,7 @@ class LegoAnimPresenter : public MxVideoPresenter { virtual void PutFrame() override; // vtable+0x6c virtual MxResult VTable0x88(MxStreamChunk* p_chunk); // vtable+0x88 - // 6 more virtual functions here + const char* GetActionObjectName(); protected: void Init(); diff --git a/LEGO1/lego/legoomni/include/legoworld.h b/LEGO1/lego/legoomni/include/legoworld.h index 115aeef4..90aedfd6 100644 --- a/LEGO1/lego/legoomni/include/legoworld.h +++ b/LEGO1/lego/legoomni/include/legoworld.h @@ -65,7 +65,7 @@ class LegoWorld : public LegoEntity { void FUN_10073400(); void FUN_10073430(); MxS32 GetCurrPathInfo(LegoPathBoundary** p_path, MxS32& p_value); - MxPresenter* FindPresenter(const char* p_presenter, const char* p_name); + MxCore* FUN_100213a0(const char* p_class, const char* p_name); MxPresenter* FUN_10021790(MxAtomId& p_atom, MxS32 p_entityId); // SYNTHETIC: LEGO1 0x1001dee0 diff --git a/LEGO1/lego/legoomni/src/entity/legoworld.cpp b/LEGO1/lego/legoomni/src/entity/legoworld.cpp index 60cb941d..0f7cf937 100644 --- a/LEGO1/lego/legoomni/src/entity/legoworld.cpp +++ b/LEGO1/lego/legoomni/src/entity/legoworld.cpp @@ -1,5 +1,6 @@ #include "legoworld.h" +#include "legoanimpresenter.h" #include "legocontrolmanager.h" #include "legoinputmanager.h" #include "legoomni.h" @@ -162,10 +163,60 @@ void LegoWorld::EndAction(MxCore* p_object) { } -// STUB: LEGO1 0x100213a0 -MxPresenter* LegoWorld::FindPresenter(const char* p_presenter, const char* p_name) +// FUNCTION: LEGO1 0x100213a0 +MxCore* LegoWorld::FUN_100213a0(const char* p_class, const char* p_name) { - return NULL; + if (!strcmp(p_class, "MxControlPresenter")) { + MxPresenterListCursor cursor(&m_list0xb8); + MxPresenter* presenter; + + while (cursor.Next(presenter)) { + MxDSAction* action = presenter->GetAction(); + if (!strcmp(action->GetObjectName(), p_name)) + return presenter; + } + + return NULL; + } + else if (!strcmp(p_class, "MxEntity")) { + LegoEntityListCursor cursor(m_entityList); + LegoEntity* entity; + + while (cursor.Next(entity)) { + if (!p_name) + return entity; + + LegoROI* roi = entity->GetROI(); + if (roi && !strcmpi(roi->GetUnknown0xe4(), p_name)) + return entity; + } + + return NULL; + } + else if (!strcmp(p_class, "LegoAnimPresenter")) { + MxPresenterListCursor cursor(&m_list0x80); + MxPresenter* presenter; + + while (cursor.Next(presenter)) { + if (!strcmpi(((LegoAnimPresenter*) presenter)->GetActionObjectName(), p_name)) + return presenter; + } + + return NULL; + } + else { + for (MxPresenterSet::iterator it = m_set0xa8.begin(); it != m_set0xa8.end(); it++) { + if ((*it)->IsA(p_class) && (*it)->IsA("MxPresenter")) { + MxPresenter* presenter = (MxPresenter*) *it; + MxDSAction* action = presenter->GetAction(); + + if (!strcmp(action->GetObjectName(), p_name)) + return *it; + } + } + + return NULL; + } } // STUB: LEGO1 0x10021790 diff --git a/LEGO1/lego/legoomni/src/infocenter/infocenter.cpp b/LEGO1/lego/legoomni/src/infocenter/infocenter.cpp index 5d3722c1..2df59474 100644 --- a/LEGO1/lego/legoomni/src/infocenter/infocenter.cpp +++ b/LEGO1/lego/legoomni/src/infocenter/infocenter.cpp @@ -305,8 +305,8 @@ void Infocenter::VTable0x50() m_unk0x1d4 = 0; m_unk0x1d6 = 0; - MxStillPresenter* bg = (MxStillPresenter*) FindPresenter("MxStillPresenter", "Background_Bitmap"); - MxStillPresenter* bgRed = (MxStillPresenter*) FindPresenter("MxStillPresenter", "BackgroundRed_Bitmap"); + MxStillPresenter* bg = (MxStillPresenter*) FUN_100213a0("MxStillPresenter", "Background_Bitmap"); + MxStillPresenter* bgRed = (MxStillPresenter*) FUN_100213a0("MxStillPresenter", "BackgroundRed_Bitmap"); switch (GameState()->GetUnknown10()) { case 0: @@ -382,56 +382,56 @@ void Infocenter::InitializeBitmaps() FUN_10021790(m_atom, c_lauraCtl)->Enable(TRUE); FUN_10021790(m_atom, c_radioCtl)->Enable(TRUE); - m_mapAreas[0].m_presenter = (MxStillPresenter*) FindPresenter("MxStillPresenter", "Info_A_Bitmap"); + m_mapAreas[0].m_presenter = (MxStillPresenter*) FUN_100213a0("MxStillPresenter", "Info_A_Bitmap"); m_mapAreas[0].m_unk0x08 = 391; m_mapAreas[0].m_unk0x0c = 182; m_mapAreas[0].m_unk0x10 = 427; m_mapAreas[0].m_unk0x14 = 230; m_mapAreas[0].m_unk0x04 = 3; - m_mapAreas[1].m_presenter = (MxStillPresenter*) FindPresenter("MxStillPresenter", "Boat_A_Bitmap"); + m_mapAreas[1].m_presenter = (MxStillPresenter*) FUN_100213a0("MxStillPresenter", "Boat_A_Bitmap"); m_mapAreas[1].m_unk0x08 = 304; m_mapAreas[1].m_unk0x0c = 225; m_mapAreas[1].m_unk0x10 = 350; m_mapAreas[1].m_unk0x14 = 268; m_mapAreas[1].m_unk0x04 = 10; - m_mapAreas[2].m_presenter = (MxStillPresenter*) FindPresenter("MxStillPresenter", "Race_A_Bitmap"); + m_mapAreas[2].m_presenter = (MxStillPresenter*) FUN_100213a0("MxStillPresenter", "Race_A_Bitmap"); m_mapAreas[2].m_unk0x08 = 301; m_mapAreas[2].m_unk0x0c = 133; m_mapAreas[2].m_unk0x10 = 347; m_mapAreas[2].m_unk0x14 = 181; m_mapAreas[2].m_unk0x04 = 11; - m_mapAreas[3].m_presenter = (MxStillPresenter*) FindPresenter("MxStillPresenter", "Pizza_A_Bitmap"); + m_mapAreas[3].m_presenter = (MxStillPresenter*) FUN_100213a0("MxStillPresenter", "Pizza_A_Bitmap"); m_mapAreas[3].m_unk0x08 = 289; m_mapAreas[3].m_unk0x0c = 182; m_mapAreas[3].m_unk0x10 = 335; m_mapAreas[3].m_unk0x14 = 225; m_mapAreas[3].m_unk0x04 = 12; - m_mapAreas[4].m_presenter = (MxStillPresenter*) FindPresenter("MxStillPresenter", "Gas_A_Bitmap"); + m_mapAreas[4].m_presenter = (MxStillPresenter*) FUN_100213a0("MxStillPresenter", "Gas_A_Bitmap"); m_mapAreas[4].m_unk0x10 = 391; m_mapAreas[4].m_unk0x08 = 350; m_mapAreas[4].m_unk0x0c = 161; m_mapAreas[4].m_unk0x14 = 209; m_mapAreas[4].m_unk0x04 = 13; - m_mapAreas[5].m_presenter = (MxStillPresenter*) FindPresenter("MxStillPresenter", "Med_A_Bitmap"); + m_mapAreas[5].m_presenter = (MxStillPresenter*) FUN_100213a0("MxStillPresenter", "Med_A_Bitmap"); m_mapAreas[5].m_unk0x08 = 392; m_mapAreas[5].m_unk0x0c = 130; m_mapAreas[5].m_unk0x10 = 438; m_mapAreas[5].m_unk0x14 = 176; m_mapAreas[5].m_unk0x04 = 14; - m_mapAreas[6].m_presenter = (MxStillPresenter*) FindPresenter("MxStillPresenter", "Cop_A_Bitmap"); + m_mapAreas[6].m_presenter = (MxStillPresenter*) FUN_100213a0("MxStillPresenter", "Cop_A_Bitmap"); m_mapAreas[6].m_unk0x08 = 396; m_mapAreas[6].m_unk0x0c = 229; m_mapAreas[6].m_unk0x10 = 442; m_mapAreas[6].m_unk0x14 = 272; m_mapAreas[6].m_unk0x04 = 15; - m_frameHotBitmap = (MxStillPresenter*) FindPresenter("MxStillPresenter", "FrameHot_Bitmap"); + m_frameHotBitmap = (MxStillPresenter*) FUN_100213a0("MxStillPresenter", "FrameHot_Bitmap"); FUN_10070dc0(TRUE); } diff --git a/LEGO1/lego/legoomni/src/video/legoanimpresenter.cpp b/LEGO1/lego/legoomni/src/video/legoanimpresenter.cpp index 0167833d..6da994ec 100644 --- a/LEGO1/lego/legoomni/src/video/legoanimpresenter.cpp +++ b/LEGO1/lego/legoomni/src/video/legoanimpresenter.cpp @@ -173,6 +173,12 @@ void LegoAnimPresenter::Destroy() Destroy(FALSE); } +// FUNCTION: LEGO1 0x1006b8f0 +const char* LegoAnimPresenter::GetActionObjectName() +{ + return m_action->GetObjectName(); +} + // STUB: LEGO1 0x1006bac0 void LegoAnimPresenter::ParseExtra() { diff --git a/LEGO1/lego/sources/roi/legoroi.h b/LEGO1/lego/sources/roi/legoroi.h index 2fb03c63..9b586353 100644 --- a/LEGO1/lego/sources/roi/legoroi.h +++ b/LEGO1/lego/sources/roi/legoroi.h @@ -40,6 +40,7 @@ class LegoROI : public ViewROI { void FUN_100a46b0(Matrix4& p_transform); void FUN_100a58f0(Matrix4& p_transform); + inline const char* GetUnknown0xe4() { return m_unk0xe4; } inline LegoEntity* GetUnknown0x104() { return m_unk0x104; } inline void SetUnknown0x104(LegoEntity* p_unk0x104) { m_unk0x104 = p_unk0x104; } @@ -47,9 +48,11 @@ class LegoROI : public ViewROI { // LegoROI::`scalar deleting destructor' private: - undefined m_pad[0x24]; // 0xe0 - LegoEntity* m_unk0x104; // 0x104 - int m_time; // 0x108 + undefined4 m_unk0xe0; // 0xe0 + const char* m_unk0xe4; // 0xe4 + undefined m_unk0xe8[0x1c]; // 0xe8 + LegoEntity* m_unk0x104; // 0x104 + int m_time; // 0x108 }; #endif // LEGOROI_H diff --git a/LEGO1/omni/include/mxdsobject.h b/LEGO1/omni/include/mxdsobject.h index 45a3b360..5fa1d4fb 100644 --- a/LEGO1/omni/include/mxdsobject.h +++ b/LEGO1/omni/include/mxdsobject.h @@ -51,6 +51,7 @@ class MxDSObject : public MxCore { inline Type GetType() const { return (Type) this->m_type; } inline const char* GetSourceName() const { return this->m_sourceName; } + inline const char* GetObjectName() const { return this->m_objectName; } inline MxU32 GetObjectId() { return this->m_objectId; } inline const MxAtomId& GetAtomId() { return this->m_atomId; } inline MxS16 GetUnknown24() { return this->m_unk0x24; }