Implement/match LegoOmni::Create (#556)

* Implement/match LegoOmni::Create

* Fix var

* Rename

* Fix style
This commit is contained in:
Christian Semmler 2024-02-10 20:52:16 -05:00 committed by GitHub
parent c69cd4d818
commit a29c0aca3f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
17 changed files with 208 additions and 50 deletions

View file

@ -292,6 +292,7 @@ add_library(lego1 SHARED
LEGO1/lego/legoomni/src/common/legostate.cpp LEGO1/lego/legoomni/src/common/legostate.cpp
LEGO1/lego/legoomni/src/common/legounksavedatawriter.cpp LEGO1/lego/legoomni/src/common/legounksavedatawriter.cpp
LEGO1/lego/legoomni/src/common/legoutil.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/common/mxcompositemediapresenter.cpp
LEGO1/lego/legoomni/src/control/legocontrolmanager.cpp LEGO1/lego/legoomni/src/control/legocontrolmanager.cpp
LEGO1/lego/legoomni/src/control/mxcontrolpresenter.cpp LEGO1/lego/legoomni/src/control/mxcontrolpresenter.cpp

View file

@ -64,6 +64,8 @@ class GifManagerBase {
return NULL; return NULL;
} }
inline void SetOwnership(MxBool p_ownership) { m_ownership = p_ownership; }
// SYNTHETIC: LEGO1 0x1005a310 // SYNTHETIC: LEGO1 0x1005a310
// GifManagerBase::`scalar deleting destructor' // GifManagerBase::`scalar deleting destructor'

View file

@ -42,6 +42,8 @@ class LegoAnimationManager : public MxCore {
private: private:
void Init(); void Init();
undefined m_unk0x08[0x4f8]; // 0x08
}; };
#endif // LEGOANIMATIONMANAGER_H #endif // LEGOANIMATIONMANAGER_H

View file

@ -1,6 +1,7 @@
#ifndef LEGOBUILDINGMANAGER_H #ifndef LEGOBUILDINGMANAGER_H
#define LEGOBUILDINGMANAGER_H #define LEGOBUILDINGMANAGER_H
#include "decomp.h"
#include "mxcore.h" #include "mxcore.h"
// VTABLE: LEGO1 0x100d6f50 // VTABLE: LEGO1 0x100d6f50
@ -30,6 +31,8 @@ class LegoBuildingManager : public MxCore {
private: private:
void Init(); void Init();
undefined m_unk0x08[0x28]; // 0x08
}; };
#endif // LEGOBUILDINGMANAGER_H #endif // LEGOBUILDINGMANAGER_H

View file

@ -104,6 +104,7 @@ class LegoOmni : public MxOmni {
void FUN_1005b4f0(MxBool p_disable, MxU16 p_flags); void FUN_1005b4f0(MxBool p_disable, MxU16 p_flags);
void CreateBackgroundAudio(); void CreateBackgroundAudio();
void RemoveWorld(const MxAtomId&, MxLong); void RemoveWorld(const MxAtomId&, MxLong);
MxResult FUN_1005a5f0();
undefined4 FUN_1005b490(char* p_worldName); undefined4 FUN_1005b490(char* p_worldName);
static MxS32 GetCurrPathInfo(LegoPathBoundary**, MxS32&); static MxS32 GetCurrPathInfo(LegoPathBoundary**, MxS32&);

View file

@ -29,6 +29,8 @@ class LegoPlantManager : public MxCore {
private: private:
void Init(); void Init();
undefined m_unk0x08[0x24]; // 0x08
}; };
#endif // LEGOPLANTMANAGER_H #endif // LEGOPLANTMANAGER_H

View file

@ -33,12 +33,18 @@ struct LegoSaveDataEntry3 {
MxU8 m_savePart10; // 0x104 MxU8 m_savePart10; // 0x104
}; };
// SIZE 0x08
class LegoUnkSaveDataWriter { class LegoUnkSaveDataWriter {
public: public:
LegoUnkSaveDataWriter();
MxResult WriteSaveData3(LegoStorage* p_stream); MxResult WriteSaveData3(LegoStorage* p_stream);
AutoROI* FUN_10083500(undefined4, undefined4); AutoROI* FUN_10083500(undefined4, undefined4);
void FUN_100832a0(); void FUN_100832a0();
void FUN_10083db0(LegoROI* p_roi); void FUN_10083db0(LegoROI* p_roi);
private:
undefined m_unk0x00[0x08]; // 0x00
}; };
#endif // LEGOUNKSAVEDATAWRITER_H #endif // LEGOUNKSAVEDATAWRITER_H

View file

@ -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

View file

@ -74,6 +74,9 @@ class LegoWorldListCursor : public MxPtrListCursor<LegoWorld> {
// TEMPLATE: LEGO1 0x100599f0 // TEMPLATE: LEGO1 0x100599f0
// MxPtrList<LegoWorld>::Destroy // MxPtrList<LegoWorld>::Destroy
// TEMPLATE: LEGO1 0x10059a70
// MxPtrList<LegoWorld>::~MxPtrList<LegoWorld>
// SYNTHETIC: LEGO1 0x10059ac0 // SYNTHETIC: LEGO1 0x10059ac0
// MxCollection<LegoWorld *>::`scalar deleting destructor' // MxCollection<LegoWorld *>::`scalar deleting destructor'

View file

@ -1,5 +1,7 @@
#include "legobuildingmanager.h" #include "legobuildingmanager.h"
DECOMP_SIZE_ASSERT(LegoBuildingManager, 0x30)
// GLOBAL: LEGO1 0x100f37cc // GLOBAL: LEGO1 0x100f37cc
int g_buildingManagerConfig = 1; int g_buildingManagerConfig = 1;

View file

@ -1,5 +1,7 @@
#include "legoplantmanager.h" #include "legoplantmanager.h"
DECOMP_SIZE_ASSERT(LegoPlantManager, 0x2c)
// FUNCTION: LEGO1 0x10026220 // FUNCTION: LEGO1 0x10026220
LegoPlantManager::LegoPlantManager() LegoPlantManager::LegoPlantManager()
{ {

View file

@ -3,11 +3,18 @@
#include "legogamestate.h" #include "legogamestate.h"
#include "roi/legoroi.h" #include "roi/legoroi.h"
DECOMP_SIZE_ASSERT(LegoSaveDataEntry3, 0x108); DECOMP_SIZE_ASSERT(LegoUnkSaveDataWriter, 0x08)
DECOMP_SIZE_ASSERT(LegoSaveDataEntry3, 0x108)
// GLOBAL: LEGO1 0x10104f20 // GLOBAL: LEGO1 0x10104f20
LegoSaveDataEntry3 g_saveData3[66]; LegoSaveDataEntry3 g_saveData3[66];
// STUB: LEGO1 0x10082a20
LegoUnkSaveDataWriter::LegoUnkSaveDataWriter()
{
// TODO
}
// STUB: LEGO1 0x100832a0 // STUB: LEGO1 0x100832a0
void LegoUnkSaveDataWriter::FUN_100832a0() void LegoUnkSaveDataWriter::FUN_100832a0()
{ {

View file

@ -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
}

View file

@ -6,16 +6,13 @@
#include "legogamestate.h" #include "legogamestate.h"
#include "legoinputmanager.h" #include "legoinputmanager.h"
#include "legoomni.h" #include "legoomni.h"
#include "legovariables.h"
#include "mxnotificationmanager.h" #include "mxnotificationmanager.h"
#include "mxomni.h" #include "mxomni.h"
#include "mxtransitionmanager.h" #include "mxtransitionmanager.h"
DECOMP_SIZE_ASSERT(ElevatorBottom, 0xfc) DECOMP_SIZE_ASSERT(ElevatorBottom, 0xfc)
// STRING: LEGO1 0x100f0d34
// GLOBAL: LEGO1 0x100f3a44
const char* g_cameraLoc = "CAMERA_LOCATION";
// FUNCTION: LEGO1 0x10017e90 // FUNCTION: LEGO1 0x10017e90
ElevatorBottom::ElevatorBottom() ElevatorBottom::ElevatorBottom()
{ {
@ -106,7 +103,7 @@ MxLong ElevatorBottom::HandleClick(LegoControlManagerEvent& p_param)
state->SetUnknown1c(1); state->SetUnknown1c(1);
m_unk0xf8 = LegoGameState::e_unk6; m_unk0xf8 = LegoGameState::e_unk6;
TransitionManager()->StartTransition(MxTransitionManager::e_pixelation, 50, FALSE, FALSE); TransitionManager()->StartTransition(MxTransitionManager::e_pixelation, 50, FALSE, FALSE);
VariableTable()->SetVariable(g_cameraLoc, "LCAMZI1,90"); VariableTable()->SetVariable(g_varCAMERALOCATION, "LCAMZI1,90");
result = 1; result = 1;
break; break;
} }

View file

@ -10,6 +10,7 @@
#include "legosoundmanager.h" #include "legosoundmanager.h"
#include "legounksavedatawriter.h" #include "legounksavedatawriter.h"
#include "legoutil.h" #include "legoutil.h"
#include "legovariables.h"
#include "legovideomanager.h" #include "legovideomanager.h"
#include "legoworld.h" #include "legoworld.h"
#include "legoworldlist.h" #include "legoworldlist.h"
@ -532,70 +533,110 @@ MxResult LegoOmni::Create(MxOmniCreateParam& p_param)
p_param.CreateFlags().CreateTickleManager(FALSE); p_param.CreateFlags().CreateTickleManager(FALSE);
if (!(m_tickleManager = new MxTickleManager())) { if (!(m_tickleManager = new MxTickleManager())) {
return FAILURE; goto done;
} }
if (MxOmni::Create(p_param) != SUCCESS) { if (MxOmni::Create(p_param) != SUCCESS) {
return FAILURE; goto done;
} }
m_objectFactory = new LegoObjectFactory(); if (!(m_objectFactory = new LegoObjectFactory())) {
if (m_objectFactory == NULL) { goto done;
return FAILURE;
} }
if ((m_soundManager = new LegoSoundManager())) { if (!(m_soundManager = new LegoSoundManager()) || m_soundManager->Create(10, 0) != SUCCESS) {
if (m_soundManager->Create(10, 0) != SUCCESS) {
delete m_soundManager; delete m_soundManager;
m_soundManager = NULL; m_soundManager = NULL;
return FAILURE; goto done;
}
} }
if ((m_videoManager = new LegoVideoManager())) { if (!(m_videoManager = new LegoVideoManager()) ||
if (m_videoManager->Create(p_param.GetVideoParam(), 100, 0) != SUCCESS) { m_videoManager->Create(p_param.GetVideoParam(), 100, 0) != SUCCESS) {
delete m_videoManager; delete m_videoManager;
m_videoManager = NULL; m_videoManager = NULL;
} goto done;
} }
if ((m_inputMgr = new LegoInputManager())) { if (!(m_inputMgr = new LegoInputManager()) || m_inputMgr->Create(p_param.GetWindowHandle()) != SUCCESS) {
if (m_inputMgr->Create(p_param.GetWindowHandle()) != SUCCESS) {
delete m_inputMgr; delete m_inputMgr;
m_inputMgr = NULL; m_inputMgr = NULL;
} goto done;
} }
m_viewLODListManager = new ViewLODListManager(); m_viewLODListManager = new ViewLODListManager();
m_gifManager = new GifManager(); 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_plantManager = new LegoPlantManager();
m_animationManager = new LegoAnimationManager(); m_animationManager = new LegoAnimationManager();
m_buildingManager = new LegoBuildingManager(); m_buildingManager = new LegoBuildingManager();
m_gameState = new LegoGameState(); m_gameState = new LegoGameState();
m_worldList = new LegoWorldList(TRUE); m_worldList = new LegoWorldList(TRUE);
if (m_viewLODListManager && m_gifManager && m_worldList && m_plantManager && m_animationManager && if (!m_viewLODListManager || !m_gifManager || !m_worldList || !m_saveDataWriter || !m_plantManager ||
m_buildingManager) { !m_animationManager || !m_buildingManager) {
// TODO: initialize a bunch of MxVariables goto done;
}
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(); RegisterScripts();
FUN_1001a700(); FUN_1001a700();
// todo: another function call. in legoomni maybe? result = FUN_1005a5f0();
m_bkgAudioManager = new MxBackgroundAudioManager();
if (m_bkgAudioManager != NULL) { if (result != SUCCESS) {
m_transitionManager = new MxTransitionManager(); goto done;
if (m_transitionManager != NULL) { }
if (m_transitionManager->GetDDrawSurfaceFromVideoManager() == SUCCESS) {
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); m_notificationManager->Register(this);
SetAppCursor(1); SetAppCursor(1);
m_gameState->SetCurrentAct(LegoGameState::e_act1); m_gameState->SetCurrentAct(LegoGameState::e_act1);
return SUCCESS;
} result = SUCCESS;
}
} done:
return result;
} }
return FAILURE; // STUB: LEGO1 0x1005a5f0
MxResult LegoOmni::FUN_1005a5f0()
{
// TODO
return SUCCESS;
} }
// FUNCTION: LEGO1 0x1005ac90 // FUNCTION: LEGO1 0x1005ac90

View file

@ -1,5 +1,7 @@
#include "legoanimationmanager.h" #include "legoanimationmanager.h"
DECOMP_SIZE_ASSERT(LegoAnimationManager, 0x500)
// GLOBAL: LEGO1 0x100f74f8 // GLOBAL: LEGO1 0x100f74f8
int g_legoAnimationManagerConfig = 1; int g_legoAnimationManagerConfig = 1;

View file

@ -22,13 +22,13 @@ class MxVariable {
} }
// FUNCTION: LEGO1 0x1003bea0 // FUNCTION: LEGO1 0x1003bea0
virtual MxString* GetValue() { return &m_value; } virtual MxString* GetValue() { return &m_value; } // vtable+0x00
// FUNCTION: LEGO1 0x1003beb0 // 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 // FUNCTION: LEGO1 0x1003bec0
virtual void Destroy() { delete this; } virtual void Destroy() { delete this; } // vtable+0x08
inline const MxString* GetKey() const { return &m_key; } inline const MxString* GetKey() const { return &m_key; }