diff --git a/LEGO1/isle.cpp b/LEGO1/isle.cpp index ec71d083..3b544960 100644 --- a/LEGO1/isle.cpp +++ b/LEGO1/isle.cpp @@ -1,27 +1,178 @@ #include "isle.h" +#include "act1state.h" +#include "legocontrolmanager.h" +#include "legogamestate.h" +#include "legoinputmanager.h" #include "legoomni.h" +#include "legoutil.h" #include "mxnotificationmanager.h" +#include "mxtransitionmanager.h" DECOMP_SIZE_ASSERT(Isle, 0x140); // FUNCTION: LEGO1 0x10030820 Isle::Isle() { - m_unk0xfc = 0; - m_unk0x100 = 0; - m_unk0x104 = 0; - m_unk0x108 = 0; - m_unk0x10c = 0; - m_unk0x110 = 0; - m_unk0x114 = 0; - m_unk0x118 = 0; - m_unk0x11c = 0; - m_unk0x120 = 0; - m_unk0x124 = 0; - m_unk0x128 = 0; - m_unk0xf8 = 0; + m_pizza = NULL; + m_pizzeria = NULL; + m_towtrack = NULL; + m_ambulance = NULL; + m_jukebox = NULL; + m_helicopter = NULL; + m_bike = NULL; + m_dunebuggy = NULL; + m_motorcycle = NULL; + m_skateboard = NULL; + m_racecar = NULL; + m_jetski = NULL; + m_act1state = 0; m_unk0x13c = 0; NotificationManager()->Register(this); } + +// FUNCTION: LEGO1 0x10030a50 +Isle::~Isle() +{ + TransitionManager()->SetWaitIndicator(NULL); + ControlManager()->Unregister(this); + + if (InputManager()->GetWorld() == this) { + InputManager()->ClearWorld(); + } + + if (GetCurrentVehicle() != NULL) { + VTable0x6c((MxCore*) GetCurrentVehicle()); + } + + NotificationManager()->Unregister(this); +} + +// FUNCTION: LEGO1 0x10030b20 +MxResult Isle::Create(MxDSObject& p_dsObject) +{ + GameState()->FUN_1003ceb0(); + + MxResult result = LegoWorld::SetAsCurrentWorld(p_dsObject); + if (result == SUCCESS) { + ControlManager()->Register(this); + InputManager()->SetWorld(this); + GameState()->FUN_1003a720(0); + + switch (GameState()->GetCurrentAct()) { + case 1: + GameState()->FUN_1003a720(0x2e); + break; + case 2: + GameState()->FUN_1003a720(0x2e); + break; + case -1: + m_unk0x13c = 2; + } + + if (GameState()->GetUnknown424() == 1) { + GameState()->SetUnknown424(0); + } + + LegoGameState* gameState = GameState(); + Act1State* state = (Act1State*) gameState->GetState("Act1State"); + if (state == NULL) { + state = (Act1State*) gameState->CreateState("Act1State"); + } + m_act1state = state; + + FUN_1003ef00(TRUE); + GameState()->SetDirty(TRUE); + } + + return result; +} + +// STUB: LEGO1 0x10030c10 +MxLong Isle::Notify(MxParam& p_param) +{ + // TODO + return 0; +} + +// STUB: LEGO1 0x10030fc0 +void Isle::Stop() +{ + // TODO +} + +// STUB: LEGO1 0x10031820 +void Isle::VTable0x68(MxBool p_add) +{ + // TODO +} + +// FUNCTION: LEGO1 0x10032f10 +void Isle::VTable0x58(MxCore* p_object) +{ + LegoWorld::VTable0x58(p_object); + + if (p_object->IsA("Pizza")) { + m_pizza = (Pizza*) p_object; + } + else if (p_object->IsA("Pizzeria")) { + m_pizzeria = (Pizzeria*) p_object; + } + else if (p_object->IsA("TowTrack")) { + m_towtrack = (TowTrack*) p_object; + } + else if (p_object->IsA("Ambulance")) { + m_ambulance = (Ambulance*) p_object; + } + else if (p_object->IsA("JukeBoxEntity")) { + m_jukebox = (JukeBoxEntity*) p_object; + } + else if (p_object->IsA("Helicopter")) { + m_helicopter = (Helicopter*) p_object; + } + else if (p_object->IsA("Bike")) { + m_bike = (Bike*) p_object; + } + else if (p_object->IsA("DuneBuggy")) { + m_dunebuggy = (DuneBuggy*) p_object; + } + else if (p_object->IsA("Motorcycle")) { + m_motorcycle = (Motorcycle*) p_object; + } + else if (p_object->IsA("SkateBoard")) { + m_skateboard = (SkateBoard*) p_object; + } + else if (p_object->IsA("Jetski")) { + m_jetski = (Jetski*) p_object; + } + else if (p_object->IsA("RaceCar")) { + m_racecar = (RaceCar*) p_object; + } +} + +// FUNCTION: LEGO1 0x10033050 +void Isle::VTable0x6c(MxCore* p_object) +{ + LegoWorld::EndAction(p_object); + + if (p_object->IsA("Helicopter")) { + m_helicopter = NULL; + } + else if (p_object->IsA("DuneBuggy")) { + m_dunebuggy = NULL; + } + else if (p_object->IsA("Jetski")) { + m_jetski = 0; + } + else if (p_object->IsA("RaceCar")) { + m_racecar = 0; + } +} + +// STUB: LEGO1 0x10033180 +MxBool Isle::VTable0x64() +{ + // TODO + return FALSE; +} diff --git a/LEGO1/isle.h b/LEGO1/isle.h index b714ea19..594f9d74 100644 --- a/LEGO1/isle.h +++ b/LEGO1/isle.h @@ -4,12 +4,29 @@ #include "legoworld.h" #include "radio.h" +class Pizza; +class Pizzeria; +class TowTrack; +class Ambulance; +class JukeBoxEntity; +class Helicopter; +class Bike; +class DuneBuggy; +class Motorcycle; +class SkateBoard; +class RaceCar; +class Jetski; +class Act1State; + // VTABLE: LEGO1 0x100d6fb8 // SIZE 0x140 // Radio at 0x12c class Isle : public LegoWorld { public: Isle(); + virtual ~Isle() override; + + virtual MxLong Notify(MxParam& p_param) override; // vtable+0x4 // FUNCTION: LEGO1 0x10030910 inline virtual const char* ClassName() const override // vtable+0x0c @@ -23,24 +40,35 @@ class Isle : public LegoWorld { { return !strcmp(p_name, Isle::ClassName()) || LegoWorld::IsA(p_name); } + virtual MxResult Create(MxDSObject& p_dsObject) override; // vtable+0x18 + virtual void Stop() override; // vtable+50 + virtual void VTable0x58(MxCore* p_object); // vtable+58 + // FUNCTION: LEGO1 0x10030900 + virtual MxBool VTable0x5c() { return TRUE; } // vtable+5c + // FUNCTION: LEGO1 0x10033170 + virtual void VTable0x60() {} // vtable+60 + virtual MxBool VTable0x64(); // vtable+64 + virtual void VTable0x68(MxBool p_add); // vtable+68 + virtual void VTable0x6c(MxCore* p_object); + inline void SetUnknown13c(MxU32 p_unk0x13c) { m_unk0x13c = p_unk0x13c; } protected: - undefined4 m_unk0xf8; // 0xf8 - undefined4 m_unk0xfc; // 0xfc - undefined4 m_unk0x100; // 0x100 - undefined4 m_unk0x104; // 0x104 - undefined4 m_unk0x108; // 0x108 - undefined4 m_unk0x10c; // 0x10c - undefined4 m_unk0x110; // 0x110 - undefined4 m_unk0x114; // 0x114 - undefined4 m_unk0x118; // 0x118 - undefined4 m_unk0x11c; // 0x11c - undefined4 m_unk0x120; // 0x120 - undefined4 m_unk0x124; // 0x124 - undefined4 m_unk0x128; // 0x128 - Radio m_radio; // 0x12c - MxU32 m_unk0x13c; // 0x13c + Act1State* m_act1state; // 0xf8 + Pizza* m_pizza; // 0xfc + Pizzeria* m_pizzeria; // 0x100 + TowTrack* m_towtrack; // 0x104 + Ambulance* m_ambulance; // 0x108 + JukeBoxEntity* m_jukebox; // 0x10c + Helicopter* m_helicopter; // 0x110 + Bike* m_bike; // 0x114 + DuneBuggy* m_dunebuggy; // 0x118 + Motorcycle* m_motorcycle; // 0x11c + SkateBoard* m_skateboard; // 0x120 + RaceCar* m_racecar; // 0x124 + Jetski* m_jetski; // 0x128 + Radio m_radio; // 0x12c + MxU32 m_unk0x13c; // 0x13c }; #endif // ISLE_H diff --git a/LEGO1/legogamestate.h b/LEGO1/legogamestate.h index 5643de52..656b990c 100644 --- a/LEGO1/legogamestate.h +++ b/LEGO1/legogamestate.h @@ -36,6 +36,9 @@ class LegoGameState { inline MxU8 GetUnknownC() { return m_unk0xc; } inline MxU32 GetUnknown10() { return m_unk0x10; } + inline MxS32 GetCurrentAct() { return m_currentAct; } + inline undefined4 GetUnknown424() { return m_unk0x424; } + inline void SetDirty(MxBool p_dirty) { m_isDirty = p_dirty; } inline void SetUnknown424(undefined4 p_unk0x424) { m_unk0x424 = p_unk0x424; } void SetSomeEnumState(undefined4 p_state); @@ -59,14 +62,15 @@ class LegoGameState { LegoState** m_stateArray; // 0x8 MxU8 m_unk0xc; // 0xc MxU32 m_unk0x10; // 0x10 - undefined4 m_currentAct; // 0x14 + MxS32 m_currentAct; // 0x14 LegoBackgroundColor* m_backgroundColor; // 0x18 LegoBackgroundColor* m_tempBackgroundColor; // 0x1c LegoFullScreenMovie* m_fullScreenMovie; // 0x20 MxU16 m_unk0x24; // 0x24 undefined m_unk0x28[128]; // 0x28 ScoreStruct m_unk0xa6; // 0xa6 - undefined m_unk0x41a[10]; // 0x41a - might be part of the structure at 0xa6 + undefined m_unk0x41a[8]; // 0x41a - might be part of the structure at 0xa6 + MxBool m_isDirty; // 0x420 undefined4 m_unk0x424; // 0x424 undefined4 m_unk0x428; // 0x428 undefined4 m_unk0x42c; // 0x42c diff --git a/LEGO1/legoutil.cpp b/LEGO1/legoutil.cpp index e608609b..42d14dac 100644 --- a/LEGO1/legoutil.cpp +++ b/LEGO1/legoutil.cpp @@ -112,6 +112,12 @@ void FUN_1003ee00(MxAtomId& p_atomId, MxS32 p_id) { } +// STUB: LEGO1 0x1003ef00 +void FUN_1003ef00(MxBool) +{ + // TODO (something related to animation manager) +} + // FUNCTION: LEGO1 0x1003ef40 void SetAppCursor(WPARAM p_wparam) { diff --git a/LEGO1/legoutil.h b/LEGO1/legoutil.h index f2413450..afc0a0d4 100644 --- a/LEGO1/legoutil.h +++ b/LEGO1/legoutil.h @@ -59,6 +59,7 @@ ExtraActionType MatchActionString(const char*); void InvokeAction(ExtraActionType p_actionId, MxAtomId& p_pAtom, int p_targetEntityId, LegoEntity* p_sender); void ConvertHSVToRGB(float p_h, float p_s, float p_v, float* p_rOut, float* p_bOut, float* p_gOut); void FUN_1003ee00(MxAtomId& p_atomId, MxS32 p_id); +void FUN_1003ef00(MxBool); void SetAppCursor(WPARAM p_wparam); MxBool FUN_1003ef60(); diff --git a/LEGO1/legoworld.cpp b/LEGO1/legoworld.cpp index 2d52b031..13d53a0f 100644 --- a/LEGO1/legoworld.cpp +++ b/LEGO1/legoworld.cpp @@ -98,7 +98,7 @@ void LegoWorld::VTable0x58(MxCore* p_object) } // STUB: LEGO1 0x10020f10 -void LegoWorld::EndAction(MxPresenter* p_presenter) +void LegoWorld::EndAction(MxCore* p_presenter) { } diff --git a/LEGO1/legoworld.h b/LEGO1/legoworld.h index 87508ae1..9ca61b56 100644 --- a/LEGO1/legoworld.h +++ b/LEGO1/legoworld.h @@ -44,7 +44,7 @@ class LegoWorld : public LegoEntity { inline LegoCameraController* GetCamera() { return m_camera; } MxResult SetAsCurrentWorld(MxDSObject& p_dsObject); - void EndAction(MxPresenter* p_presenter); + void EndAction(MxCore* p_presenter); void FUN_1001fc80(IslePathActor* p_actor); MxBool FUN_100727e0(MxU32, Vector3Data& p_loc, Vector3Data& p_dir, Vector3Data& p_up); MxBool FUN_10072980(MxU32, Vector3Data& p_loc, Vector3Data& p_dir, Vector3Data& p_up);