From bebe780c772316756539a0c10730ece227c1e5b7 Mon Sep 17 00:00:00 2001 From: Christian Semmler Date: Mon, 11 Nov 2024 10:48:45 -0700 Subject: [PATCH] Implement/match LegoAct2::Create (#1146) --- LEGO1/lego/legoomni/include/legoact2.h | 2 +- LEGO1/lego/legoomni/src/worlds/legoact2.cpp | 46 +++++++++++++++++++-- 2 files changed, 44 insertions(+), 4 deletions(-) diff --git a/LEGO1/lego/legoomni/include/legoact2.h b/LEGO1/lego/legoomni/include/legoact2.h index 3f8b65ef..7482f0ce 100644 --- a/LEGO1/lego/legoomni/include/legoact2.h +++ b/LEGO1/lego/legoomni/include/legoact2.h @@ -78,7 +78,7 @@ class LegoAct2 : public LegoWorld { undefined m_unk0x10c2; // 0x10c2 undefined4 m_unk0x10c4; // 0x10c4 undefined4 m_unk0x10c8; // 0x10c8 - undefined4 m_unk0x10cc; // 0x10cc + LegoAct2State* m_gameState; // 0x10cc undefined4 m_unk0x10d0; // 0x10d0 char* m_unk0x10d4; // 0x10d4 undefined4 m_unk0x10d8; // 0x10d8 diff --git a/LEGO1/lego/legoomni/src/worlds/legoact2.cpp b/LEGO1/lego/legoomni/src/worlds/legoact2.cpp index 523cee3c..a11b63b6 100644 --- a/LEGO1/lego/legoomni/src/worlds/legoact2.cpp +++ b/LEGO1/lego/legoomni/src/worlds/legoact2.cpp @@ -1,6 +1,7 @@ #include "legoact2.h" #include "legoanimationmanager.h" +#include "legogamestate.h" #include "legoinputmanager.h" #include "misc.h" #include "mxmisc.h" @@ -40,11 +41,50 @@ LegoAct2::~LegoAct2() NotificationManager()->Unregister(this); } -// STUB: LEGO1 0x1004ff20 +// FUNCTION: LEGO1 0x1004ff20 +// FUNCTION: BETA10 0x1003a7ff MxResult LegoAct2::Create(MxDSAction& p_dsAction) { - // TODO - return SUCCESS; + GameState()->FindLoadedAct(); + + MxResult result = LegoWorld::Create(p_dsAction); + if (result == SUCCESS) { + AnimationManager()->EnableCamAnims(FALSE); + + LegoGameState* gameState = GameState(); + LegoAct2State* state = (LegoAct2State*) gameState->GetState("LegoAct2State"); + + if (state == NULL) { + state = (LegoAct2State*) gameState->CreateState("LegoAct2State"); + } + + m_gameState = state; + m_gameState->m_unk0x08 = 0; + + switch (GameState()->GetLoadedAct()) { + case LegoGameState::e_act2: + GameState()->StopArea(LegoGameState::e_infomain); + GameState()->StopArea(LegoGameState::e_act2main); + break; + case LegoGameState::e_act3: + GameState()->StopArea(LegoGameState::e_infomain); + GameState()->StopArea(LegoGameState::e_act3script); + break; + case LegoGameState::e_act1: + case LegoGameState::e_actNotFound: + GameState()->StopArea(LegoGameState::e_undefined); + if (GameState()->GetPreviousArea() == LegoGameState::e_infomain) { + GameState()->StopArea(LegoGameState::e_isle); + } + } + + GameState()->m_currentArea = LegoGameState::e_act2main; + GameState()->SetCurrentAct(LegoGameState::e_act2); + InputManager()->Register(this); + GameState()->SetDirty(TRUE); + } + + return result; } // STUB: LEGO1 0x10050040