From 2e5d54c03e7e3b9a128b4128a0f61f0ed6d581a2 Mon Sep 17 00:00:00 2001 From: Misha <106913236+MishaProductions@users.noreply.github.com> Date: Sun, 24 Mar 2024 17:30:04 -0400 Subject: [PATCH] Finish LegoPathPresenter (#721) * Finish LegoPathPresenter * Update legopathcontroller.cpp * Fixes * fix --------- Co-authored-by: Christian Semmler --- .../legoomni/include/legopathcontroller.h | 7 ++- .../lego/legoomni/include/legopathpresenter.h | 2 +- LEGO1/lego/legoomni/include/legoworld.h | 1 + .../legoomni/src/entity/legonavcontroller.cpp | 2 +- LEGO1/lego/legoomni/src/entity/legoworld.cpp | 7 +++ .../legoomni/src/paths/legopathcontroller.cpp | 8 ++- .../legoomni/src/paths/legopathpresenter.cpp | 49 +++++++++++++++++-- 7 files changed, 66 insertions(+), 10 deletions(-) diff --git a/LEGO1/lego/legoomni/include/legopathcontroller.h b/LEGO1/lego/legoomni/include/legopathcontroller.h index 303edd18..ba8674e1 100644 --- a/LEGO1/lego/legoomni/include/legopathcontroller.h +++ b/LEGO1/lego/legoomni/include/legopathcontroller.h @@ -4,7 +4,9 @@ #include "decomp.h" #include "legopathactor.h" #include "mxcore.h" + class LegoPathBoundary; +class LegoWorld; // VTABLE: LEGO1 0x100d7d60 // SIZE 0x40 @@ -31,12 +33,13 @@ class LegoPathController : public MxCore { // SYNTHETIC: LEGO1 0x10045740 // LegoPathController::`scalar deleting destructor' - virtual void VTable0x14(); // vtable+0x14 - virtual void Destroy(); // vtable+0x18 + virtual void VTable0x14(MxU8* p_data, Vector3& p_location, MxAtomId& p_trigger); // vtable+0x14 + virtual void Destroy(); // vtable+0x18 undefined4 FUN_10046770(LegoPathActor* p_actor); MxResult FUN_10046b30(LegoPathBoundary** p_path, MxS32& p_value); void Enable(MxBool p_enable); + void FUN_10046bb0(LegoWorld* p_world); private: undefined4 m_unk0x08; // 0x08 diff --git a/LEGO1/lego/legoomni/include/legopathpresenter.h b/LEGO1/lego/legoomni/include/legopathpresenter.h index e6c5da14..6477c2c0 100644 --- a/LEGO1/lego/legoomni/include/legopathpresenter.h +++ b/LEGO1/lego/legoomni/include/legopathpresenter.h @@ -39,7 +39,7 @@ class LegoPathPresenter : public MxMediaPresenter { protected: void Destroy(MxBool p_fromDestructor); - MxAtomId m_atomId; // 0x50 + MxAtomId m_trigger; // 0x50 }; #endif // LEGOPATHPRESENTER_H diff --git a/LEGO1/lego/legoomni/include/legoworld.h b/LEGO1/lego/legoomni/include/legoworld.h index 801b4e7a..25dc3300 100644 --- a/LEGO1/lego/legoomni/include/legoworld.h +++ b/LEGO1/lego/legoomni/include/legoworld.h @@ -68,6 +68,7 @@ class LegoWorld : public LegoEntity { void Remove(MxCore* p_object); undefined4 FUN_1001fa70(IslePathActor* p_actor); void FUN_1001fc80(IslePathActor* p_actor); + void AddPath(LegoPathController* p_controller); MxResult GetCurrPathInfo(LegoPathBoundary** p_path, MxS32& p_value); MxCore* Find(const char* p_class, const char* p_name); MxCore* Find(const MxAtomId& p_atom, MxS32 p_entityId); diff --git a/LEGO1/lego/legoomni/src/entity/legonavcontroller.cpp b/LEGO1/lego/legoomni/src/entity/legonavcontroller.cpp index 011e1a63..705db2f4 100644 --- a/LEGO1/lego/legoomni/src/entity/legonavcontroller.cpp +++ b/LEGO1/lego/legoomni/src/entity/legonavcontroller.cpp @@ -84,7 +84,7 @@ undefined4 g_unk0x100f66b4 = 0; undefined4 g_unk0x100f66bc = 2; // GLOBAL: LEGO1 0x100f66c0 -char* g_debugPassword = "OGEL"; +char g_debugPassword[] = "OGEL"; // GLOBAL: LEGO1 0x100f66c8 char* g_currentInput = g_debugPassword; diff --git a/LEGO1/lego/legoomni/src/entity/legoworld.cpp b/LEGO1/lego/legoomni/src/entity/legoworld.cpp index a0a89c0a..ab81ddca 100644 --- a/LEGO1/lego/legoomni/src/entity/legoworld.cpp +++ b/LEGO1/lego/legoomni/src/entity/legoworld.cpp @@ -287,6 +287,13 @@ void LegoWorld::FUN_1001fc80(IslePathActor* p_actor) } } +// FUNCTION: LEGO1 0x1001ff80 +void LegoWorld::AddPath(LegoPathController* p_controller) +{ + p_controller->FUN_10046bb0(this); + m_list0x68.Append(p_controller); +} + // FUNCTION: LEGO1 0x10020120 MxResult LegoWorld::GetCurrPathInfo(LegoPathBoundary** p_path, MxS32& p_value) { diff --git a/LEGO1/lego/legoomni/src/paths/legopathcontroller.cpp b/LEGO1/lego/legoomni/src/paths/legopathcontroller.cpp index 4fa44b03..e2e9056a 100644 --- a/LEGO1/lego/legoomni/src/paths/legopathcontroller.cpp +++ b/LEGO1/lego/legoomni/src/paths/legopathcontroller.cpp @@ -9,7 +9,7 @@ LegoPathController::LegoPathController() } // STUB: LEGO1 0x10045880 -void LegoPathController::VTable0x14() +void LegoPathController::VTable0x14(MxU8* p_data, Vector3& p_location, MxAtomId& p_trigger) { // TODO } @@ -39,6 +39,12 @@ MxResult LegoPathController::FUN_10046b30(LegoPathBoundary** p_path, MxS32& p_va return SUCCESS; } +// STUB: LEGO1 0x10046bb0 +void LegoPathController::FUN_10046bb0(LegoWorld* p_world) +{ + // TODO +} + // STUB: LEGO1 0x10046be0 void LegoPathController::Enable(MxBool p_enable) { diff --git a/LEGO1/lego/legoomni/src/paths/legopathpresenter.cpp b/LEGO1/lego/legoomni/src/paths/legopathpresenter.cpp index 1fb06970..9ff31ed4 100644 --- a/LEGO1/lego/legoomni/src/paths/legopathpresenter.cpp +++ b/LEGO1/lego/legoomni/src/paths/legopathpresenter.cpp @@ -3,9 +3,14 @@ #include "legovideomanager.h" #include "misc.h" #include "mxautolock.h" +#include "mxutilities.h" DECOMP_SIZE_ASSERT(LegoPathPresenter, 0x54) +// STRING: LEGO1 0x10101ef0 +// GLOBAL: LEGO1 0x101020c4 +const char* g_triggersSource = "TRIGGERS_SOURCE"; + // FUNCTION: LEGO1 0x100448d0 LegoPathPresenter::LegoPathPresenter() { @@ -59,11 +64,31 @@ void LegoPathPresenter::Destroy() Destroy(FALSE); } -// STUB: LEGO1 0x10044c20 +// FUNCTION: LEGO1 0x10044c20 void LegoPathPresenter::ReadyTickle() { - // TODO - ProgressTickleState(e_starting); // Allow initialization process to continue + LegoWorld* currentWorld = CurrentWorld(); + + if (currentWorld) { + MxStreamChunk* chunk = m_subscriber->PopData(); + + if (chunk) { + LegoPathController* controller = new LegoPathController(); + + if (controller == NULL) { + EndAction(); + } + else { + ParseExtra(); + + controller->VTable0x14(chunk->GetData(), m_action->GetLocation(), m_trigger); + currentWorld->AddPath(controller); + + m_subscriber->FreeDataChunk(chunk); + ProgressTickleState(MxPresenter::e_starting); + } + } + } } // FUNCTION: LEGO1 0x10044d00 @@ -90,8 +115,22 @@ void LegoPathPresenter::RepeatingTickle() EndAction(); } -// STUB: LEGO1 0x10044d60 +// FUNCTION: LEGO1 0x10044d60 void LegoPathPresenter::ParseExtra() { - // TODO + MxU16 extraLength; + char* extraData; + m_action->GetExtra(extraLength, extraData); + + if (extraLength & MAXWORD) { + char extraCopy[256], output[256]; + memcpy(extraCopy, extraData, extraLength & MAXWORD); + extraCopy[extraLength & MAXWORD] = '\0'; + + strupr(extraCopy); + + if (KeyValueStringParse(output, g_triggersSource, extraCopy) != FALSE) { + m_trigger = MxAtomId(output, e_lowerCase2); + } + } }