From a29c0aca3f3133a99905191613b203272727c53a Mon Sep 17 00:00:00 2001 From: Christian Semmler Date: Sat, 10 Feb 2024 20:52:16 -0500 Subject: [PATCH] Implement/match LegoOmni::Create (#556) * Implement/match LegoOmni::Create * Fix var * Rename * Fix style --- CMakeLists.txt | 1 + LEGO1/lego/legoomni/include/gifmanager.h | 2 + .../legoomni/include/legoanimationmanager.h | 2 + .../legoomni/include/legobuildingmanager.h | 3 + LEGO1/lego/legoomni/include/legoomni.h | 1 + .../lego/legoomni/include/legoplantmanager.h | 2 + .../legoomni/include/legounksavedatawriter.h | 6 + LEGO1/lego/legoomni/include/legovariables.h | 47 +++++++ LEGO1/lego/legoomni/include/legoworldlist.h | 3 + .../src/build/legobuildingmanager.cpp | 2 + .../legoomni/src/common/legoplantmanager.cpp | 2 + .../src/common/legounksavedatawriter.cpp | 9 +- .../legoomni/src/common/legovariables.cpp | 40 ++++++ .../src/infocenter/elevatorbottom.cpp | 7 +- LEGO1/lego/legoomni/src/main/legoomni.cpp | 123 ++++++++++++------ .../src/video/legoanimationmanager.cpp | 2 + LEGO1/omni/include/mxvariable.h | 6 +- 17 files changed, 208 insertions(+), 50 deletions(-) create mode 100644 LEGO1/lego/legoomni/include/legovariables.h create mode 100644 LEGO1/lego/legoomni/src/common/legovariables.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index d5322d6e..28c99a62 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -292,6 +292,7 @@ add_library(lego1 SHARED LEGO1/lego/legoomni/src/common/legostate.cpp LEGO1/lego/legoomni/src/common/legounksavedatawriter.cpp LEGO1/lego/legoomni/src/common/legoutil.cpp + LEGO1/lego/legoomni/src/common/legovariables.cpp LEGO1/lego/legoomni/src/common/mxcompositemediapresenter.cpp LEGO1/lego/legoomni/src/control/legocontrolmanager.cpp LEGO1/lego/legoomni/src/control/mxcontrolpresenter.cpp diff --git a/LEGO1/lego/legoomni/include/gifmanager.h b/LEGO1/lego/legoomni/include/gifmanager.h index ce600a62..5fec6013 100644 --- a/LEGO1/lego/legoomni/include/gifmanager.h +++ b/LEGO1/lego/legoomni/include/gifmanager.h @@ -64,6 +64,8 @@ class GifManagerBase { return NULL; } + inline void SetOwnership(MxBool p_ownership) { m_ownership = p_ownership; } + // SYNTHETIC: LEGO1 0x1005a310 // GifManagerBase::`scalar deleting destructor' diff --git a/LEGO1/lego/legoomni/include/legoanimationmanager.h b/LEGO1/lego/legoomni/include/legoanimationmanager.h index 94cb5b86..ed40b398 100644 --- a/LEGO1/lego/legoomni/include/legoanimationmanager.h +++ b/LEGO1/lego/legoomni/include/legoanimationmanager.h @@ -42,6 +42,8 @@ class LegoAnimationManager : public MxCore { private: void Init(); + + undefined m_unk0x08[0x4f8]; // 0x08 }; #endif // LEGOANIMATIONMANAGER_H diff --git a/LEGO1/lego/legoomni/include/legobuildingmanager.h b/LEGO1/lego/legoomni/include/legobuildingmanager.h index 98ccf373..f603b5dd 100644 --- a/LEGO1/lego/legoomni/include/legobuildingmanager.h +++ b/LEGO1/lego/legoomni/include/legobuildingmanager.h @@ -1,6 +1,7 @@ #ifndef LEGOBUILDINGMANAGER_H #define LEGOBUILDINGMANAGER_H +#include "decomp.h" #include "mxcore.h" // VTABLE: LEGO1 0x100d6f50 @@ -30,6 +31,8 @@ class LegoBuildingManager : public MxCore { private: void Init(); + + undefined m_unk0x08[0x28]; // 0x08 }; #endif // LEGOBUILDINGMANAGER_H diff --git a/LEGO1/lego/legoomni/include/legoomni.h b/LEGO1/lego/legoomni/include/legoomni.h index 36cacb70..07633479 100644 --- a/LEGO1/lego/legoomni/include/legoomni.h +++ b/LEGO1/lego/legoomni/include/legoomni.h @@ -104,6 +104,7 @@ class LegoOmni : public MxOmni { void FUN_1005b4f0(MxBool p_disable, MxU16 p_flags); void CreateBackgroundAudio(); void RemoveWorld(const MxAtomId&, MxLong); + MxResult FUN_1005a5f0(); undefined4 FUN_1005b490(char* p_worldName); static MxS32 GetCurrPathInfo(LegoPathBoundary**, MxS32&); diff --git a/LEGO1/lego/legoomni/include/legoplantmanager.h b/LEGO1/lego/legoomni/include/legoplantmanager.h index 686a5a35..1f67a72d 100644 --- a/LEGO1/lego/legoomni/include/legoplantmanager.h +++ b/LEGO1/lego/legoomni/include/legoplantmanager.h @@ -29,6 +29,8 @@ class LegoPlantManager : public MxCore { private: void Init(); + + undefined m_unk0x08[0x24]; // 0x08 }; #endif // LEGOPLANTMANAGER_H diff --git a/LEGO1/lego/legoomni/include/legounksavedatawriter.h b/LEGO1/lego/legoomni/include/legounksavedatawriter.h index 413e7ed8..dd15339a 100644 --- a/LEGO1/lego/legoomni/include/legounksavedatawriter.h +++ b/LEGO1/lego/legoomni/include/legounksavedatawriter.h @@ -33,12 +33,18 @@ struct LegoSaveDataEntry3 { MxU8 m_savePart10; // 0x104 }; +// SIZE 0x08 class LegoUnkSaveDataWriter { public: + LegoUnkSaveDataWriter(); + MxResult WriteSaveData3(LegoStorage* p_stream); AutoROI* FUN_10083500(undefined4, undefined4); void FUN_100832a0(); void FUN_10083db0(LegoROI* p_roi); + +private: + undefined m_unk0x00[0x08]; // 0x00 }; #endif // LEGOUNKSAVEDATAWRITER_H diff --git a/LEGO1/lego/legoomni/include/legovariables.h b/LEGO1/lego/legoomni/include/legovariables.h new file mode 100644 index 00000000..2116c564 --- /dev/null +++ b/LEGO1/lego/legoomni/include/legovariables.h @@ -0,0 +1,47 @@ +#ifndef LEGOVARIABLES_H +#define LEGOVARIABLES_H + +#include "mxvariable.h" + +extern const char* g_varVISIBILITY; +extern const char* g_varCAMERALOCATION; +extern const char* g_varCURSOR; +extern const char* g_varWHOAMI; + +// VTABLE: LEGO1 0x100d86c8 +// SIZE 0x24 +class VisibilityVariable : public MxVariable { +public: + VisibilityVariable() { m_key = g_varVISIBILITY; } + + void SetValue(const char* p_value) override; // vtable+0x04 +}; + +// VTABLE: LEGO1 0x100d86b8 +// SIZE 0x24 +class CameraLocationVariable : public MxVariable { +public: + CameraLocationVariable() { m_key = g_varCAMERALOCATION; } + + void SetValue(const char* p_value) override; // vtable+0x04 +}; + +// VTABLE: LEGO1 0x100d86a8 +// SIZE 0x24 +class CursorVariable : public MxVariable { +public: + CursorVariable() { m_key = g_varCURSOR; } + + void SetValue(const char* p_value) override; // vtable+0x04 +}; + +// VTABLE: LEGO1 0x100d8698 +// SIZE 0x24 +class WhoAmIVariable : public MxVariable { +public: + WhoAmIVariable() { m_key = g_varWHOAMI; } + + void SetValue(const char* p_value) override; // vtable+0x04 +}; + +#endif // LEGOVARIABLES_H diff --git a/LEGO1/lego/legoomni/include/legoworldlist.h b/LEGO1/lego/legoomni/include/legoworldlist.h index bd8197bc..577d310f 100644 --- a/LEGO1/lego/legoomni/include/legoworldlist.h +++ b/LEGO1/lego/legoomni/include/legoworldlist.h @@ -74,6 +74,9 @@ class LegoWorldListCursor : public MxPtrListCursor { // TEMPLATE: LEGO1 0x100599f0 // MxPtrList::Destroy +// TEMPLATE: LEGO1 0x10059a70 +// MxPtrList::~MxPtrList + // SYNTHETIC: LEGO1 0x10059ac0 // MxCollection::`scalar deleting destructor' diff --git a/LEGO1/lego/legoomni/src/build/legobuildingmanager.cpp b/LEGO1/lego/legoomni/src/build/legobuildingmanager.cpp index 3776638c..8ec95f44 100644 --- a/LEGO1/lego/legoomni/src/build/legobuildingmanager.cpp +++ b/LEGO1/lego/legoomni/src/build/legobuildingmanager.cpp @@ -1,5 +1,7 @@ #include "legobuildingmanager.h" +DECOMP_SIZE_ASSERT(LegoBuildingManager, 0x30) + // GLOBAL: LEGO1 0x100f37cc int g_buildingManagerConfig = 1; diff --git a/LEGO1/lego/legoomni/src/common/legoplantmanager.cpp b/LEGO1/lego/legoomni/src/common/legoplantmanager.cpp index 56bf518f..e8c5e097 100644 --- a/LEGO1/lego/legoomni/src/common/legoplantmanager.cpp +++ b/LEGO1/lego/legoomni/src/common/legoplantmanager.cpp @@ -1,5 +1,7 @@ #include "legoplantmanager.h" +DECOMP_SIZE_ASSERT(LegoPlantManager, 0x2c) + // FUNCTION: LEGO1 0x10026220 LegoPlantManager::LegoPlantManager() { diff --git a/LEGO1/lego/legoomni/src/common/legounksavedatawriter.cpp b/LEGO1/lego/legoomni/src/common/legounksavedatawriter.cpp index 619362ab..499a9af7 100644 --- a/LEGO1/lego/legoomni/src/common/legounksavedatawriter.cpp +++ b/LEGO1/lego/legoomni/src/common/legounksavedatawriter.cpp @@ -3,11 +3,18 @@ #include "legogamestate.h" #include "roi/legoroi.h" -DECOMP_SIZE_ASSERT(LegoSaveDataEntry3, 0x108); +DECOMP_SIZE_ASSERT(LegoUnkSaveDataWriter, 0x08) +DECOMP_SIZE_ASSERT(LegoSaveDataEntry3, 0x108) // GLOBAL: LEGO1 0x10104f20 LegoSaveDataEntry3 g_saveData3[66]; +// STUB: LEGO1 0x10082a20 +LegoUnkSaveDataWriter::LegoUnkSaveDataWriter() +{ + // TODO +} + // STUB: LEGO1 0x100832a0 void LegoUnkSaveDataWriter::FUN_100832a0() { diff --git a/LEGO1/lego/legoomni/src/common/legovariables.cpp b/LEGO1/lego/legoomni/src/common/legovariables.cpp new file mode 100644 index 00000000..f69bfcd3 --- /dev/null +++ b/LEGO1/lego/legoomni/src/common/legovariables.cpp @@ -0,0 +1,40 @@ +#include "legovariables.h" + +// GLOBAL: LEGO1 0x100f3a40 +// STRING: LEGO1 0x100f3808 +const char* g_varVISIBILITY = "VISIBILITY"; + +// GLOBAL: LEGO1 0x100f3a44 +// STRING: LEGO1 0x100f3a30 +const char* g_varCAMERALOCATION = "CAMERA_LOCATION"; + +// GLOBAL: LEGO1 0x100f3a48 +// STRING: LEGO1 0x100f3a28 +const char* g_varCURSOR = "CURSOR"; + +// GLOBAL: LEGO1 0x100f3a4c +// STRING: LEGO1 0x100f3a1c +const char* g_varWHOAMI = "WHO_AM_I"; + +// STUB: LEGO1 0x10037d00 +void VisibilityVariable::SetValue(const char* p_value) +{ + // TODO +} + +// STUB: LEGO1 0x10037d80 +void CameraLocationVariable::SetValue(const char* p_value) +{ + // TODO +} + +// FUNCTION: LEGO1 0x10037e30 +void CursorVariable::SetValue(const char* p_value) +{ +} + +// STUB: LEGO1 0x10037e40 +void WhoAmIVariable::SetValue(const char* p_value) +{ + // TODO +} diff --git a/LEGO1/lego/legoomni/src/infocenter/elevatorbottom.cpp b/LEGO1/lego/legoomni/src/infocenter/elevatorbottom.cpp index 24a7c2e5..5ef0d580 100644 --- a/LEGO1/lego/legoomni/src/infocenter/elevatorbottom.cpp +++ b/LEGO1/lego/legoomni/src/infocenter/elevatorbottom.cpp @@ -6,16 +6,13 @@ #include "legogamestate.h" #include "legoinputmanager.h" #include "legoomni.h" +#include "legovariables.h" #include "mxnotificationmanager.h" #include "mxomni.h" #include "mxtransitionmanager.h" DECOMP_SIZE_ASSERT(ElevatorBottom, 0xfc) -// STRING: LEGO1 0x100f0d34 -// GLOBAL: LEGO1 0x100f3a44 -const char* g_cameraLoc = "CAMERA_LOCATION"; - // FUNCTION: LEGO1 0x10017e90 ElevatorBottom::ElevatorBottom() { @@ -106,7 +103,7 @@ MxLong ElevatorBottom::HandleClick(LegoControlManagerEvent& p_param) state->SetUnknown1c(1); m_unk0xf8 = LegoGameState::e_unk6; TransitionManager()->StartTransition(MxTransitionManager::e_pixelation, 50, FALSE, FALSE); - VariableTable()->SetVariable(g_cameraLoc, "LCAMZI1,90"); + VariableTable()->SetVariable(g_varCAMERALOCATION, "LCAMZI1,90"); result = 1; break; } diff --git a/LEGO1/lego/legoomni/src/main/legoomni.cpp b/LEGO1/lego/legoomni/src/main/legoomni.cpp index 08ea6368..621b8aaa 100644 --- a/LEGO1/lego/legoomni/src/main/legoomni.cpp +++ b/LEGO1/lego/legoomni/src/main/legoomni.cpp @@ -10,6 +10,7 @@ #include "legosoundmanager.h" #include "legounksavedatawriter.h" #include "legoutil.h" +#include "legovariables.h" #include "legovideomanager.h" #include "legoworld.h" #include "legoworldlist.h" @@ -532,70 +533,110 @@ MxResult LegoOmni::Create(MxOmniCreateParam& p_param) p_param.CreateFlags().CreateTickleManager(FALSE); if (!(m_tickleManager = new MxTickleManager())) { - return FAILURE; + goto done; } if (MxOmni::Create(p_param) != SUCCESS) { - return FAILURE; + goto done; } - m_objectFactory = new LegoObjectFactory(); - if (m_objectFactory == NULL) { - return FAILURE; + if (!(m_objectFactory = new LegoObjectFactory())) { + goto done; } - if ((m_soundManager = new LegoSoundManager())) { - if (m_soundManager->Create(10, 0) != SUCCESS) { - delete m_soundManager; - m_soundManager = NULL; - return FAILURE; - } + if (!(m_soundManager = new LegoSoundManager()) || m_soundManager->Create(10, 0) != SUCCESS) { + delete m_soundManager; + m_soundManager = NULL; + goto done; } - if ((m_videoManager = new LegoVideoManager())) { - if (m_videoManager->Create(p_param.GetVideoParam(), 100, 0) != SUCCESS) { - delete m_videoManager; - m_videoManager = NULL; - } + if (!(m_videoManager = new LegoVideoManager()) || + m_videoManager->Create(p_param.GetVideoParam(), 100, 0) != SUCCESS) { + delete m_videoManager; + m_videoManager = NULL; + goto done; } - if ((m_inputMgr = new LegoInputManager())) { - if (m_inputMgr->Create(p_param.GetWindowHandle()) != SUCCESS) { - delete m_inputMgr; - m_inputMgr = NULL; - } + if (!(m_inputMgr = new LegoInputManager()) || m_inputMgr->Create(p_param.GetWindowHandle()) != SUCCESS) { + delete m_inputMgr; + m_inputMgr = NULL; + goto done; } m_viewLODListManager = new ViewLODListManager(); m_gifManager = new GifManager(); - // TODO: there is another class here + m_gifManager->SetOwnership(FALSE); + // FUN_10046c10 + + m_saveDataWriter = new LegoUnkSaveDataWriter(); m_plantManager = new LegoPlantManager(); m_animationManager = new LegoAnimationManager(); m_buildingManager = new LegoBuildingManager(); m_gameState = new LegoGameState(); m_worldList = new LegoWorldList(TRUE); - if (m_viewLODListManager && m_gifManager && m_worldList && m_plantManager && m_animationManager && - m_buildingManager) { - // TODO: initialize a bunch of MxVariables - RegisterScripts(); - FUN_1001a700(); - // todo: another function call. in legoomni maybe? - m_bkgAudioManager = new MxBackgroundAudioManager(); - if (m_bkgAudioManager != NULL) { - m_transitionManager = new MxTransitionManager(); - if (m_transitionManager != NULL) { - if (m_transitionManager->GetDDrawSurfaceFromVideoManager() == SUCCESS) { - m_notificationManager->Register(this); - SetAppCursor(1); - m_gameState->SetCurrentAct(LegoGameState::e_act1); - return SUCCESS; - } - } - } + if (!m_viewLODListManager || !m_gifManager || !m_worldList || !m_saveDataWriter || !m_plantManager || + !m_animationManager || !m_buildingManager) { + goto done; } - return FAILURE; + MxVariable* variable; + + if (!(variable = new VisibilityVariable())) { + goto done; + } + m_variableTable->SetVariable(variable); + + if (!(variable = new CameraLocationVariable())) { + goto done; + } + m_variableTable->SetVariable(variable); + + if (!(variable = new CursorVariable())) { + goto done; + } + m_variableTable->SetVariable(variable); + + if (!(variable = new WhoAmIVariable())) { + goto done; + } + m_variableTable->SetVariable(variable); + + RegisterScripts(); + FUN_1001a700(); + result = FUN_1005a5f0(); + + if (result != SUCCESS) { + goto done; + } + + if (!(m_bkgAudioManager = new MxBackgroundAudioManager())) { + goto done; + } + + if (!(m_transitionManager = new MxTransitionManager())) { + goto done; + } + + if (m_transitionManager->GetDDrawSurfaceFromVideoManager() != SUCCESS) { + goto done; + } + + m_notificationManager->Register(this); + SetAppCursor(1); + m_gameState->SetCurrentAct(LegoGameState::e_act1); + + result = SUCCESS; + +done: + return result; +} + +// STUB: LEGO1 0x1005a5f0 +MxResult LegoOmni::FUN_1005a5f0() +{ + // TODO + return SUCCESS; } // FUNCTION: LEGO1 0x1005ac90 diff --git a/LEGO1/lego/legoomni/src/video/legoanimationmanager.cpp b/LEGO1/lego/legoomni/src/video/legoanimationmanager.cpp index 0b10ed24..30c6d16f 100644 --- a/LEGO1/lego/legoomni/src/video/legoanimationmanager.cpp +++ b/LEGO1/lego/legoomni/src/video/legoanimationmanager.cpp @@ -1,5 +1,7 @@ #include "legoanimationmanager.h" +DECOMP_SIZE_ASSERT(LegoAnimationManager, 0x500) + // GLOBAL: LEGO1 0x100f74f8 int g_legoAnimationManagerConfig = 1; diff --git a/LEGO1/omni/include/mxvariable.h b/LEGO1/omni/include/mxvariable.h index 9b0a3816..d201cd39 100644 --- a/LEGO1/omni/include/mxvariable.h +++ b/LEGO1/omni/include/mxvariable.h @@ -22,13 +22,13 @@ class MxVariable { } // FUNCTION: LEGO1 0x1003bea0 - virtual MxString* GetValue() { return &m_value; } + virtual MxString* GetValue() { return &m_value; } // vtable+0x00 // FUNCTION: LEGO1 0x1003beb0 - virtual void SetValue(const char* p_value) { m_value = p_value; } + virtual void SetValue(const char* p_value) { m_value = p_value; } // vtable+0x04 // FUNCTION: LEGO1 0x1003bec0 - virtual void Destroy() { delete this; } + virtual void Destroy() { delete this; } // vtable+0x08 inline const MxString* GetKey() const { return &m_key; }