diff --git a/LEGO1/lego/legoomni/include/hospital.h b/LEGO1/lego/legoomni/include/hospital.h index 809e64e2..45f131ee 100644 --- a/LEGO1/lego/legoomni/include/hospital.h +++ b/LEGO1/lego/legoomni/include/hospital.h @@ -2,6 +2,7 @@ #define HOSPITAL_H #include "decomp.h" +#include "hospitalstate.h" #include "legoworld.h" // VTABLE: LEGO1 0x100d9730 @@ -37,19 +38,19 @@ class Hospital : public LegoWorld { // Hospital::`scalar deleting destructor' private: - undefined2 m_unk0xf8; // 0xf8 - undefined4 m_unk0xfc; // 0xfc - undefined2 m_unk0x100; // 0x100 - undefined4 m_unk0x104; // 0x104 - VTable0x18 suggests this may be pointer to a LegoGameState - undefined2 m_unk0x108; // 0x108 - undefined4 m_unk0x10c; // 0x10c - undefined4 m_unk0x110; // 0x110 - undefined4 m_unk0x114; // 0x114 - undefined m_unk0x118; // 0x118 - undefined4 m_unk0x11c; // 0x11c - undefined4 m_unk0x120; // 0x120 - undefined m_unk0x124[4]; // 0x124 - undefined m_unk0x128; // 0x128 + undefined2 m_unk0xf8; // 0xf8 + undefined4 m_unk0xfc; // 0xfc + undefined2 m_unk0x100; // 0x100 + HospitalState* m_hospitalState; // 0x104 + undefined2 m_unk0x108; // 0x108 + undefined4 m_unk0x10c; // 0x10c + undefined4 m_unk0x110; // 0x110 + undefined4 m_unk0x114; // 0x114 + undefined m_unk0x118; // 0x118 + undefined4 m_unk0x11c; // 0x11c + undefined4 m_unk0x120; // 0x120 + undefined m_unk0x124[4]; // 0x124 + undefined m_unk0x128; // 0x128 }; #endif // HOSPITAL_H diff --git a/LEGO1/lego/legoomni/include/hospitalstate.h b/LEGO1/lego/legoomni/include/hospitalstate.h index 980007e3..8f9e5ef6 100644 --- a/LEGO1/lego/legoomni/include/hospitalstate.h +++ b/LEGO1/lego/legoomni/include/hospitalstate.h @@ -2,12 +2,18 @@ #define HOSPITALSTATE_H #include "decomp.h" +#include "hospital_actions.h" #include "legostate.h" // VTABLE: LEGO1 0x100d97a0 // SIZE 0x18 class HospitalState : public LegoState { public: + // SIZE 0x04 + struct Unknown0x08 { + undefined4 m_unk0x00; // 0x00 + }; + HospitalState(); ~HospitalState() override {} @@ -29,14 +35,16 @@ class HospitalState : public LegoState { // SYNTHETIC: LEGO1 0x100764c0 // HospitalState::`scalar deleting destructor' + friend class Hospital; + private: - undefined m_unk0x08[4]; // 0x08 - undefined2 m_unk0x0c; // 0x0c - undefined2 m_unk0x0e; // 0x0e - undefined2 m_unk0x10; // 0x10 - undefined2 m_unk0x12; // 0x12 - undefined2 m_unk0x14; // 0x14 - undefined2 m_unk0x16; // 0x16 + Unknown0x08 m_unk0x08; // 0x08 + undefined2 m_unk0x0c; // 0x0c + undefined2 m_unk0x0e; // 0x0e + undefined2 m_unk0x10; // 0x10 + undefined2 m_unk0x12; // 0x12 + undefined2 m_unk0x14; // 0x14 + undefined2 m_unk0x16; // 0x16 }; #endif // HOSPITALSTATE_H diff --git a/LEGO1/lego/legoomni/src/worlds/hospital.cpp b/LEGO1/lego/legoomni/src/worlds/hospital.cpp index 6dfee325..8e245c2b 100644 --- a/LEGO1/lego/legoomni/src/worlds/hospital.cpp +++ b/LEGO1/lego/legoomni/src/worlds/hospital.cpp @@ -1,5 +1,10 @@ #include "hospital.h" +#include "legocontrolmanager.h" +#include "legogamestate.h" +#include "legoinputmanager.h" +#include "legoutils.h" +#include "misc.h" #include "mxmisc.h" #include "mxnotificationmanager.h" @@ -8,18 +13,18 @@ DECOMP_SIZE_ASSERT(Hospital, 0x12c) // FUNCTION: LEGO1 0x100745e0 Hospital::Hospital() { - this->m_unk0xf8 = 0; - this->m_unk0x100 = 0; - this->m_unk0x104 = 0; - this->m_unk0x108 = 0; - this->m_unk0xfc = 0; - this->m_unk0x10c = 0; - this->m_unk0x110 = 0; - this->m_unk0x114 = 0; - this->m_unk0x118 = 0; - this->m_unk0x11c = 0; - this->m_unk0x120 = 0; - this->m_unk0x128 = 0; + m_unk0xf8 = 0; + m_unk0x100 = 0; + m_hospitalState = NULL; + m_unk0x108 = 0; + m_unk0xfc = 0; + m_unk0x10c = 0; + m_unk0x110 = 0; + m_unk0x114 = 0; + m_unk0x118 = 0; + m_unk0x11c = 0; + m_unk0x120 = 0; + m_unk0x128 = 0; NotificationManager()->Register(this); } @@ -35,11 +40,36 @@ Hospital::~Hospital() // TODO } -// STUB: LEGO1 0x100748c0 +// FUNCTION: LEGO1 0x100748c0 MxResult Hospital::Create(MxDSAction& p_dsAction) { - // TODO - return SUCCESS; + MxResult result = LegoWorld::Create(p_dsAction); + if (result == SUCCESS) { + InputManager()->SetWorld(this); + ControlManager()->Register(this); + } + + SetIsWorldActive(FALSE); + + m_hospitalState = (HospitalState*) GameState()->GetState("HospitalState"); + if (!m_hospitalState) { + m_hospitalState = (HospitalState*) GameState()->CreateState("HospitalState"); + m_hospitalState->m_unk0x08.m_unk0x00 = 1; + } + else if (m_hospitalState->m_unk0x08.m_unk0x00 == 4) { + m_hospitalState->m_unk0x08.m_unk0x00 = 4; + } + else { + m_hospitalState->m_unk0x08.m_unk0x00 = 3; + } + + GameState()->SetCurrentArea(LegoGameState::e_hospital); + GameState()->StopArea(LegoGameState::e_previousArea); + + InputManager()->Register(this); + FUN_1003ef00(FALSE); + + return result; } // STUB: LEGO1 0x10074990