diff --git a/LEGO1/lego/legoomni/include/gasstation.h b/LEGO1/lego/legoomni/include/gasstation.h index f8709bc0..10a825ac 100644 --- a/LEGO1/lego/legoomni/include/gasstation.h +++ b/LEGO1/lego/legoomni/include/gasstation.h @@ -16,6 +16,19 @@ class MxStillPresenter; // SIZE 0x24 class GasStationState : public LegoState { public: + enum { + e_unknown0 = 0, + e_newState = 1, + e_beforeExitingForQuest = 2, + e_unknown3 = 3, + e_unknown4 = 4, + e_introduction = 5, + e_explainQuest = 6, + e_waitAcceptingQuest = 7, + e_afterAcceptingQuest = 8, + e_cancelQuest = 9, + }; + GasStationState(); // FUNCTION: LEGO1 0x100061d0 @@ -44,7 +57,7 @@ class GasStationState : public LegoState { // TODO: Most likely getters/setters are not used according to BETA. GarageScript::Script m_actions[3]; // 0x08 - undefined4 m_unk0x14; // 0x14 + MxS32 m_state; // 0x14 MxS16 m_pepperAction; // 0x18 MxS16 m_mamaAction; // 0x1a MxS16 m_papaAction; // 0x1c @@ -90,6 +103,13 @@ class GasStation : public LegoWorld { // GasStation::`scalar deleting destructor' private: + enum { + e_finished = 0, + e_start = 1, + e_started = 2, + e_canceled = 3, + }; + inline void PlayAction(GarageScript::Script p_objectId); inline void StopAction(GarageScript::Script p_objectId); @@ -101,13 +121,13 @@ class GasStation : public LegoWorld { undefined2 m_unk0xfa; // 0xfa LegoGameState::Area m_destLocation; // 0xfc GasStationState* m_state; // 0x100 - undefined2 m_unk0x104; // 0x104 - undefined2 m_unk0x106; // 0x106 + MxS16 m_waitingState; // 0x104 + MxS16 m_setWithCurrentAction; // 0x106 MxStillPresenter* m_trackLedBitmap; // 0x108 - MxLong m_unk0x10c; // 0x10c + MxLong m_lastIdleAnimation; // 0x10c MxLong m_trackLedTimer; // 0x110 - MxBool m_unk0x114; // 0x114 - MxBool m_unk0x115; // 0x115 + MxBool m_waiting; // 0x114 + MxBool m_flashingLeds; // 0x115 Radio m_radio; // 0x118 }; diff --git a/LEGO1/lego/legoomni/src/worlds/gasstation.cpp b/LEGO1/lego/legoomni/src/worlds/gasstation.cpp index 2c686464..0c356665 100644 --- a/LEGO1/lego/legoomni/src/worlds/gasstation.cpp +++ b/LEGO1/lego/legoomni/src/worlds/gasstation.cpp @@ -28,7 +28,7 @@ DECOMP_SIZE_ASSERT(GasStation, 0x128) DECOMP_SIZE_ASSERT(GasStationState, 0x24) // GLOBAL: LEGO1 0x100f0160 -undefined4 g_unk0x100f0160 = 3; +MxS32 g_animationSkipCounterGasStation = 3; // GLOBAL: LEGO1 0x100f0164 MxBool g_trackLedEnabled = FALSE; @@ -40,11 +40,11 @@ GasStation::GasStation() m_state = NULL; m_destLocation = LegoGameState::e_undefined; m_trackLedBitmap = NULL; - m_unk0x104 = 0; - m_unk0x114 = FALSE; - m_unk0x106 = 0; - m_unk0x10c = 0; - m_unk0x115 = FALSE; + m_waitingState = e_finished; + m_waiting = FALSE; + m_setWithCurrentAction = 0; + m_lastIdleAnimation = 0; + m_flashingLeds = FALSE; m_trackLedTimer = 0; NotificationManager()->Register(this); @@ -61,7 +61,7 @@ GasStation::~GasStation() ControlManager()->Unregister(this); TickleManager()->UnregisterClient(this); NotificationManager()->Unregister(this); - g_unk0x100f0160 = 3; + g_animationSkipCounterGasStation = 3; } // FUNCTION: LEGO1 0x10004990 @@ -79,13 +79,13 @@ MxResult GasStation::Create(MxDSAction& p_dsAction) m_state = (GasStationState*) GameState()->GetState("GasStationState"); if (!m_state) { m_state = (GasStationState*) GameState()->CreateState("GasStationState"); - m_state->m_unk0x14 = 1; + m_state->m_state = GasStationState::e_newState; } - else if (m_state->m_unk0x14 == 4) { - m_state->m_unk0x14 = 4; + else if (m_state->m_state == GasStationState::e_unknown4) { + m_state->m_state = GasStationState::e_unknown4; } else { - m_state->m_unk0x14 = 3; + m_state->m_state = GasStationState::e_unknown3; } GameState()->m_currentArea = LegoGameState::e_garage; @@ -141,25 +141,25 @@ void GasStation::ReadyWorld() case LegoActor::c_pepper: switch (m_state->m_pepperAction) { case 0: - m_state->m_unk0x14 = 5; + m_state->m_state = GasStationState::e_introduction; PlayAction(GarageScript::c_wgs002nu_RunAnim); - m_unk0x106 = 1; + m_setWithCurrentAction = 1; break; case 1: - m_state->m_unk0x14 = 5; + m_state->m_state = GasStationState::e_introduction; PlayAction(GarageScript::c_wgs003nu_RunAnim); - m_unk0x106 = 1; + m_setWithCurrentAction = 1; break; case 2: - m_state->m_unk0x14 = 5; + m_state->m_state = GasStationState::e_introduction; PlayAction(GarageScript::c_wgs004nu_RunAnim); - m_unk0x106 = 1; + m_setWithCurrentAction = 1; break; default: - m_state->m_unk0x14 = 6; + m_state->m_state = GasStationState::e_explainQuest; PlayAction(GarageScript::c_wgs008nu_RunAnim); - m_unk0x106 = 1; - m_unk0x104 = 1; + m_setWithCurrentAction = 1; + m_waitingState = e_start; break; } @@ -170,20 +170,20 @@ void GasStation::ReadyWorld() case LegoActor::c_mama: switch (m_state->m_mamaAction) { case 0: - m_state->m_unk0x14 = 5; + m_state->m_state = GasStationState::e_introduction; PlayAction(GarageScript::c_wgs006nu_RunAnim); - m_unk0x106 = 1; + m_setWithCurrentAction = 1; break; case 1: - m_state->m_unk0x14 = 5; + m_state->m_state = GasStationState::e_introduction; PlayAction(GarageScript::c_wgs007nu_RunAnim); - m_unk0x106 = 1; + m_setWithCurrentAction = 1; break; default: - m_state->m_unk0x14 = 6; + m_state->m_state = GasStationState::e_explainQuest; PlayAction(GarageScript::c_wgs008nu_RunAnim); - m_unk0x106 = 1; - m_unk0x104 = 1; + m_setWithCurrentAction = 1; + m_waitingState = e_start; break; } @@ -194,20 +194,20 @@ void GasStation::ReadyWorld() case LegoActor::c_nick: switch (m_state->m_nickAction) { case 0: - m_state->m_unk0x14 = 5; + m_state->m_state = GasStationState::e_introduction; PlayAction(GarageScript::c_wgs009nu_RunAnim); - m_unk0x106 = 1; + m_setWithCurrentAction = 1; break; case 1: - m_state->m_unk0x14 = 5; + m_state->m_state = GasStationState::e_introduction; PlayAction(GarageScript::c_wgs010nu_RunAnim); - m_unk0x106 = 1; + m_setWithCurrentAction = 1; break; default: - m_state->m_unk0x14 = 6; + m_state->m_state = GasStationState::e_explainQuest; PlayAction(GarageScript::c_wgs008nu_RunAnim); - m_unk0x106 = 1; - m_unk0x104 = 1; + m_setWithCurrentAction = 1; + m_waitingState = e_start; break; } @@ -218,20 +218,20 @@ void GasStation::ReadyWorld() case LegoActor::c_papa: switch (m_state->m_papaAction) { case 0: - m_state->m_unk0x14 = 5; + m_state->m_state = GasStationState::e_introduction; PlayAction(GarageScript::c_wgs012nu_RunAnim); - m_unk0x106 = 1; + m_setWithCurrentAction = 1; break; case 1: - m_state->m_unk0x14 = 5; + m_state->m_state = GasStationState::e_introduction; PlayAction(GarageScript::c_wgs014nu_RunAnim); - m_unk0x106 = 1; + m_setWithCurrentAction = 1; break; default: - m_state->m_unk0x14 = 6; + m_state->m_state = GasStationState::e_explainQuest; PlayAction(GarageScript::c_wgs017nu_RunAnim); - m_unk0x106 = 1; - m_unk0x104 = 1; + m_setWithCurrentAction = 1; + m_waitingState = e_start; break; } @@ -242,20 +242,20 @@ void GasStation::ReadyWorld() case LegoActor::c_laura: switch (m_state->m_lauraAction) { case 0: - m_state->m_unk0x14 = 5; + m_state->m_state = GasStationState::e_introduction; PlayAction(GarageScript::c_wgs020nu_RunAnim); - m_unk0x106 = 1; + m_setWithCurrentAction = 1; break; case 1: - m_state->m_unk0x14 = 5; + m_state->m_state = GasStationState::e_introduction; PlayAction(GarageScript::c_wgs021nu_RunAnim); - m_unk0x106 = 1; + m_setWithCurrentAction = 1; break; default: - m_state->m_unk0x14 = 6; + m_state->m_state = GasStationState::e_explainQuest; PlayAction(GarageScript::c_wgs022nu_RunAnim); - m_unk0x106 = 1; - m_unk0x104 = 1; + m_setWithCurrentAction = 1; + m_waitingState = e_start; break; } @@ -303,33 +303,33 @@ MxLong GasStation::HandleEndAction(MxEndActionNotificationParam& p_param) if (action->GetAtomId() == m_atomId && action->GetObjectId()) { m_state->StopAction((GarageScript::Script) action->GetObjectId()); - m_unk0x106 = 0; + m_setWithCurrentAction = 0; - switch (m_state->m_unk0x14) { - case 5: - g_unk0x100f0160 = 0; - m_state->m_unk0x14 = 6; - m_unk0x115 = TRUE; + switch (m_state->m_state) { + case GasStationState::e_introduction: + g_animationSkipCounterGasStation = 0; + m_state->m_state = GasStationState::e_explainQuest; + m_flashingLeds = TRUE; PlayAction(GarageScript::c_wgs023nu_RunAnim); - m_unk0x106 = 1; - m_unk0x104 = 1; + m_setWithCurrentAction = 1; + m_waitingState = e_start; break; - case 6: - g_unk0x100f0160 = 0; - m_unk0x115 = TRUE; + case GasStationState::e_explainQuest: + g_animationSkipCounterGasStation = 0; + m_flashingLeds = TRUE; - if (m_unk0x104 == 3) { - m_state->m_unk0x14 = 8; + if (m_waitingState == e_canceled) { + m_state->m_state = GasStationState::e_afterAcceptingQuest; PlayAction(GarageScript::c_wgs029nu_RunAnim); - m_unk0x106 = 1; + m_setWithCurrentAction = 1; } else { - m_state->m_unk0x14 = 7; - m_unk0x114 = TRUE; + m_state->m_state = GasStationState::e_waitAcceptingQuest; + m_waiting = TRUE; } break; - case 8: - m_state->m_unk0x14 = 2; + case GasStationState::e_afterAcceptingQuest: + m_state->m_state = GasStationState::e_beforeExitingForQuest; ((Act1State*) GameState()->GetState("Act1State"))->m_unk0x018 = 7; m_destLocation = LegoGameState::e_unk28; m_radio.Stop(); @@ -348,7 +348,7 @@ MxLong GasStation::HandleEndAction(MxEndActionNotificationParam& p_param) // FUNCTION: LEGO1 0x10005920 MxLong GasStation::HandleKeyPress(SDL_Keycode p_key) { - if (p_key == SDLK_SPACE && g_unk0x100f0160 == 0 && m_unk0x106 != 0) { + if (p_key == SDLK_SPACE && g_animationSkipCounterGasStation == 0 && m_setWithCurrentAction != 0) { m_state->StopActions(); return 1; } @@ -360,18 +360,18 @@ MxLong GasStation::HandleKeyPress(SDL_Keycode p_key) // FUNCTION: BETA10 0x10029319 MxLong GasStation::HandleButtonDown(LegoControlManagerNotificationParam& p_param) { - if (m_unk0x104 == 1 || m_unk0x104 == 2) { + if (m_waitingState == e_start || m_waitingState == e_started) { LegoROI* roi = PickROI(p_param.GetX(), p_param.GetY()); if (roi != NULL) { if (!SDL_strncasecmp(roi->GetName(), "capdb", 5) || !SDL_strncasecmp(roi->GetName(), "*capdb", 6)) { - m_unk0x104 = 3; - m_unk0x114 = FALSE; + m_waitingState = e_canceled; + m_waiting = FALSE; - if (m_state->m_unk0x14 == 7) { - m_state->m_unk0x14 = 8; + if (m_state->m_state == GasStationState::e_waitAcceptingQuest) { + m_state->m_state = GasStationState::e_afterAcceptingQuest; PlayAction(GarageScript::c_wgs029nu_RunAnim); - m_unk0x106 = 1; + m_setWithCurrentAction = 1; } else { StopAction(GarageScript::c_wgs023nu_RunAnim); @@ -395,7 +395,7 @@ MxLong GasStation::HandleControl(LegoControlManagerNotificationParam& p_param) switch (p_param.m_clickedObjectId) { case GarageScript::c_LeftArrow_Ctl: case GarageScript::c_RightArrow_Ctl: - m_state->m_unk0x14 = 0; + m_state->m_state = GasStationState::e_unknown0; m_destLocation = LegoGameState::Area::e_garadoor; m_state->StopActions(); @@ -404,7 +404,7 @@ MxLong GasStation::HandleControl(LegoControlManagerNotificationParam& p_param) TransitionManager()->StartTransition(MxTransitionManager::e_mosaic, 50, FALSE, FALSE); break; case GarageScript::c_Info_Ctl: - m_state->m_unk0x14 = 0; + m_state->m_state = GasStationState::e_unknown0; m_destLocation = LegoGameState::Area::e_infomain; m_state->StopActions(); @@ -413,7 +413,7 @@ MxLong GasStation::HandleControl(LegoControlManagerNotificationParam& p_param) TransitionManager()->StartTransition(MxTransitionManager::e_mosaic, 50, FALSE, FALSE); break; case GarageScript::c_Buggy_Ctl: - m_state->m_unk0x14 = 0; + m_state->m_state = GasStationState::e_unknown0; m_destLocation = LegoGameState::Area::e_dunecarbuild; m_state->StopActions(); @@ -453,29 +453,29 @@ MxResult GasStation::Tickle() return SUCCESS; } - if (g_unk0x100f0160 != 0) { - g_unk0x100f0160--; + if (g_animationSkipCounterGasStation != 0) { + g_animationSkipCounterGasStation--; } MxLong time = Timer()->GetTime(); - if (m_unk0x114) { - if (time - m_unk0x10c > 15000) { - m_unk0x10c = time; - if (m_unk0x104 == 1) { - m_unk0x104 = 2; + if (m_waiting) { + if (time - m_lastIdleAnimation > 15000) { + m_lastIdleAnimation = time; + if (m_waitingState == e_start) { + m_waitingState = e_started; } - else if (m_unk0x104 != 0) { - m_unk0x104 = 0; + else if (m_waitingState != e_finished) { + m_waitingState = e_finished; MxDSAction action; - m_state->m_unk0x14 = 9; + m_state->m_state = GasStationState::e_cancelQuest; PlayAction(GarageScript::c_wgs031nu_RunAnim); - m_unk0x106 = 1; + m_setWithCurrentAction = 1; } } } - if (m_unk0x115) { + if (m_flashingLeds) { if (time - m_trackLedTimer > 300) { m_trackLedTimer = time; g_trackLedEnabled = !g_trackLedEnabled; @@ -491,7 +491,7 @@ MxBool GasStation::Escape() { m_radio.Stop(); m_state->StopActions(); - m_state->m_unk0x14 = 0; + m_state->m_state = GasStationState::e_unknown0; m_destLocation = LegoGameState::Area::e_infomain; return TRUE; } diff --git a/LEGO1/lego/legoomni/src/worlds/hospital.cpp b/LEGO1/lego/legoomni/src/worlds/hospital.cpp index 523d5aaa..95171f22 100644 --- a/LEGO1/lego/legoomni/src/worlds/hospital.cpp +++ b/LEGO1/lego/legoomni/src/worlds/hospital.cpp @@ -26,7 +26,7 @@ DECOMP_SIZE_ASSERT(Hospital, 0x12c) DECOMP_SIZE_ASSERT(HospitalState, 0x18) // GLOBAL: LEGO1 0x100f7918 -undefined4 g_animationSkipCounter = 3; +undefined4 g_animationSkipCounterHospital = 3; // GLOBAL: LEGO1 0x100f791c MxBool g_copLedEnabled = FALSE; @@ -66,7 +66,7 @@ Hospital::~Hospital() m_hospitalState->m_state = HospitalState::e_unknown3; NotificationManager()->Unregister(this); - g_animationSkipCounter = 3; + g_animationSkipCounterHospital = 3; } // FUNCTION: LEGO1 0x100748c0 @@ -224,7 +224,7 @@ MxLong Hospital::HandleKeyPress(SDL_Keycode p_key) { MxLong result = 0; - if (p_key == SDLK_SPACE && g_animationSkipCounter == 0) { + if (p_key == SDLK_SPACE && g_animationSkipCounterHospital == 0) { DeleteObjects(&m_atomId, HospitalScript::c_hho002cl_RunAnim, HospitalScript::c_hho006cl_RunAnim); result = 1; } @@ -253,7 +253,7 @@ MxLong Hospital::HandleEndAction(MxEndActionNotificationParam& p_param) m_currentAction = HospitalScript::c_hho006cl_RunAnim; m_setWithCurrentAction = 1; m_flashingLeds = 1; - g_animationSkipCounter = 0; + g_animationSkipCounterHospital = 0; break; case HospitalState::e_explainQuestShort: m_time = Timer()->GetTime(); @@ -639,8 +639,8 @@ MxResult Hospital::Tickle() return SUCCESS; } - if (g_animationSkipCounter != 0) { - g_animationSkipCounter -= 1; + if (g_animationSkipCounterHospital != 0) { + g_animationSkipCounterHospital -= 1; } MxLong time = Timer()->GetTime(); diff --git a/LEGO1/lego/sources/roi/legolod.cpp b/LEGO1/lego/sources/roi/legolod.cpp index eb2402ef..5df9f732 100644 --- a/LEGO1/lego/sources/roi/legolod.cpp +++ b/LEGO1/lego/sources/roi/legolod.cpp @@ -18,7 +18,7 @@ DECOMP_SIZE_ASSERT(LegoLOD::Mesh, 0x08) LPDIRECT3DRMMATERIAL g_unk0x101013d4 = NULL; // GLOBAL: LEGO1 0x101013dc -const char* g_unk0x101013dc = "inh"; +const char* g_InhPrefix = "inh"; inline IDirect3DRM2* GetD3DRM(Tgl::Renderer* pRenderer); inline BOOL GetMeshData(IDirect3DRMMesh*& mesh, D3DRMGROUPINDEX& index, Tgl::Mesh* pMesh); @@ -68,7 +68,7 @@ LegoResult LegoLOD::Read(Tgl::Renderer* p_renderer, LegoTextureContainer* p_text LegoU32(*textureIndices)[3] = NULL; LegoTextureInfo* textureInfo = NULL; - LegoU32 i, meshUnd1, meshUnd2, tempNumVertsAndNormals; + LegoU32 i, indexBackwards, indexForwards, tempNumVertsAndNormals; unsigned char paletteEntries[256]; if (p_storage->Read(&m_unk0x08, sizeof(undefined4)) != SUCCESS) { @@ -95,8 +95,8 @@ LegoResult LegoLOD::Read(Tgl::Renderer* p_renderer, LegoTextureContainer* p_text m_melems = new Mesh[m_numMeshes]; memset(m_melems, 0, sizeof(*m_melems) * m_numMeshes); - meshUnd1 = m_numMeshes - 1; - meshUnd2 = 0; + indexBackwards = m_numMeshes - 1; + indexForwards = 0; if (p_storage->Read(&tempNumVertsAndNormals, sizeof(LegoU32)) != SUCCESS) { goto done; @@ -186,13 +186,13 @@ LegoResult LegoLOD::Read(Tgl::Renderer* p_renderer, LegoTextureContainer* p_text textureName = mesh->GetTextureName(); materialName = mesh->GetMaterialName(); - if (FUN_100aae20(textureName) || FUN_100aae20(materialName)) { - meshIndex = meshUnd1; - meshUnd1--; + if (HasInhPrefix(textureName) || HasInhPrefix(materialName)) { + meshIndex = indexBackwards; + indexBackwards--; } else { - meshIndex = meshUnd2; - meshUnd2++; + meshIndex = indexForwards; + indexForwards++; } m_melems[meshIndex].m_tglMesh = m_meshBuilder->CreateMesh( @@ -267,7 +267,7 @@ LegoResult LegoLOD::Read(Tgl::Renderer* p_renderer, LegoTextureContainer* p_text } } - m_meshOffset = meshUnd2; + m_meshOffset = indexForwards; if (textureVertices != NULL) { delete[] textureVertices; @@ -379,10 +379,10 @@ LegoResult LegoLOD::GetTextureInfo(LegoTextureInfo*& p_textureInfo) } // FUNCTION: LEGO1 0x100aae20 -LegoBool LegoLOD::FUN_100aae20(const LegoChar* p_name) +LegoBool LegoLOD::HasInhPrefix(const LegoChar* p_name) { if (p_name != NULL) { - if (!SDL_strncasecmp(p_name, g_unk0x101013dc, strlen(g_unk0x101013dc))) { + if (!SDL_strncasecmp(p_name, g_InhPrefix, strlen(g_InhPrefix))) { return TRUE; } } diff --git a/LEGO1/lego/sources/roi/legolod.h b/LEGO1/lego/sources/roi/legolod.h index 62ece564..114e377b 100644 --- a/LEGO1/lego/sources/roi/legolod.h +++ b/LEGO1/lego/sources/roi/legolod.h @@ -35,7 +35,7 @@ class LegoLOD : public ViewLOD { void ClearMeshOffset(); LegoResult GetTextureInfo(LegoTextureInfo*& p_textureInfo); - static LegoBool FUN_100aae20(const LegoChar* p_name); + static LegoBool HasInhPrefix(const LegoChar* p_name); // SYNTHETIC: LEGO1 0x100aa430 // LegoLOD::`scalar deleting destructor'