From a75ace8a53b3d79c414e578887b4bc92faffd207 Mon Sep 17 00:00:00 2001 From: Christian Semmler Date: Fri, 5 Jul 2024 19:44:01 -0700 Subject: [PATCH] Implement/match TowTrack::VTable0x70 (#1062) --- LEGO1/lego/legoomni/include/legovariables.h | 1 + LEGO1/lego/legoomni/include/towtrack.h | 10 +++-- LEGO1/lego/legoomni/src/actors/towtrack.cpp | 44 ++++++++++++++++--- .../legoomni/src/common/legovariables.cpp | 4 ++ 4 files changed, 49 insertions(+), 10 deletions(-) diff --git a/LEGO1/lego/legoomni/include/legovariables.h b/LEGO1/lego/legoomni/include/legovariables.h index b209776c..1b5cd93b 100644 --- a/LEGO1/lego/legoomni/include/legovariables.h +++ b/LEGO1/lego/legoomni/include/legovariables.h @@ -11,6 +11,7 @@ extern const char* g_varMOTOSPEED; extern const char* g_varMOTOFUEL; extern const char* g_varAMBULSPEED; extern const char* g_varAMBULFUEL; +extern const char* g_varTOWSPEED; extern const char* g_varTOWFUEL; extern const char* g_varVISIBILITY; extern const char* g_varCAMERALOCATION; diff --git a/LEGO1/lego/legoomni/include/towtrack.h b/LEGO1/lego/legoomni/include/towtrack.h index ebcefb54..3d9c7a1a 100644 --- a/LEGO1/lego/legoomni/include/towtrack.h +++ b/LEGO1/lego/legoomni/include/towtrack.h @@ -48,8 +48,8 @@ class TowTrackMissionState : public LegoState { // TowTrackMissionState::`scalar deleting destructor' undefined4 m_unk0x08; // 0x08 - undefined4 m_unk0x0c; // 0x0c - MxU8 m_unk0x10; // 0x10 + MxS32 m_unk0x0c; // 0x0c + MxBool m_unk0x10; // 0x10 MxS16 m_unk0x12; // 0x12 MxS16 m_unk0x14; // 0x14 MxS16 m_unk0x16; // 0x16 @@ -84,7 +84,7 @@ class TowTrack : public IslePathActor { MxLong Notify(MxParam& p_param) override; // vtable+0x04 MxResult Create(MxDSAction& p_dsAction) override; // vtable+0x18 - void VTable0x70(float p_float) override; // vtable+0x70 + void VTable0x70(float p_time) override; // vtable+0x70 MxLong HandleClick() override; // vtable+0xcc MxLong HandleControl(LegoControlManagerNotificationParam& p_param) override; // vtable+0xd4 MxLong HandleEndAnim(LegoEndAnimNotificationParam& p_param) override; // vtable+0xd8 @@ -101,6 +101,8 @@ class TowTrack : public IslePathActor { // TowTrack::`scalar deleting destructor' private: + void FUN_1004dcf0(IsleScript::Script); + undefined4 m_unk0x160; // 0x160 TowTrackMissionState* m_state; // 0x164 MxS16 m_unk0x168; // 0x168 @@ -109,7 +111,7 @@ class TowTrack : public IslePathActor { MxS16 m_unk0x16e; // 0x16e MxS32 m_unk0x170; // 0x170 MxS32 m_unk0x174; // 0x174 - MxFloat m_unk0x178; // 0x178 + MxFloat m_fuel; // 0x178 MxFloat m_time; // 0x17c }; diff --git a/LEGO1/lego/legoomni/src/actors/towtrack.cpp b/LEGO1/lego/legoomni/src/actors/towtrack.cpp index 05cf5fcb..dd9a0d9b 100644 --- a/LEGO1/lego/legoomni/src/actors/towtrack.cpp +++ b/LEGO1/lego/legoomni/src/actors/towtrack.cpp @@ -1,7 +1,9 @@ #include "towtrack.h" +#include "isle_actions.h" #include "legocontrolmanager.h" #include "legogamestate.h" +#include "legonavcontroller.h" #include "legovariables.h" #include "legoworld.h" #include "misc.h" @@ -23,7 +25,7 @@ TowTrack::TowTrack() m_unk0x16e = 0; m_unk0x174 = -1; m_maxLinearVel = 40.0; - m_unk0x178 = 1.0; + m_fuel = 1.0; } // FUNCTION: LEGO1 0x1004c970 @@ -54,15 +56,39 @@ MxResult TowTrack::Create(MxDSAction& p_dsAction) } VariableTable()->SetVariable(g_varTOWFUEL, "1.0"); - m_unk0x178 = 1.0; + m_fuel = 1.0; m_time = Timer()->GetTime(); return result; } -// STUB: LEGO1 0x1004cb10 -void TowTrack::VTable0x70(float p_float) +// FUNCTION: LEGO1 0x1004cb10 +void TowTrack::VTable0x70(float p_time) { - // TODO + IslePathActor::VTable0x70(p_time); + + if (UserActor() == this) { + char buf[200]; + float speed = abs(m_worldSpeed); + float maxLinearVel = NavController()->GetMaxLinearVel(); + + sprintf(buf, "%g", speed / maxLinearVel); + VariableTable()->SetVariable(g_varTOWSPEED, buf); + + m_fuel += (p_time - m_time) * -3.333333333e-06f; + if (m_fuel < 0) { + m_fuel = 0; + } + + m_time = p_time; + + sprintf(buf, "%g", m_fuel); + VariableTable()->SetVariable(g_varTOWFUEL, buf); + + if (p_time - m_state->m_unk0x0c > 100000.0f && m_state->m_unk0x08 == 1 && !m_state->m_unk0x10) { + FUN_1004dcf0(IsleScript::c_Avo909In_PlayWav); + m_state->m_unk0x10 = TRUE; + } + } } // FUNCTION: LEGO1 0x1004cc40 @@ -139,6 +165,12 @@ void TowTrack::FUN_1004dbe0() // TODO } +// STUB: LEGO1 0x1004dcf0 +void TowTrack::FUN_1004dcf0(IsleScript::Script) +{ + // TODO +} + // FUNCTION: LEGO1 0x1004dd30 TowTrackMissionState::TowTrackMissionState() { @@ -149,7 +181,7 @@ TowTrackMissionState::TowTrackMissionState() m_unk0x18 = 0; m_unk0x0c = 0; m_unk0x1a = 0; - m_unk0x10 = 0; + m_unk0x10 = FALSE; m_score1 = 0; m_score2 = 0; m_score3 = 0; diff --git a/LEGO1/lego/legoomni/src/common/legovariables.cpp b/LEGO1/lego/legoomni/src/common/legovariables.cpp index 54569743..da6b30fd 100644 --- a/LEGO1/lego/legoomni/src/common/legovariables.cpp +++ b/LEGO1/lego/legoomni/src/common/legovariables.cpp @@ -48,6 +48,10 @@ const char* g_varAMBULSPEED = "ambulSPEED"; // STRING: LEGO1 0x100f39a0 const char* g_varAMBULFUEL = "ambulFUEL"; +// GLOBAL: LEGO1 0x100f43b0 +// STRING: LEGO1 0x100f43a4 +const char* g_varTOWSPEED = "towSPEED"; + // GLOBAL: LEGO1 0x100f43b4 // STRING: LEGO1 0x100f439c const char* g_varTOWFUEL = "towFUEL";