diff --git a/LEGO1/lego/legoomni/include/ambulance.h b/LEGO1/lego/legoomni/include/ambulance.h index ae9bee04..99615f9e 100644 --- a/LEGO1/lego/legoomni/include/ambulance.h +++ b/LEGO1/lego/legoomni/include/ambulance.h @@ -1,6 +1,7 @@ #ifndef AMBULANCE_H #define AMBULANCE_H +#include "ambulancemissionstate.h" #include "islepathactor.h" // VTABLE: LEGO1 0x100d71a8 @@ -8,6 +9,7 @@ class Ambulance : public IslePathActor { public: Ambulance(); + ~Ambulance() override; MxLong Notify(MxParam& p_param) override; // vtable+0x04 MxResult Tickle() override; // vtable+0x08 @@ -40,19 +42,18 @@ class Ambulance : public IslePathActor { // Ambulance::`scalar deleting destructor' private: - // TODO: Ambulance fields - undefined m_unk0x160[4]; - MxS32 m_unk0x164; - MxS16 m_unk0x168; - MxS16 m_unk0x16a; - MxS16 m_unk0x16c; - MxS16 m_unk0x16e; - MxS16 m_unk0x170; - MxS16 m_unk0x172; - MxS32 m_unk0x174; - MxS32 m_unk0x178; - MxFloat m_unk0x17c; - undefined m_unk0x180[4]; + undefined m_unk0x160[4]; // 0x160 + AmbulanceMissionState* m_state; // 0x164 + MxS16 m_unk0x168; // 0x168 + MxS16 m_unk0x16a; // 0x16a + MxS16 m_unk0x16c; // 0x16c + MxS16 m_unk0x16e; // 0x16e + MxS16 m_unk0x170; // 0x170 + MxS16 m_unk0x172; // 0x172 + MxS32 m_unk0x174; // 0x174 + MxS32 m_unk0x178; // 0x178 + MxFloat m_unk0x17c; // 0x17c + MxFloat m_time; // 0x180 }; #endif // AMBULANCE_H diff --git a/LEGO1/lego/legoomni/include/ambulancemissionstate.h b/LEGO1/lego/legoomni/include/ambulancemissionstate.h index aca6120b..143a027d 100644 --- a/LEGO1/lego/legoomni/include/ambulancemissionstate.h +++ b/LEGO1/lego/legoomni/include/ambulancemissionstate.h @@ -24,6 +24,8 @@ class AmbulanceMissionState : public LegoState { MxResult VTable0x1c(LegoFile* p_legoFile) override; // vtable+0x1c + inline void SetUnknown0x08(undefined4 p_unk0x08) { m_unk0x08 = p_unk0x08; } + inline MxU16 GetColor(MxU8 p_id) { switch (p_id) { diff --git a/LEGO1/lego/legoomni/include/legogamestate.h b/LEGO1/lego/legoomni/include/legogamestate.h index 54539326..80b6e2d0 100644 --- a/LEGO1/lego/legoomni/include/legogamestate.h +++ b/LEGO1/lego/legoomni/include/legogamestate.h @@ -177,9 +177,9 @@ class LegoGameState { void SetCurrentAct(Act p_currentAct); void FindLoadedAct(); + void RegisterState(LegoState* p_state); private: - void RegisterState(LegoState* p_state); MxResult WriteVariable(LegoStorage* p_storage, MxVariableTable* p_from, const char* p_variableName); MxResult WriteEndOfVariables(LegoStorage* p_storage); MxS32 ReadVariable(LegoStorage* p_storage, MxVariableTable* p_to); diff --git a/LEGO1/lego/legoomni/include/legovariables.h b/LEGO1/lego/legoomni/include/legovariables.h index 8528d44d..ec02c530 100644 --- a/LEGO1/lego/legoomni/include/legovariables.h +++ b/LEGO1/lego/legoomni/include/legovariables.h @@ -3,6 +3,7 @@ #include "mxvariable.h" +extern const char* g_varAMBULFUEL; extern const char* g_varVISIBILITY; extern const char* g_varCAMERALOCATION; extern const char* g_varCURSOR; diff --git a/LEGO1/lego/legoomni/src/actors/ambulance.cpp b/LEGO1/lego/legoomni/src/actors/ambulance.cpp index 168e48ed..9c0f87e5 100644 --- a/LEGO1/lego/legoomni/src/actors/ambulance.cpp +++ b/LEGO1/lego/legoomni/src/actors/ambulance.cpp @@ -1,6 +1,14 @@ #include "ambulance.h" #include "decomp.h" +#include "legocontrolmanager.h" +#include "legogamestate.h" +#include "legoomni.h" +#include "legovariables.h" +#include "misc.h" +#include "mxmisc.h" +#include "mxticklemanager.h" +#include "mxtimer.h" DECOMP_SIZE_ASSERT(Ambulance, 0x184) @@ -9,7 +17,7 @@ Ambulance::Ambulance() { this->m_unk0x168 = 0; this->m_unk0x16a = -1; - this->m_unk0x164 = 0; + this->m_state = NULL; this->m_unk0x16c = 0; this->m_unk0x174 = -1; this->m_unk0x16e = 0; @@ -20,17 +28,43 @@ Ambulance::Ambulance() this->m_unk0x17c = 1.0; } -// STUB: LEGO1 0x10035f90 +// FUNCTION: LEGO1 0x10035f90 void Ambulance::Destroy(MxBool p_fromDestructor) { - // TODO } -// STUB: LEGO1 0x100361d0 +// FUNCTION: LEGO1 0x10036150 +Ambulance::~Ambulance() +{ + ControlManager()->Unregister(this); + TickleManager()->UnregisterClient(this); +} + +// FUNCTION: LEGO1 0x100361d0 MxResult Ambulance::Create(MxDSAction& p_dsAction) { - // TODO - return SUCCESS; + MxResult result = IslePathActor::Create(p_dsAction); + + if (result == SUCCESS) { + m_world = CurrentWorld(); + + if (m_world) { + m_world->Add(this); + } + + m_state = (AmbulanceMissionState*) GameState()->GetState("AmbulanceMissionState"); + if (!m_state) { + m_state = new AmbulanceMissionState(); + m_state->SetUnknown0x08(0); + GameState()->RegisterState(m_state); + } + } + + VariableTable()->SetVariable(g_varAMBULFUEL, "1.0"); + m_unk0x17c = 1.0; + m_time = Timer()->GetTime(); + + return result; } // STUB: LEGO1 0x10036300 diff --git a/LEGO1/lego/legoomni/src/common/legovariables.cpp b/LEGO1/lego/legoomni/src/common/legovariables.cpp index d4689af5..83a17084 100644 --- a/LEGO1/lego/legoomni/src/common/legovariables.cpp +++ b/LEGO1/lego/legoomni/src/common/legovariables.cpp @@ -15,6 +15,10 @@ DECOMP_SIZE_ASSERT(CursorVariable, 0x24) DECOMP_SIZE_ASSERT(WhoAmIVariable, 0x24) DECOMP_SIZE_ASSERT(CustomizeAnimFileVariable, 0x24) +// GLOBAL: LEGO1 0x100f39bc +// STRING: LEGO1 0x100f39a0 +const char* g_varAMBULFUEL = "ambulFUEL"; + // GLOBAL: LEGO1 0x100f3a40 // STRING: LEGO1 0x100f3808 const char* g_varVISIBILITY = "VISIBILITY";