From 5df947dbb9bdb0989a483a45f7bc029073701139 Mon Sep 17 00:00:00 2001 From: Christian Semmler Date: Sat, 11 May 2024 09:32:11 -0400 Subject: [PATCH] Implement/match LegoPathController::FUN_10045c20 and LegoPathController ctor (#903) * Implement/match LegoPathController::FUN_10045c20 and LegoPathController ctor * Remove obsolete struct --- LEGO1/lego/legoomni/include/islepathactor.h | 8 ++-- LEGO1/lego/legoomni/include/legopathactor.h | 2 +- .../legoomni/include/legopathcontroller.h | 38 +++++++++++++------ .../legoomni/src/actors/islepathactor.cpp | 2 +- .../src/common/legoanimationmanager.cpp | 12 +++--- .../lego/legoomni/src/paths/legopathactor.cpp | 1 + .../legoomni/src/paths/legopathcontroller.cpp | 37 +++++++++++++++--- LEGO1/lego/sources/geom/legounkown100db7f4.h | 1 + LEGO1/lego/sources/geom/legoweedge.h | 1 + 9 files changed, 73 insertions(+), 29 deletions(-) diff --git a/LEGO1/lego/legoomni/include/islepathactor.h b/LEGO1/lego/legoomni/include/islepathactor.h index e834eff1..569221f1 100644 --- a/LEGO1/lego/legoomni/include/islepathactor.h +++ b/LEGO1/lego/legoomni/include/islepathactor.h @@ -33,7 +33,7 @@ class IslePathActor : public LegoPathActor { LegoGameState::Area p_area, MxAtomId* p_script, MxS32 p_entityId, - const char* p_path, + const char* p_name, MxS16 p_src, float p_srcScale, MxS16 p_dest, @@ -45,7 +45,7 @@ class IslePathActor : public LegoPathActor { m_area = p_area; m_script = p_script; m_entityId = p_entityId; - strcpy(m_path, p_path); + strcpy(m_name, p_name); m_src = p_src; m_srcScale = p_srcScale; m_dest = p_dest; @@ -60,7 +60,7 @@ class IslePathActor : public LegoPathActor { m_area = p_location.m_area; m_script = p_location.m_script; m_entityId = p_location.m_entityId; - strcpy(m_path, p_location.m_path); + strcpy(m_name, p_location.m_name); m_src = p_location.m_src; m_srcScale = p_location.m_srcScale; m_dest = p_location.m_dest; @@ -73,7 +73,7 @@ class IslePathActor : public LegoPathActor { LegoGameState::Area m_area; // 0x00 MxAtomId* m_script; // 0x04 MxS32 m_entityId; // 0x08 - char m_path[20]; // 0x0c + char m_name[20]; // 0x0c MxS16 m_src; // 0x20 float m_srcScale; // 0x24 MxS16 m_dest; // 0x28 diff --git a/LEGO1/lego/legoomni/include/legopathactor.h b/LEGO1/lego/legoomni/include/legopathactor.h index 86b67ac2..06eb4103 100644 --- a/LEGO1/lego/legoomni/include/legopathactor.h +++ b/LEGO1/lego/legoomni/include/legopathactor.h @@ -119,7 +119,7 @@ class LegoPathActor : public LegoActor { inline void SetBoundary(LegoPathBoundary* p_boundary) { m_boundary = p_boundary; } inline void SetState(MxU32 p_state) { m_state = p_state; } - inline void ClearController() { m_controller = NULL; } + inline void SetController(LegoPathController* p_controller) { m_controller = p_controller; } // SYNTHETIC: LEGO1 0x1002d800 // LegoPathActor::`scalar deleting destructor' diff --git a/LEGO1/lego/legoomni/include/legopathcontroller.h b/LEGO1/lego/legoomni/include/legopathcontroller.h index fb4efe77..069912d2 100644 --- a/LEGO1/lego/legoomni/include/legopathcontroller.h +++ b/LEGO1/lego/legoomni/include/legopathcontroller.h @@ -2,12 +2,12 @@ #define LEGOPATHCONTROLLER_H #include "decomp.h" +#include "legopathactor.h" +#include "legopathboundary.h" #include "mxcore.h" #include "mxstl/stlcompat.h" class LegoAnimPresenter; -class LegoPathActor; -class LegoPathBoundary; class LegoWorld; class MxAtomId; class Vector3; @@ -61,16 +61,30 @@ class LegoPathController : public MxCore { void FUN_10046bb0(LegoWorld* p_world); private: - LegoPathBoundary* m_unk0x08; // 0x08 - undefined4 m_unk0x0c; // 0x0c - undefined4 m_unk0x10; // 0x10 - undefined4 m_unk0x14; // 0x14 - MxU16 m_numL; // 0x18 - MxU16 m_numE; // 0x1a - MxU16 m_numN; // 0x1c - MxU16 m_numT; // 0x1e - map m_pfsE; // 0x20 - map m_unk0x30; // 0x30 + LegoPathBoundary* m_unk0x08; // 0x08 + undefined4 m_unk0x0c; // 0x0c + undefined4 m_unk0x10; // 0x10 + undefined4 m_unk0x14; // 0x14 + MxU16 m_numL; // 0x18 + MxU16 m_numE; // 0x1a + MxU16 m_numN; // 0x1c + MxU16 m_numT; // 0x1e + set m_pfsE; // 0x20 + LegoPathActorSet m_actors; // 0x30 }; +// clang-format off +// TEMPLATE: LEGO1 0x100451a0 +// _Tree >::_Kfn,LegoPathControllerComparator,allocator >::~_Tree::~Set + +// TEMPLATE: LEGO1 0x10045830 +// set >::~set > + +// GLOBAL: LEGO1 0x100f4360 +// _Tree >::_Kfn,LegoPathControllerComparator,allocator >::_Nil +// clang-format on + #endif // LEGOPATHCONTROLLER_H diff --git a/LEGO1/lego/legoomni/src/actors/islepathactor.cpp b/LEGO1/lego/legoomni/src/actors/islepathactor.cpp index 91a3c105..61b203e9 100644 --- a/LEGO1/lego/legoomni/src/actors/islepathactor.cpp +++ b/LEGO1/lego/legoomni/src/actors/islepathactor.cpp @@ -484,7 +484,7 @@ void IslePathActor::SpawnPlayer(LegoGameState::Area p_area, MxBool p_und, MxU8 p m_world->PlaceActor( this, - g_spawnLocations[i].m_path, + g_spawnLocations[i].m_name, g_spawnLocations[i].m_src, g_spawnLocations[i].m_srcScale, g_spawnLocations[i].m_dest, diff --git a/LEGO1/lego/legoomni/src/common/legoanimationmanager.cpp b/LEGO1/lego/legoomni/src/common/legoanimationmanager.cpp index 515e8aec..3f4947a2 100644 --- a/LEGO1/lego/legoomni/src/common/legoanimationmanager.cpp +++ b/LEGO1/lego/legoomni/src/common/legoanimationmanager.cpp @@ -152,7 +152,7 @@ LegoAnimationManager::~LegoAnimationManager() if (actor != NULL && actor->GetController() != NULL && CurrentWorld() != NULL) { CurrentWorld()->FUN_1001fc80((IslePathActor*) actor); - actor->ClearController(); + actor->SetController(NULL); } CharacterManager()->FUN_10083db0(roi); @@ -238,7 +238,7 @@ void LegoAnimationManager::Suspend() if (actor != NULL && actor->GetController() != NULL) { actor->GetController()->FUN_10046770(actor); - actor->ClearController(); + actor->SetController(NULL); } CharacterManager()->FUN_10083db0(roi); @@ -863,7 +863,7 @@ MxResult LegoAnimationManager::StartEntityAction(MxDSAction& p_dsAction, LegoEnt if (controller) { controller->FUN_10046770(actor); - actor->ClearController(); + actor->SetController(NULL); for (MxS32 i = 0; i < (MxS32) _countof(m_extras); i++) { if (m_extras[i].m_roi == roi) { @@ -1192,7 +1192,7 @@ MxResult LegoAnimationManager::Tickle() if (actor != NULL && actor->GetController() != NULL) { actor->GetController()->FUN_10046770(actor); - actor->ClearController(); + actor->SetController(NULL); } CharacterManager()->FUN_10083db0(roi); @@ -1452,7 +1452,7 @@ void LegoAnimationManager::FUN_10062580(AnimInfo& p_info) if (controller) { controller->FUN_10046770(actor); - actor->ClearController(); + actor->SetController(NULL); for (MxS32 i = 0; i < (MxS32) _countof(m_extras); i++) { if (m_extras[i].m_roi == actor->GetROI()) { @@ -1561,7 +1561,7 @@ void LegoAnimationManager::PurgeExtra(MxBool p_und) LegoPathActor* actor = CharacterManager()->GetActor(roi->GetName()); if (actor != NULL && actor->GetController() != NULL) { actor->GetController()->FUN_10046770(actor); - actor->ClearController(); + actor->SetController(NULL); } CharacterManager()->FUN_10083db0(roi); diff --git a/LEGO1/lego/legoomni/src/paths/legopathactor.cpp b/LEGO1/lego/legoomni/src/paths/legopathactor.cpp index 400f165d..6d393746 100644 --- a/LEGO1/lego/legoomni/src/paths/legopathactor.cpp +++ b/LEGO1/lego/legoomni/src/paths/legopathactor.cpp @@ -80,6 +80,7 @@ MxResult LegoPathActor::VTable0x80(Vector3& p_point1, Vector3& p_point2, Vector3 } // FUNCTION: LEGO1 0x1002d9c0 +// FUNCTION: BETA10 0x100ae9da MxResult LegoPathActor::VTable0x88( LegoPathBoundary* p_boundary, float p_time, diff --git a/LEGO1/lego/legoomni/src/paths/legopathcontroller.cpp b/LEGO1/lego/legoomni/src/paths/legopathcontroller.cpp index 66e7dc26..c3d89b98 100644 --- a/LEGO1/lego/legoomni/src/paths/legopathcontroller.cpp +++ b/LEGO1/lego/legoomni/src/paths/legopathcontroller.cpp @@ -1,13 +1,22 @@ #include "legopathcontroller.h" -#include "legopathboundary.h" +#include "mxmisc.h" +#include "mxtimer.h" DECOMP_SIZE_ASSERT(LegoPathController, 0x40) -// STUB: LEGO1 0x10044f40 +// FUNCTION: LEGO1 0x10044f40 +// FUNCTION: BETA10 0x100b6860 LegoPathController::LegoPathController() { - // TODO + m_unk0x08 = NULL; + m_unk0x0c = 0; + m_unk0x10 = 0; + m_unk0x14 = 0; + m_numL = 0; + m_numE = 0; + m_numN = 0; + m_numT = 0; } // STUB: LEGO1 0x10045880 @@ -29,7 +38,7 @@ MxResult LegoPathController::Tickle() return SUCCESS; } -// STUB: LEGO1 0x10045c20 +// FUNCTION: LEGO1 0x10045c20 // FUNCTION: BETA10 0x100b6d80 MxResult LegoPathController::FUN_10045c20( LegoPathActor* p_actor, @@ -40,10 +49,28 @@ MxResult LegoPathController::FUN_10045c20( float p_destScale ) { + if (p_actor->GetController() != NULL) { + p_actor->GetController()->FUN_10046770(p_actor); + p_actor->SetController(NULL); + } + + LegoPathBoundary* pBoundary = GetPathBoundary(p_name); + LegoEdge* pSrcE = pBoundary->GetEdges()[p_src]; + LegoEdge* pDestE = pBoundary->GetEdges()[p_dest]; + float time = Timer()->GetTime(); + + if (p_actor->VTable0x88(pBoundary, time, *pSrcE, p_srcScale, (LegoUnknown100db7f4&) *pDestE, p_destScale) != + SUCCESS) { + return FAILURE; + } + + p_actor->SetController(this); + m_actors.insert(p_actor); return SUCCESS; } // STUB: LEGO1 0x10046770 +// FUNCTION: BETA10 0x100b7264 undefined4 LegoPathController::FUN_10046770(LegoPathActor* p_actor) { return 0; @@ -72,7 +99,7 @@ MxResult LegoPathController::FUN_10046b30(LegoPathBoundary** p_path, MxS32& p_va LegoPathBoundary* LegoPathController::GetPathBoundary(const char* p_name) { for (MxS32 i = 0; i < m_numL; i++) { - if (strcmpi(m_unk0x08[i].GetName(), p_name) == 0) { + if (!strcmpi(m_unk0x08[i].GetName(), p_name)) { return &m_unk0x08[i]; } } diff --git a/LEGO1/lego/sources/geom/legounkown100db7f4.h b/LEGO1/lego/sources/geom/legounkown100db7f4.h index d1cfa324..8cf8934f 100644 --- a/LEGO1/lego/sources/geom/legounkown100db7f4.h +++ b/LEGO1/lego/sources/geom/legounkown100db7f4.h @@ -10,6 +10,7 @@ class LegoUnknown100db7f4 : public LegoEdge { public: // FUNCTION: LEGO1 0x1002ddc0 + // FUNCTION: BETA10 0x100372a0 LegoResult FUN_1002ddc0(LegoWEEdge& p_f, Vector3& p_point) { if (p_f.IsEqual(*m_faceA)) { diff --git a/LEGO1/lego/sources/geom/legoweedge.h b/LEGO1/lego/sources/geom/legoweedge.h index f02b0cac..c743479d 100644 --- a/LEGO1/lego/sources/geom/legoweedge.h +++ b/LEGO1/lego/sources/geom/legoweedge.h @@ -15,6 +15,7 @@ class LegoWEEdge { virtual LegoResult VTable0x04(); // vtable+0x04 inline LegoU8 GetNumEdges() { return m_numEdges; } + inline LegoEdge** GetEdges() { return m_edges; } inline LegoU32 IsEqual(LegoWEEdge& p_other) { return this == &p_other; } // SYNTHETIC: LEGO1 0x1009a570