GasStation destructor, enable, create (#561)

* GasStation destructor, enable, create

* Fixes

* Remove comment

---------

Co-authored-by: Christian Semmler <mail@csemmler.com>
This commit is contained in:
Joshua Peisach 2024-02-13 18:40:04 -05:00 committed by GitHub
parent 971ac8b6e7
commit eb3b339454
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 87 additions and 21 deletions

View file

@ -2,6 +2,7 @@
#define GASSTATION_H #define GASSTATION_H
#include "decomp.h" #include "decomp.h"
#include "gasstationstate.h"
#include "legoworld.h" #include "legoworld.h"
#include "radio.h" #include "radio.h"
@ -42,7 +43,7 @@ class GasStation : public LegoWorld {
undefined2 m_unk0xf8; // 0xf8 undefined2 m_unk0xf8; // 0xf8
undefined2 m_unk0xfa; // 0xfa undefined2 m_unk0xfa; // 0xfa
undefined4 m_unk0xfc; // 0xfc undefined4 m_unk0xfc; // 0xfc
undefined4 m_unk0x100; // 0x100 GasStationState* m_state; // 0x100
undefined2 m_unk0x104; // 0x104 undefined2 m_unk0x104; // 0x104
undefined2 m_unk0x106; // 0x106 undefined2 m_unk0x106; // 0x106
undefined4 m_unk0x108; // 0x108 undefined4 m_unk0x108; // 0x108

View file

@ -7,6 +7,15 @@
// SIZE 0x24 // SIZE 0x24
class GasStationState : public LegoState { class GasStationState : public LegoState {
public: public:
// SIZE 0x04
struct Unknown0x14 {
inline void SetUnknown0x00(undefined4 p_unk0x00) { m_unk0x00 = p_unk0x00; }
inline undefined4 GetUnknown0x00() { return m_unk0x00; }
private:
undefined4 m_unk0x00; // 0x00
};
GasStationState(); GasStationState();
// FUNCTION: LEGO1 0x100061d0 // FUNCTION: LEGO1 0x100061d0
@ -27,9 +36,11 @@ class GasStationState : public LegoState {
// SYNTHETIC: LEGO1 0x10006290 // SYNTHETIC: LEGO1 0x10006290
// GasStationState::`scalar deleting destructor' // GasStationState::`scalar deleting destructor'
inline Unknown0x14& GetUnknown0x14() { return m_unk0x14; }
private: private:
undefined4 m_unk0x08[3]; // 0x08 undefined4 m_unk0x08[3]; // 0x08
undefined4 m_unk0x14; // 0x14 Unknown0x14 m_unk0x14; // 0x14
undefined2 m_unk0x18; // 0x18 undefined2 m_unk0x18; // 0x18
undefined2 m_unk0x1a; // 0x1a undefined2 m_unk0x1a; // 0x1a
undefined2 m_unk0x1c; // 0x1c undefined2 m_unk0x1c; // 0x1c

View file

@ -1,12 +1,20 @@
#include "gasstation.h" #include "gasstation.h"
#include "legocontrolmanager.h"
#include "legogamestate.h"
#include "legoinputmanager.h"
#include "legoomni.h"
#include "mxnotificationmanager.h" #include "mxnotificationmanager.h"
#include "mxticklemanager.h"
// GLOBAL: LEGO1 0x100f0160
undefined4 g_unk0x100f0160;
// FUNCTION: LEGO1 0x100046a0 // FUNCTION: LEGO1 0x100046a0
GasStation::GasStation() GasStation::GasStation()
{ {
m_unk0xf8 = 0; m_unk0xf8 = 0;
m_unk0x100 = 0; m_state = NULL;
m_unk0xfc = 0; m_unk0xfc = 0;
m_unk0x108 = 0; m_unk0x108 = 0;
m_unk0x104 = 0; m_unk0x104 = 0;
@ -25,17 +33,52 @@ MxBool GasStation::VTable0x5c()
return TRUE; return TRUE;
} }
// STUB: LEGO1 0x100048c0 // FUNCTION: LEGO1 0x100048c0
GasStation::~GasStation() GasStation::~GasStation()
{ {
// TODO InputManager()->UnRegister(this);
if (InputManager()->GetWorld() == this) {
InputManager()->ClearWorld();
}
ControlManager()->Unregister(this);
TickleManager()->UnregisterClient(this);
NotificationManager()->Unregister(this);
g_unk0x100f0160 = 3;
} }
// STUB: LEGO1 0x10004990 // FUNCTION: LEGO1 0x10004990
MxResult GasStation::Create(MxDSAction& p_dsAction) MxResult GasStation::Create(MxDSAction& p_dsAction)
{ {
// TODO MxResult result = LegoWorld::Create(p_dsAction);
return SUCCESS; if (result == SUCCESS) {
InputManager()->SetWorld(this);
ControlManager()->Register(this);
}
InputManager()->SetCamera(NULL);
m_state = (GasStationState*) GameState()->GetState("GasStationState");
if (!m_state) {
m_state = (GasStationState*) GameState()->CreateState("GasStationState");
m_state->GetUnknown0x14().SetUnknown0x00(1);
}
else {
GasStationState::Unknown0x14& unk0x14 = m_state->GetUnknown0x14();
if (unk0x14.GetUnknown0x00() == 4) {
unk0x14.SetUnknown0x00(4);
}
else {
unk0x14.SetUnknown0x00(3);
}
}
GameState()->SetCurrentArea(LegoGameState::e_garage);
GameState()->StopArea(LegoGameState::e_previousArea);
InputManager()->Register(this);
SetIsWorldActive(FALSE);
return result;
} }
// STUB: LEGO1 0x10004a60 // STUB: LEGO1 0x10004a60
@ -52,10 +95,21 @@ void GasStation::ReadyWorld()
// TODO // TODO
} }
// STUB: LEGO1 0x10005c40 // FUNCTION: LEGO1 0x10005c40
void GasStation::Enable(MxBool p_enable) void GasStation::Enable(MxBool p_enable)
{ {
// TODO LegoWorld::Enable(p_enable);
if (p_enable) {
InputManager()->SetWorld(this);
InputManager()->SetCamera(NULL);
return;
}
else {
if (InputManager()->GetWorld() == this) {
InputManager()->ClearWorld();
}
}
} }
// STUB: LEGO1 0x10005c90 // STUB: LEGO1 0x10005c90