Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement/match remaining GasStation functions #1129

Merged
merged 2 commits into from
Nov 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions LEGO1/lego/legoomni/include/gasstation.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,19 @@ class GasStationState : public LegoState {
// SYNTHETIC: LEGO1 0x10006290
// GasStationState::`scalar deleting destructor'

void FUN_10006430(GarageScript::Script);
void FUN_10006460(GarageScript::Script);
void FUN_10006490();
void PlayAction(GarageScript::Script p_objectId);
void StopAction(GarageScript::Script p_objectId);
void StopActions();

// TODO: Most likely getters/setters are not used according to BETA.

undefined4 m_unk0x08[3]; // 0x08
Unknown0x14 m_unk0x14; // 0x14
MxS16 m_unk0x18; // 0x18
MxS16 m_unk0x1a; // 0x1a
MxS16 m_unk0x1c; // 0x1c
MxS16 m_unk0x1e; // 0x1e
MxS16 m_unk0x20; // 0x20
GarageScript::Script m_actions[3]; // 0x08
Unknown0x14 m_unk0x14; // 0x14
MxS16 m_pepperAction; // 0x18
MxS16 m_mamaAction; // 0x1a
MxS16 m_papaAction; // 0x1c
MxS16 m_nickAction; // 0x1e
MxS16 m_lauraAction; // 0x20
};

// VTABLE: LEGO1 0x100d4650
Expand Down
122 changes: 70 additions & 52 deletions LEGO1/lego/legoomni/src/worlds/gasstation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ void GasStation::ReadyWorld()

switch (m_currentActorId) {
case LegoActor::c_pepper:
switch (m_state->m_unk0x18) {
switch (m_state->m_pepperAction) {
case 0:
m_state->m_unk0x14.m_unk0x00 = 5;
PlayAction(GarageScript::c_wgs002nu_RunAnim);
Expand All @@ -162,14 +162,14 @@ void GasStation::ReadyWorld()
break;
}

if (m_state->m_unk0x18 < 5) {
m_state->m_unk0x18++;
if (m_state->m_pepperAction < 5) {
m_state->m_pepperAction++;
}

FUN_10015820(FALSE, LegoOmni::c_disableInput | LegoOmni::c_disable3d | LegoOmni::c_clearScreen);
break;
case LegoActor::c_mama:
switch (m_state->m_unk0x1a) {
switch (m_state->m_mamaAction) {
case 0:
m_state->m_unk0x14.m_unk0x00 = 5;
PlayAction(GarageScript::c_wgs006nu_RunAnim);
Expand All @@ -188,14 +188,14 @@ void GasStation::ReadyWorld()
break;
}

if (m_state->m_unk0x1a < 5) {
m_state->m_unk0x1a++;
if (m_state->m_mamaAction < 5) {
m_state->m_mamaAction++;
}

FUN_10015820(FALSE, LegoOmni::c_disableInput | LegoOmni::c_disable3d | LegoOmni::c_clearScreen);
break;
case LegoActor::c_papa:
switch (m_state->m_unk0x1c) {
switch (m_state->m_papaAction) {
case 0:
m_state->m_unk0x14.m_unk0x00 = 5;
PlayAction(GarageScript::c_wgs012nu_RunAnim);
Expand All @@ -214,14 +214,14 @@ void GasStation::ReadyWorld()
break;
}

if (m_state->m_unk0x1c < 5) {
m_state->m_unk0x1c++;
if (m_state->m_papaAction < 5) {
m_state->m_papaAction++;
}

FUN_10015820(FALSE, LegoOmni::c_disableInput | LegoOmni::c_disable3d | LegoOmni::c_clearScreen);
break;
case LegoActor::c_nick:
switch (m_state->m_unk0x1e) {
switch (m_state->m_nickAction) {
case 0:
m_state->m_unk0x14.m_unk0x00 = 5;
PlayAction(GarageScript::c_wgs009nu_RunAnim);
Expand All @@ -240,14 +240,14 @@ void GasStation::ReadyWorld()
break;
}

if (m_state->m_unk0x1e < 5) {
m_state->m_unk0x1e++;
if (m_state->m_nickAction < 5) {
m_state->m_nickAction++;
}

FUN_10015820(FALSE, LegoOmni::c_disableInput | LegoOmni::c_disable3d | LegoOmni::c_clearScreen);
break;
case LegoActor::c_laura:
switch (m_state->m_unk0x20) {
switch (m_state->m_lauraAction) {
case 0:
m_state->m_unk0x14.m_unk0x00 = 5;
PlayAction(GarageScript::c_wgs020nu_RunAnim);
Expand All @@ -266,8 +266,8 @@ void GasStation::ReadyWorld()
break;
}

if (m_state->m_unk0x20 < 5) {
m_state->m_unk0x20++;
if (m_state->m_lauraAction < 5) {
m_state->m_lauraAction++;
}

FUN_10015820(FALSE, LegoOmni::c_disableInput | LegoOmni::c_disable3d | LegoOmni::c_clearScreen);
Expand All @@ -288,7 +288,7 @@ inline void GasStation::PlayAction(GarageScript::Script p_objectId)

BackgroundAudioManager()->LowerVolume();
Start(&action);
m_state->FUN_10006430(p_objectId);
m_state->PlayAction(p_objectId);
}

// FUNCTION: BETA10 0x10029f00
Expand All @@ -297,7 +297,7 @@ inline void GasStation::StopAction(GarageScript::Script p_objectId)
if (p_objectId != GarageScript::c_noneGarage) {
InvokeAction(Extra::e_stop, *g_garageScript, p_objectId, NULL);
BackgroundAudioManager()->RaiseVolume();
m_state->FUN_10006460(p_objectId);
m_state->StopAction(p_objectId);
}
}

Expand All @@ -310,7 +310,7 @@ MxLong GasStation::HandleEndAction(MxEndActionNotificationParam& p_param)
MxDSAction* action = p_param.GetAction();

if (action->GetAtomId() == m_atomId && action->GetObjectId()) {
m_state->FUN_10006460((GarageScript::Script) action->GetObjectId());
m_state->StopAction((GarageScript::Script) action->GetObjectId());
m_unk0x106 = 0;

switch (m_state->m_unk0x14.m_unk0x00) {
Expand Down Expand Up @@ -357,7 +357,7 @@ MxLong GasStation::HandleEndAction(MxEndActionNotificationParam& p_param)
MxLong GasStation::HandleKeyPress(MxS8 p_key)
{
if (p_key == VK_SPACE && g_unk0x100f0160 == 0 && m_unk0x106 != 0) {
m_state->FUN_10006490();
m_state->StopActions();
return 1;
}

Expand Down Expand Up @@ -394,6 +394,7 @@ MxLong GasStation::HandleButtonDown(LegoControlManagerNotificationParam& p_param
}

// FUNCTION: LEGO1 0x10005b20
// FUNCTION: BETA10 0x10029445
MxLong GasStation::HandleControl(LegoControlManagerNotificationParam& p_param)
{
if (p_param.GetUnknown0x28() == 1) {
Expand All @@ -405,7 +406,7 @@ MxLong GasStation::HandleControl(LegoControlManagerNotificationParam& p_param)
m_state->m_unk0x14.m_unk0x00 = 0;
m_destLocation = LegoGameState::Area::e_garadoor;

m_state->FUN_10006490();
m_state->StopActions();
m_radio.Stop();
BackgroundAudioManager()->Stop();
TransitionManager()->StartTransition(MxTransitionManager::e_mosaic, 50, FALSE, FALSE);
Expand All @@ -414,7 +415,7 @@ MxLong GasStation::HandleControl(LegoControlManagerNotificationParam& p_param)
m_state->m_unk0x14.m_unk0x00 = 0;
m_destLocation = LegoGameState::Area::e_infomain;

m_state->FUN_10006490();
m_state->StopActions();
m_radio.Stop();
BackgroundAudioManager()->Stop();
TransitionManager()->StartTransition(MxTransitionManager::e_mosaic, 50, FALSE, FALSE);
Expand All @@ -423,7 +424,7 @@ MxLong GasStation::HandleControl(LegoControlManagerNotificationParam& p_param)
m_state->m_unk0x14.m_unk0x00 = 0;
m_destLocation = LegoGameState::Area::e_dunecarbuild;

m_state->FUN_10006490();
m_state->StopActions();
m_radio.Stop();
BackgroundAudioManager()->Stop();
TransitionManager()->StartTransition(MxTransitionManager::e_mosaic, 50, FALSE, FALSE);
Expand All @@ -435,6 +436,7 @@ MxLong GasStation::HandleControl(LegoControlManagerNotificationParam& p_param)
}

// FUNCTION: LEGO1 0x10005c40
// FUNCTION: BETA10 0x10029551
void GasStation::Enable(MxBool p_enable)
{
LegoWorld::Enable(p_enable);
Expand All @@ -451,6 +453,7 @@ void GasStation::Enable(MxBool p_enable)
}

// FUNCTION: LEGO1 0x10005c90
// FUNCTION: BETA10 0x100295c6
MxResult GasStation::Tickle()
{
if (!m_worldStarted) {
Expand Down Expand Up @@ -495,64 +498,79 @@ MxResult GasStation::Tickle()
MxBool GasStation::Escape()
{
m_radio.Stop();
m_state->FUN_10006490();
m_state->StopActions();
m_state->m_unk0x14.m_unk0x00 = 0;
m_destLocation = LegoGameState::Area::e_infomain;
return TRUE;
}

// FUNCTION: LEGO1 0x10005eb0
// FUNCTION: BETA10 0x100296b8
GasStationState::GasStationState()
{
m_unk0x18 = 0;
m_unk0x1a = 0;
m_unk0x1c = 0;
m_unk0x1e = 0;
m_unk0x20 = 0;

undefined4* unk0x08 = m_unk0x08;
unk0x08[0] = -1;
unk0x08[1] = -1;
unk0x08[2] = -1;
m_pepperAction = 0;
m_mamaAction = 0;
m_papaAction = 0;
m_nickAction = 0;
m_lauraAction = 0;
memset(m_actions, GarageScript::c_noneGarage, sizeof(m_actions));
}

// FUNCTION: LEGO1 0x10006300
// FUNCTION: BETA10 0x10029754
MxResult GasStationState::Serialize(LegoFile* p_file)
{
LegoState::Serialize(p_file);

if (p_file->IsWriteMode()) {
Write(p_file, m_unk0x18);
Write(p_file, m_unk0x1a);
Write(p_file, m_unk0x1c);
Write(p_file, m_unk0x1e);
Write(p_file, m_unk0x20);
Write(p_file, m_pepperAction);
Write(p_file, m_mamaAction);
Write(p_file, m_papaAction);
Write(p_file, m_nickAction);
Write(p_file, m_lauraAction);
}
else if (p_file->IsReadMode()) {
Read(p_file, &m_unk0x18);
Read(p_file, &m_unk0x1a);
Read(p_file, &m_unk0x1c);
Read(p_file, &m_unk0x1e);
Read(p_file, &m_unk0x20);
Read(p_file, &m_pepperAction);
Read(p_file, &m_mamaAction);
Read(p_file, &m_papaAction);
Read(p_file, &m_nickAction);
Read(p_file, &m_lauraAction);
}

return SUCCESS;
}

// STUB: LEGO1 0x10006430
void GasStationState::FUN_10006430(GarageScript::Script)
// FUNCTION: LEGO1 0x10006430
void GasStationState::PlayAction(GarageScript::Script p_objectId)
{
// TODO
for (MxS32 i = 0; i < (MxS32) sizeOfArray(m_actions); i++) {
if (m_actions[i] == GarageScript::c_noneGarage) {
m_actions[i] = p_objectId;
return;
}
}
}

// STUB: LEGO1 0x10006460
void GasStationState::FUN_10006460(GarageScript::Script)
// FUNCTION: LEGO1 0x10006460
void GasStationState::StopAction(GarageScript::Script p_objectId)
{
// TODO
for (MxS32 i = 0; i < (MxS32) sizeOfArray(m_actions); i++) {
if (m_actions[i] == p_objectId) {
m_actions[i] = GarageScript::c_noneGarage;
return;
}
}
}

// STUB: LEGO1 0x10006490
void GasStationState::FUN_10006490()
// FUNCTION: LEGO1 0x10006490
void GasStationState::StopActions()
{
// TODO
for (MxS32 i = 0; i < (MxS32) sizeOfArray(m_actions); i++) {
if (m_actions[i] != GarageScript::c_noneGarage) {
InvokeAction(Extra::e_stop, *g_garageScript, m_actions[i], NULL);
m_actions[i] = GarageScript::c_noneGarage;
}
}

BackgroundAudioManager()->RaiseVolume();
}
Loading