From 6774784b37ec185297191c0dd87251a53f3c7e4c Mon Sep 17 00:00:00 2001 From: Christian Semmler Date: Wed, 22 May 2024 14:09:06 -0400 Subject: [PATCH] Implement/match LegoPathActor::VTable0xa4 and VTable0xa8 (#945) * Implement/match LegoPathActor::VTable0xa4 * Implement/match LegoPathActor::VTable0xa8 * Name enum constants --- LEGO1/lego/legoomni/include/isle.h | 5 +-- .../legoomni/include/legoanimationmanager.h | 2 +- LEGO1/lego/legoomni/include/legopathactor.h | 4 +- .../src/common/legoanimationmanager.cpp | 2 +- .../lego/legoomni/src/paths/legopathactor.cpp | 45 ++++++++++++++++--- .../legoomni/src/paths/legopathboundary.cpp | 12 ++--- .../legoomni/src/paths/legopathcontroller.cpp | 13 +++--- .../legoomni/src/paths/legopathstruct.cpp | 6 +-- LEGO1/lego/legoomni/src/worlds/isle.cpp | 6 +-- LEGO1/lego/sources/geom/legowegedge.cpp | 6 +-- LEGO1/lego/sources/geom/legowegedge.h | 20 ++++----- 11 files changed, 79 insertions(+), 42 deletions(-) diff --git a/LEGO1/lego/legoomni/include/isle.h b/LEGO1/lego/legoomni/include/isle.h index 39ab1527..76971271 100644 --- a/LEGO1/lego/legoomni/include/isle.h +++ b/LEGO1/lego/legoomni/include/isle.h @@ -24,10 +24,9 @@ class Act1State; // SIZE 0x140 class Isle : public LegoWorld { public: - // For g_unk0x100f1198 enum { - c_bit6 = 0x20, - c_bit7 = 0x40 + c_playCamAnims = 0x20, + c_playMusic = 0x40 }; Isle(); diff --git a/LEGO1/lego/legoomni/include/legoanimationmanager.h b/LEGO1/lego/legoomni/include/legoanimationmanager.h index e4fe914f..52aeb7c6 100644 --- a/LEGO1/lego/legoomni/include/legoanimationmanager.h +++ b/LEGO1/lego/legoomni/include/legoanimationmanager.h @@ -102,7 +102,7 @@ class LegoAnimationManager : public MxCore { MxBool p_param8, MxBool p_param9 ); - void CameraTriggerFire(LegoPathActor* p_actor, undefined4, MxU32 p_location, MxBool p_bool); + void CameraTriggerFire(LegoPathActor* p_actor, MxBool, MxU32 p_location, MxBool p_bool); void FUN_10061010(MxBool p_und); LegoTranInfo* GetTranInfo(MxU32 p_index); void FUN_10062770(); diff --git a/LEGO1/lego/legoomni/include/legopathactor.h b/LEGO1/lego/legoomni/include/legopathactor.h index c43e5877..4acc28e7 100644 --- a/LEGO1/lego/legoomni/include/legopathactor.h +++ b/LEGO1/lego/legoomni/include/legopathactor.h @@ -96,8 +96,8 @@ class LegoPathActor : public LegoActor { // FUNCTION: LEGO1 0x10002d60 virtual MxS32 VTable0xa0() { return 0; } // vtable+0xa0 - virtual void VTable0xa4(MxBool&, MxS32&); // vtable+0xa4 - virtual void VTable0xa8(); // vtable+0xa8 + virtual void VTable0xa4(MxBool& p_und1, MxS32& p_und2); // vtable+0xa4 + virtual void VTable0xa8(); // vtable+0xa8 // FUNCTION: LEGO1 0x10002d70 virtual void VTable0xac(MxFloat p_unk0x13c) { m_unk0x13c = p_unk0x13c; } // vtable+0xac diff --git a/LEGO1/lego/legoomni/src/common/legoanimationmanager.cpp b/LEGO1/lego/legoomni/src/common/legoanimationmanager.cpp index 5a761d94..2bd84167 100644 --- a/LEGO1/lego/legoomni/src/common/legoanimationmanager.cpp +++ b/LEGO1/lego/legoomni/src/common/legoanimationmanager.cpp @@ -1153,7 +1153,7 @@ MxResult LegoAnimationManager::FUN_10060dc0( // FUNCTION: LEGO1 0x10060eb0 // FUNCTION: BETA10 0x1004206c -void LegoAnimationManager::CameraTriggerFire(LegoPathActor* p_actor, undefined4, MxU32 p_location, MxBool p_bool) +void LegoAnimationManager::CameraTriggerFire(LegoPathActor* p_actor, MxBool, MxU32 p_location, MxBool p_bool) { if (Lego()->m_unk0x13c && m_enableCamAnims && !m_animRunning) { LegoLocation* location = LegoNavController::GetLocation(p_location); diff --git a/LEGO1/lego/legoomni/src/paths/legopathactor.cpp b/LEGO1/lego/legoomni/src/paths/legopathactor.cpp index ee0da2fa..c26aec13 100644 --- a/LEGO1/lego/legoomni/src/paths/legopathactor.cpp +++ b/LEGO1/lego/legoomni/src/paths/legopathactor.cpp @@ -628,14 +628,49 @@ MxResult LegoPathActor::VTable0x9c() return SUCCESS; } -// STUB: LEGO1 0x1002f650 -void LegoPathActor::VTable0xa4(MxBool&, MxS32&) +// FUNCTION: LEGO1 0x1002f650 +// FUNCTION: BETA10 0x100afd67 +void LegoPathActor::VTable0xa4(MxBool& p_und1, MxS32& p_und2) { - // TODO + switch (GetActorId()) { + case 1: + p_und1 = TRUE; + p_und2 = 2; + break; + case 2: + p_und1 = FALSE; + p_und2 = 1; + break; + case 3: + p_und1 = TRUE; + p_und2 = 1; + break; + case 4: + case 6: + p_und1 = TRUE; + p_und2 = rand() % p_und2 + 1; + break; + case 5: + p_und1 = FALSE; + p_und2 = 2; + break; + default: + p_und1 = TRUE; + p_und2 = 1; + break; + } } -// STUB: LEGO1 0x1002f700 +// FUNCTION: LEGO1 0x1002f700 +// FUNCTION: BETA10 0x100afe4c void LegoPathActor::VTable0xa8() { - // TODO + m_lastTime = Timer()->GetTime(); + m_roi->FUN_100a58f0(m_unk0xec); + m_roi->VTable0x14(); + + if (m_userNavFlag) { + m_roi->WrappedSetLocalTransform(m_unk0xec); + FUN_10010c30(); + } } diff --git a/LEGO1/lego/legoomni/src/paths/legopathboundary.cpp b/LEGO1/lego/legoomni/src/paths/legopathboundary.cpp index 67116bf0..057143ec 100644 --- a/LEGO1/lego/legoomni/src/paths/legopathboundary.cpp +++ b/LEGO1/lego/legoomni/src/paths/legopathboundary.cpp @@ -61,19 +61,19 @@ void LegoPathBoundary::FUN_100575b0(Vector3& p_point1, Vector3& p_point2, LegoPa if (dot2 > dot1) { for (MxS32 i = 0; i < m_unk0x48; i++) { - LegoPathStruct* s = m_unk0x4c[i].m_pathStruct; + LegoPathStruct* s = m_pathTrigger[i].m_pathStruct; - if (m_unk0x4c[i].m_unk0x08 >= dot1 && m_unk0x4c[i].m_unk0x08 < dot2) { - s->HandleTrigger(p_actor, TRUE, m_unk0x4c[i].m_data); + if (m_pathTrigger[i].m_unk0x08 >= dot1 && m_pathTrigger[i].m_unk0x08 < dot2) { + s->HandleTrigger(p_actor, TRUE, m_pathTrigger[i].m_data); } } } else if (dot2 < dot1) { for (MxS32 i = 0; i < m_unk0x48; i++) { - LegoPathStruct* s = m_unk0x4c[i].m_pathStruct; + LegoPathStruct* s = m_pathTrigger[i].m_pathStruct; - if (m_unk0x4c[i].m_unk0x08 >= dot2 && m_unk0x4c[i].m_unk0x08 < dot1) { - s->HandleTrigger(p_actor, FALSE, m_unk0x4c[i].m_data); + if (m_pathTrigger[i].m_unk0x08 >= dot2 && m_pathTrigger[i].m_unk0x08 < dot1) { + s->HandleTrigger(p_actor, FALSE, m_pathTrigger[i].m_data); } } } diff --git a/LEGO1/lego/legoomni/src/paths/legopathcontroller.cpp b/LEGO1/lego/legoomni/src/paths/legopathcontroller.cpp index 4dd2afbf..eeed3661 100644 --- a/LEGO1/lego/legoomni/src/paths/legopathcontroller.cpp +++ b/LEGO1/lego/legoomni/src/paths/legopathcontroller.cpp @@ -678,21 +678,24 @@ MxResult LegoPathController::ReadBoundaries(LegoStorage* p_storage) if (boundary.m_unk0x48 > 0) { boundary.m_unk0x50 = new Mx3DPointFloat; - boundary.m_unk0x4c = new LegoWEGEdge::PathWithTrigger[boundary.m_unk0x48]; + boundary.m_pathTrigger = new LegoWEGEdge::PathWithTrigger[boundary.m_unk0x48]; for (j = 0; j < boundary.m_unk0x48; j++) { if (p_storage->Read(&s, sizeof(s)) != SUCCESS) { return FAILURE; } - boundary.m_unk0x4c[j].m_pathStruct = &m_structs[s]; + boundary.m_pathTrigger[j].m_pathStruct = &m_structs[s]; - if (p_storage->Read(&boundary.m_unk0x4c[j].m_data, sizeof(boundary.m_unk0x4c[j].m_data)) != SUCCESS) { + if (p_storage->Read(&boundary.m_pathTrigger[j].m_data, sizeof(boundary.m_pathTrigger[j].m_data)) != + SUCCESS) { return FAILURE; } - if (p_storage->Read(&boundary.m_unk0x4c[j].m_unk0x08, sizeof(boundary.m_unk0x4c[j].m_unk0x08)) != - SUCCESS) { + if (p_storage->Read( + &boundary.m_pathTrigger[j].m_unk0x08, + sizeof(boundary.m_pathTrigger[j].m_unk0x08) + ) != SUCCESS) { return FAILURE; } } diff --git a/LEGO1/lego/legoomni/src/paths/legopathstruct.cpp b/LEGO1/lego/legoomni/src/paths/legopathstruct.cpp index e4150852..db2cc767 100644 --- a/LEGO1/lego/legoomni/src/paths/legopathstruct.cpp +++ b/LEGO1/lego/legoomni/src/paths/legopathstruct.cpp @@ -17,7 +17,7 @@ DECOMP_SIZE_ASSERT(LegoPathStructBase, 0x0c) DECOMP_SIZE_ASSERT(LegoPathStruct, 0x14) // Flags used in isle.cpp -extern MxU32 g_unk0x100f1198; +extern MxU32 g_isleFlags; // GLOBAL: LEGO1 0x100f119c MxBool g_unk0x100f119c = FALSE; @@ -45,7 +45,7 @@ MxBool LegoPathStruct::HandleTrigger(LegoPathActor* p_actor, MxBool p_direction, switch (m_name[2]) { case c_camAnim: - if (g_unk0x100f1198 & Isle::c_bit6) { + if (g_isleFlags & Isle::c_playCamAnims) { PlayCamAnim(p_actor, bool2, p_data, TRUE); } break; @@ -75,7 +75,7 @@ MxBool LegoPathStruct::HandleTrigger(LegoPathActor* p_actor, MxBool p_direction, break; } case c_music: - if (g_unk0x100f1198 & Isle::c_bit7) { + if (g_isleFlags & Isle::c_playMusic) { PlayMusic(p_direction, p_data); } break; diff --git a/LEGO1/lego/legoomni/src/worlds/isle.cpp b/LEGO1/lego/legoomni/src/worlds/isle.cpp index ba0d822b..9d787a8d 100644 --- a/LEGO1/lego/legoomni/src/worlds/isle.cpp +++ b/LEGO1/lego/legoomni/src/worlds/isle.cpp @@ -38,7 +38,7 @@ DECOMP_SIZE_ASSERT(Isle, 0x140) // GLOBAL: LEGO1 0x100f1198 -MxU32 g_unk0x100f1198 = 0x7f; +MxU32 g_isleFlags = 0x7f; // FUNCTION: LEGO1 0x10030820 Isle::Isle() @@ -724,7 +724,7 @@ void Isle::Enable(MxBool p_enable) AnimationManager()->FUN_1005f6d0(FALSE); AnimationManager()->EnableCamAnims(FALSE); - g_unk0x100f1198 &= ~c_bit7; + g_isleFlags &= ~c_playMusic; m_towtrack->FUN_1004dab0(); break; case 9: @@ -733,7 +733,7 @@ void Isle::Enable(MxBool p_enable) AnimationManager()->FUN_1005f6d0(FALSE); AnimationManager()->EnableCamAnims(FALSE); - g_unk0x100f1198 &= ~c_bit7; + g_isleFlags &= ~c_playMusic; m_ambulance->FUN_10036e60(); break; case 11: diff --git a/LEGO1/lego/sources/geom/legowegedge.cpp b/LEGO1/lego/sources/geom/legowegedge.cpp index 480533f6..afbe9ddb 100644 --- a/LEGO1/lego/sources/geom/legowegedge.cpp +++ b/LEGO1/lego/sources/geom/legowegedge.cpp @@ -12,7 +12,7 @@ LegoWEGEdge::LegoWEGEdge() m_edgeNormals = NULL; m_flags = 0; m_unk0x48 = 0; - m_unk0x4c = NULL; + m_pathTrigger = NULL; m_unk0x50 = NULL; } @@ -29,8 +29,8 @@ LegoWEGEdge::~LegoWEGEdge() if (m_edgeNormals) { delete[] m_edgeNormals; } - if (m_unk0x4c) { - delete m_unk0x4c; + if (m_pathTrigger) { + delete m_pathTrigger; } if (m_unk0x50) { delete m_unk0x50; diff --git a/LEGO1/lego/sources/geom/legowegedge.h b/LEGO1/lego/sources/geom/legowegedge.h index 3617151e..aff336e6 100644 --- a/LEGO1/lego/sources/geom/legowegedge.h +++ b/LEGO1/lego/sources/geom/legowegedge.h @@ -63,16 +63,16 @@ class LegoWEGEdge : public LegoWEEdge { friend class LegoPathController; protected: - LegoU8 m_flags; // 0x0c - LegoU8 m_unk0x0d; // 0x0d - LegoChar* m_name; // 0x10 - Mx4DPointFloat m_unk0x14; // 0x14 - Mx4DPointFloat* m_edgeNormals; // 0x2c - Mx3DPointFloat m_unk0x30; // 0x30 - LegoU32 m_unk0x44; // 0x44 - LegoU8 m_unk0x48; // 0x48 - PathWithTrigger* m_unk0x4c; // 0x4c - Mx3DPointFloat* m_unk0x50; // 0x50 + LegoU8 m_flags; // 0x0c + LegoU8 m_unk0x0d; // 0x0d + LegoChar* m_name; // 0x10 + Mx4DPointFloat m_unk0x14; // 0x14 + Mx4DPointFloat* m_edgeNormals; // 0x2c + Mx3DPointFloat m_unk0x30; // 0x30 + LegoU32 m_unk0x44; // 0x44 + LegoU8 m_unk0x48; // 0x48 + PathWithTrigger* m_pathTrigger; // 0x4c + Mx3DPointFloat* m_unk0x50; // 0x50 }; #endif // __LEGOWEGEDGE_H