From a8eebe454ebb568640c0e3302920bc6a1fee6e2c Mon Sep 17 00:00:00 2001 From: Nathan M Gilbert Date: Thu, 4 Apr 2024 06:26:03 -0400 Subject: [PATCH] Implement/match LegoExtraActor:: WaitForAnimation, Restart (#768) * Implement/match LegoExtraActor:: WaitForAnimation, Restart * whitespace --------- Co-authored-by: Christian Semmler --- .../lego/legoomni/include/legoanimpresenter.h | 6 ++- .../lego/legoomni/include/legocarraceactor.h | 2 +- LEGO1/lego/legoomni/include/legoentity.h | 1 + LEGO1/lego/legoomni/include/legoextraactor.h | 5 +- LEGO1/lego/legoomni/include/legojetski.h | 2 +- .../legoomni/include/legojetskiraceactor.h | 2 +- LEGO1/lego/legoomni/include/legopathactor.h | 4 +- .../lego/legoomni/include/legopathboundary.h | 15 +++++- LEGO1/lego/legoomni/include/legoracecar.h | 2 +- .../legoomni/src/entity/legocarraceactor.cpp | 3 +- LEGO1/lego/legoomni/src/entity/legojetski.cpp | 3 +- .../src/entity/legojetskiraceactor.cpp | 3 +- .../legoomni/src/paths/legoextraactor.cpp | 54 +++++++++++++++++-- .../lego/legoomni/src/paths/legopathactor.cpp | 3 +- LEGO1/lego/legoomni/src/race/legoracecar.cpp | 3 +- 15 files changed, 88 insertions(+), 20 deletions(-) diff --git a/LEGO1/lego/legoomni/include/legoanimpresenter.h b/LEGO1/lego/legoomni/include/legoanimpresenter.h index 0c86a6b0..0eff701b 100644 --- a/LEGO1/lego/legoomni/include/legoanimpresenter.h +++ b/LEGO1/lego/legoomni/include/legoanimpresenter.h @@ -51,7 +51,11 @@ class LegoAnimPresenter : public MxVideoPresenter { virtual void VTable0x98(); // vtable+0x98 // STUB: LEGO1 0x1000c990 - virtual void VTable0x9c() {} // vtable+0x9c + virtual undefined4* VTable0x9c(undefined4& p_unk0x6c) + { + p_unk0x6c = m_unk0x6c; + return m_unk0x68; + } // vtable+0x9c virtual void VTable0xa0(); // vtable+0xa0 diff --git a/LEGO1/lego/legoomni/include/legocarraceactor.h b/LEGO1/lego/legoomni/include/legocarraceactor.h index 29ff1797..5671418c 100644 --- a/LEGO1/lego/legoomni/include/legocarraceactor.h +++ b/LEGO1/lego/legoomni/include/legocarraceactor.h @@ -32,7 +32,7 @@ class LegoCarRaceActor : public virtual LegoRaceActor { MxU32 VTable0x90(float, Matrix4&) override; // vtable+0x90 MxResult VTable0x94(LegoPathActor* p_actor, MxBool p_bool) override; // vtable+0x94 void VTable0x98() override; // vtable+0x98 - void VTable0x9c() override; // vtable+0x9c + MxResult WaitForAnimation() override; // vtable+0x9c virtual void FUN_10080590(); diff --git a/LEGO1/lego/legoomni/include/legoentity.h b/LEGO1/lego/legoomni/include/legoentity.h index 69a482cf..775c4f6f 100644 --- a/LEGO1/lego/legoomni/include/legoentity.h +++ b/LEGO1/lego/legoomni/include/legoentity.h @@ -72,6 +72,7 @@ class LegoEntity : public MxEntity { inline MxBool GetUnknown0x10IsSet(MxU8 p_flag) { return m_unk0x10 & p_flag; } inline MxU8 GetFlags() { return m_flags; } + inline MxFloat GetWorldSpeed() { return m_worldSpeed; } inline LegoROI* GetROI() { return m_roi; } inline MxU8 GetUnknown0x59() { return m_unk0x59; } diff --git a/LEGO1/lego/legoomni/include/legoextraactor.h b/LEGO1/lego/legoomni/include/legoextraactor.h index 80da50f3..edaf6928 100644 --- a/LEGO1/lego/legoomni/include/legoextraactor.h +++ b/LEGO1/lego/legoomni/include/legoextraactor.h @@ -41,11 +41,12 @@ class LegoExtraActor : public virtual LegoAnimActor { void VTable0x74(Matrix4& p_transform) override; // vtable+0x74 MxU32 VTable0x90(float p_float, Matrix4& p_matrix) override; // vtable+0x90 MxResult VTable0x94(LegoPathActor* p_actor, MxBool p_bool) override; // vtable+0x94 - void VTable0x9c() override; // vtable+0x9c + MxResult WaitForAnimation() override; // vtable+0x9c void VTable0xa4(MxU8& p_und1, MxS32& p_und2) override; // vtable+0xa4 void VTable0xc4() override; // vtable+0xc4 virtual MxResult FUN_1002aae0(); + void Restart(); inline void FUN_1002ad8a(); // SYNTHETIC: LEGO1 0x1002b760 @@ -56,7 +57,7 @@ class LegoExtraActor : public virtual LegoAnimActor { undefined m_unk0x0c; // 0x0c MxU8 m_axis; // 0x0d undefined m_unk0x0e; // 0x0e - MxFloat m_unk0x10; // 0x10 + MxFloat m_prevWorldSpeed; // 0x10 MxU8 m_unk0x14; // 0x14 MxU8 m_unk0x15; // 0x15 MxMatrix m_unk0x18; // 0x18 diff --git a/LEGO1/lego/legoomni/include/legojetski.h b/LEGO1/lego/legoomni/include/legojetski.h index a153d607..9761a3a6 100644 --- a/LEGO1/lego/legoomni/include/legojetski.h +++ b/LEGO1/lego/legoomni/include/legojetski.h @@ -37,7 +37,7 @@ class LegoJetski : public LegoJetskiRaceActor, public LegoRaceMap { void VTable0x70(float p_float) override; // vtable+0x70 MxResult VTable0x94(LegoPathActor* p_actor, MxBool p_bool) override; // vtable+0x94 void VTable0x98() override; // vtable+0x98 - void VTable0x9c() override; // vtable+0x9c + MxResult WaitForAnimation() override; // vtable+0x9c virtual void FUN_100136f0(float p_worldSpeed); diff --git a/LEGO1/lego/legoomni/include/legojetskiraceactor.h b/LEGO1/lego/legoomni/include/legojetskiraceactor.h index d24566f5..20bbb545 100644 --- a/LEGO1/lego/legoomni/include/legojetskiraceactor.h +++ b/LEGO1/lego/legoomni/include/legojetskiraceactor.h @@ -30,7 +30,7 @@ class LegoJetskiRaceActor : public virtual LegoCarRaceActor { void VTable0x6c() override; // vtable+0x6c void VTable0x70(float p_float) override; // vtable+0x70 void VTable0x98() override; // vtable+0x98 - void VTable0x9c() override; // vtable+0x9c + MxResult WaitForAnimation() override; // vtable+0x9c void VTable0x1c() override; // vtable+0x1c // SYNTHETIC: LEGO1 0x10081d40 diff --git a/LEGO1/lego/legoomni/include/legopathactor.h b/LEGO1/lego/legoomni/include/legopathactor.h index 3a9bea76..e78cae8b 100644 --- a/LEGO1/lego/legoomni/include/legopathactor.h +++ b/LEGO1/lego/legoomni/include/legopathactor.h @@ -51,8 +51,8 @@ class LegoPathActor : public LegoActor { // FUNCTION: LEGO1 0x10002d50 virtual MxResult VTable0x94(LegoPathActor*, MxBool) { return 0; } // vtable+0x94 - virtual void VTable0x98(); // vtable+0x98 - virtual void VTable0x9c(); // vtable+0x9c + virtual void VTable0x98(); // vtable+0x98 + virtual MxResult WaitForAnimation(); // vtable+0x9c // FUNCTION: LEGO1 0x10002d60 virtual MxS32 VTable0xa0() { return 0; } // vtable+0xa0 diff --git a/LEGO1/lego/legoomni/include/legopathboundary.h b/LEGO1/lego/legoomni/include/legopathboundary.h index 11a97230..763059f5 100644 --- a/LEGO1/lego/legoomni/include/legopathboundary.h +++ b/LEGO1/lego/legoomni/include/legopathboundary.h @@ -2,6 +2,7 @@ #define LEGOPATHBOUNDARY_H #include "geom/legowegedge.h" +#include "legoanimpresenter.h" #include "mxstl/stlcompat.h" #include "mxtypes.h" @@ -9,6 +10,12 @@ struct LegoPathBoundaryComparator { MxBool operator()(const undefined*, const undefined*) const { return 0; } }; +struct LegoAnimPresenterSetCompare { + MxBool operator()(const LegoAnimPresenter*, const LegoAnimPresenter*) const { return 0; } +}; + +typedef set LegoAnimPresenterSet; + // VTABLE: LEGO1 0x100d8618 // SIZE 0x74 class LegoPathBoundary : public LegoWEGEdge { @@ -17,10 +24,16 @@ class LegoPathBoundary : public LegoWEGEdge { // STUB: LEGO1 0x10047a80 // LegoPathBoundary::`scalar deleting destructor' + inline LegoAnimPresenterSet* GetUnknown0x64() { return &m_unk0x64; } private: map m_unk0x54; // 0x54 - map m_unk0x64; // 0x64 + LegoAnimPresenterSet m_unk0x64; // 0x64 }; +// clang-format off +// GLOBAL: LEGO1 0x100f3200 +// _Tree >::_Kfn,LegoAnimPresenterSetCompare,allocator >::_Nil +// clang-format on + #endif // LEGOPATHBOUNDARY_H diff --git a/LEGO1/lego/legoomni/include/legoracecar.h b/LEGO1/lego/legoomni/include/legoracecar.h index 58098a94..f6b21501 100644 --- a/LEGO1/lego/legoomni/include/legoracecar.h +++ b/LEGO1/lego/legoomni/include/legoracecar.h @@ -37,7 +37,7 @@ class LegoRaceCar : public LegoCarRaceActor, public LegoRaceMap { void VTable0x70(float p_float) override; // vtable+0x70 MxResult VTable0x94(LegoPathActor* p_actor, MxBool p_bool) override; // vtable+0x94 void VTable0x98() override; // vtable+0x98 - void VTable0x9c() override; // vtable+0x9c + MxResult WaitForAnimation() override; // vtable+0x9c virtual void FUN_10012ea0(float p_worldSpeed); virtual void FUN_10012ff0(float); diff --git a/LEGO1/lego/legoomni/src/entity/legocarraceactor.cpp b/LEGO1/lego/legoomni/src/entity/legocarraceactor.cpp index e28ebc46..2e3524c7 100644 --- a/LEGO1/lego/legoomni/src/entity/legocarraceactor.cpp +++ b/LEGO1/lego/legoomni/src/entity/legocarraceactor.cpp @@ -70,7 +70,8 @@ void LegoCarRaceActor::VTable0x98() } // STUB: LEGO1 0x10081d30 -void LegoCarRaceActor::VTable0x9c() +MxResult LegoCarRaceActor::WaitForAnimation() { // TODO + return SUCCESS; } diff --git a/LEGO1/lego/legoomni/src/entity/legojetski.cpp b/LEGO1/lego/legoomni/src/entity/legojetski.cpp index 75cf5cff..c919276c 100644 --- a/LEGO1/lego/legoomni/src/entity/legojetski.cpp +++ b/LEGO1/lego/legoomni/src/entity/legojetski.cpp @@ -69,7 +69,8 @@ void LegoJetski::VTable0x98() } // STUB: LEGO1 0x10014200 -void LegoJetski::VTable0x9c() +MxResult LegoJetski::WaitForAnimation() { // TODO + return SUCCESS; } diff --git a/LEGO1/lego/legoomni/src/entity/legojetskiraceactor.cpp b/LEGO1/lego/legoomni/src/entity/legojetskiraceactor.cpp index 14fde544..f5e8c8a4 100644 --- a/LEGO1/lego/legoomni/src/entity/legojetskiraceactor.cpp +++ b/LEGO1/lego/legoomni/src/entity/legojetskiraceactor.cpp @@ -36,7 +36,8 @@ void LegoJetskiRaceActor::VTable0x98() } // STUB: LEGO1 0x100822e0 -void LegoJetskiRaceActor::VTable0x9c() +MxResult LegoJetskiRaceActor::WaitForAnimation() { // TODO + return SUCCESS; } diff --git a/LEGO1/lego/legoomni/src/paths/legoextraactor.cpp b/LEGO1/lego/legoomni/src/paths/legoextraactor.cpp index a1a84eba..45d43cc0 100644 --- a/LEGO1/lego/legoomni/src/paths/legoextraactor.cpp +++ b/LEGO1/lego/legoomni/src/paths/legoextraactor.cpp @@ -145,7 +145,7 @@ MxResult LegoExtraActor::FUN_1002aae0() m_boundary = oldEdge; } - LegoPathActor::VTable0x9c(); + LegoPathActor::WaitForAnimation(); return SUCCESS; } @@ -229,7 +229,7 @@ MxResult LegoExtraActor::VTable0x94(LegoPathActor* p_actor, MxBool p_bool) FUN_1002ad8a(); SoundManager()->GetCacheSoundManager()->FUN_1003dae0("crash5", m_roi->GetName(), FALSE); m_scheduledTime = Timer()->GetTime() + m_disAnim->GetDuration(); - m_unk0x10 = m_worldSpeed; + m_prevWorldSpeed = m_worldSpeed; VTable0xc4(); SetWorldSpeed(0); m_unk0x14 = 1; @@ -273,10 +273,54 @@ MxResult LegoExtraActor::VTable0x94(LegoPathActor* p_actor, MxBool p_bool) return SUCCESS; } -// STUB: LEGO1 0x1002b290 -void LegoExtraActor::VTable0x9c() +// FUNCTION: LEGO1 0x1002b290 +MxResult LegoExtraActor::WaitForAnimation() { - // TODO + LegoPathBoundary* oldBoundary = m_boundary; + MxResult result = LegoPathActor::WaitForAnimation(); + + if (m_boundary != oldBoundary) { + MxU32 b = FALSE; + LegoAnimPresenterSet* set = m_boundary->GetUnknown0x64(); + + for (LegoAnimPresenterSet::iterator it = set->begin(); it != set->end(); it++) { + undefined4 tmp; + if ((*it)->VTable0x9c(tmp)) { + b = TRUE; + break; + } + } + + if (b) { + m_unk0x0e = 1; + m_prevWorldSpeed = GetWorldSpeed(); + SetWorldSpeed(0); + } + } + + return result; +} + +// FUNCTION: LEGO1 0x1002b370 +void LegoExtraActor::Restart() +{ + if (m_unk0x0e != 0) { + MxU32 b = FALSE; + LegoAnimPresenterSet* set = m_boundary->GetUnknown0x64(); + + for (LegoAnimPresenterSet::iterator it = set->begin(); it != set->end(); it++) { + undefined4 tmp; + if ((*it)->VTable0x9c(tmp)) { + b = TRUE; + break; + } + } + + if (!b) { + SetWorldSpeed(m_prevWorldSpeed); + m_unk0x0e = 0; + } + } } // STUB: LEGO1 0x1002b440 diff --git a/LEGO1/lego/legoomni/src/paths/legopathactor.cpp b/LEGO1/lego/legoomni/src/paths/legopathactor.cpp index 8ab1c470..e389d1b8 100644 --- a/LEGO1/lego/legoomni/src/paths/legopathactor.cpp +++ b/LEGO1/lego/legoomni/src/paths/legopathactor.cpp @@ -75,9 +75,10 @@ void LegoPathActor::ParseAction(char*) } // STUB: LEGO1 0x1002f1b0 -void LegoPathActor::VTable0x9c() +MxResult LegoPathActor::WaitForAnimation() { // TODO + return SUCCESS; } // STUB: LEGO1 0x1002f650 diff --git a/LEGO1/lego/legoomni/src/race/legoracecar.cpp b/LEGO1/lego/legoomni/src/race/legoracecar.cpp index b7fc1ee3..0c7484a3 100644 --- a/LEGO1/lego/legoomni/src/race/legoracecar.cpp +++ b/LEGO1/lego/legoomni/src/race/legoracecar.cpp @@ -89,7 +89,8 @@ void LegoRaceCar::VTable0x98() } // STUB: LEGO1 0x10014580 -void LegoRaceCar::VTable0x9c() +MxResult LegoRaceCar::WaitForAnimation() { // TODO + return SUCCESS; }