From c2da041f40f45aecd73099ef54f306a8f813fe9e Mon Sep 17 00:00:00 2001 From: Misha <106913236+MishaProductions@users.noreply.github.com> Date: Sat, 13 Jan 2024 15:00:11 -0500 Subject: [PATCH] Implement a few legoworld methods (#430) * Push changes * Update legoworld.cpp * Update legoworld.cpp * Minor style fixes --------- Co-authored-by: Christian Semmler --- LEGO1/lego/legoomni/include/helicopter.h | 2 +- LEGO1/lego/legoomni/include/infocenter.h | 2 +- LEGO1/lego/legoomni/include/isle.h | 2 +- LEGO1/lego/legoomni/include/islepathactor.h | 2 +- .../legoomni/include/legocontrolmanager.h | 2 + LEGO1/lego/legoomni/include/legoentity.h | 2 +- LEGO1/lego/legoomni/include/legoomni.h | 3 +- .../include/legopointofviewcontroller.h | 1 + LEGO1/lego/legoomni/include/legorace.h | 2 +- LEGO1/lego/legoomni/include/legoworld.h | 40 ++++++------- LEGO1/lego/legoomni/include/score.h | 2 +- LEGO1/lego/legoomni/src/build/helicopter.cpp | 4 +- .../src/control/legocontrolmanager.cpp | 6 ++ LEGO1/lego/legoomni/src/entity/legoentity.cpp | 6 +- .../legoomni/src/entity/legopovcontroller.cpp | 6 ++ LEGO1/lego/legoomni/src/entity/legorace.cpp | 2 +- LEGO1/lego/legoomni/src/entity/legoworld.cpp | 59 +++++++++++++++++-- .../legoomni/src/infocenter/infocenter.cpp | 2 +- LEGO1/lego/legoomni/src/infocenter/score.cpp | 4 +- LEGO1/lego/legoomni/src/isle/isle.cpp | 4 +- .../lego/legoomni/src/isle/islepathactor.cpp | 4 +- LEGO1/lego/legoomni/src/main/legoomni.cpp | 6 ++ LEGO1/omni/include/mxentity.h | 8 +-- 23 files changed, 120 insertions(+), 51 deletions(-) diff --git a/LEGO1/lego/legoomni/include/helicopter.h b/LEGO1/lego/legoomni/include/helicopter.h index ef932f30..ec4faa59 100644 --- a/LEGO1/lego/legoomni/include/helicopter.h +++ b/LEGO1/lego/legoomni/include/helicopter.h @@ -37,7 +37,7 @@ public: return !strcmp(p_name, Helicopter::ClassName()) || IslePathActor::IsA(p_name); } - virtual MxResult Create(MxDSObject& p_dsObject) override; // vtable+0x18 + virtual MxResult Create(MxDSAction& p_dsAction) override; // vtable+0x18 void VTable0x70(float p_float) override; // vtable+0x70 void VTable0x74(Matrix4& p_transform) override; // vtable+0x74 virtual MxU32 VTable0xcc() override; // vtable+0xcc diff --git a/LEGO1/lego/legoomni/include/infocenter.h b/LEGO1/lego/legoomni/include/infocenter.h index 634d7b55..d514d550 100644 --- a/LEGO1/lego/legoomni/include/infocenter.h +++ b/LEGO1/lego/legoomni/include/infocenter.h @@ -26,7 +26,7 @@ public: return !strcmp(p_name, Infocenter::ClassName()) || LegoWorld::IsA(p_name); } - virtual MxResult Create(MxDSObject& p_dsObject) override; // vtable+0x18 + virtual MxResult Create(MxDSAction& p_dsAction) override; // vtable+0x18 virtual void VTable0x50() override; // vtable+0x50 virtual MxBool VTable0x5c() override; // vtable+0x5c virtual MxBool VTable0x64() override; // vtable+0x64 diff --git a/LEGO1/lego/legoomni/include/isle.h b/LEGO1/lego/legoomni/include/isle.h index a768d357..6bf1fd48 100644 --- a/LEGO1/lego/legoomni/include/isle.h +++ b/LEGO1/lego/legoomni/include/isle.h @@ -40,7 +40,7 @@ public: return !strcmp(p_name, Isle::ClassName()) || LegoWorld::IsA(p_name); } - virtual MxResult Create(MxDSObject& p_dsObject) override; // vtable+0x18 + virtual MxResult Create(MxDSAction& p_dsAction) override; // vtable+0x18 virtual void VTable0x50() override; // vtable+50 virtual void VTable0x58(MxCore* p_object) override; // vtable+58 // FUNCTION: LEGO1 0x10030900 diff --git a/LEGO1/lego/legoomni/include/islepathactor.h b/LEGO1/lego/legoomni/include/islepathactor.h index d7a8ff60..559e4bca 100644 --- a/LEGO1/lego/legoomni/include/islepathactor.h +++ b/LEGO1/lego/legoomni/include/islepathactor.h @@ -28,7 +28,7 @@ public: return !strcmp(p_name, IslePathActor::ClassName()) || LegoPathActor::IsA(p_name); } - virtual MxResult Create(MxDSObject& p_dsObject) override; // vtable+0x18 + virtual MxResult Create(MxDSAction& p_dsAction) override; // vtable+0x18 // FUNCTION: LEGO1 0x10002e70 virtual MxU32 VTable0xcc() { return 0; } // vtable+0xcc // FUNCTION: LEGO1 0x10002df0 diff --git a/LEGO1/lego/legoomni/include/legocontrolmanager.h b/LEGO1/lego/legoomni/include/legocontrolmanager.h index 7bc8dc0f..36bf6d48 100644 --- a/LEGO1/lego/legoomni/include/legocontrolmanager.h +++ b/LEGO1/lego/legoomni/include/legocontrolmanager.h @@ -2,6 +2,7 @@ #define LEGOCONTROLMANAGER_H #include "mxcore.h" +#include "mxpresenterlist.h" // VTABLE: LEGO1 0x100d6a80 class LegoControlManager : public MxCore { @@ -24,6 +25,7 @@ public: return !strcmp(p_name, LegoControlManager::ClassName()) || MxCore::IsA(p_name); } + void FUN_10028df0(MxPresenterList* p_presenterList); void Register(MxCore* p_listener); void Unregister(MxCore* p_listener); }; diff --git a/LEGO1/lego/legoomni/include/legoentity.h b/LEGO1/lego/legoomni/include/legoentity.h index 8ca966b1..21dd26a8 100644 --- a/LEGO1/lego/legoomni/include/legoentity.h +++ b/LEGO1/lego/legoomni/include/legoentity.h @@ -32,7 +32,7 @@ public: return !strcmp(p_name, LegoEntity::ClassName()) || MxEntity::IsA(p_name); } - virtual MxResult Create(MxDSObject& p_dsObject); // vtable+0x18 + virtual MxResult Create(MxDSAction& p_dsAction); // vtable+0x18 virtual void Destroy(MxBool p_fromDestructor); // vtable+0x1c virtual void ParseAction(char*); // vtable+0x20 virtual void SetROI(LegoROI* p_roi, MxBool p_bool1, MxBool p_bool2); // vtable+0x24 diff --git a/LEGO1/lego/legoomni/include/legoomni.h b/LEGO1/lego/legoomni/include/legoomni.h index 21c84801..deab2d44 100644 --- a/LEGO1/lego/legoomni/include/legoomni.h +++ b/LEGO1/lego/legoomni/include/legoomni.h @@ -116,7 +116,7 @@ public: MxDSAction& GetCurrentAction() { return m_action; } inline void SetNavController(LegoNavController* p_navController) { m_navController = p_navController; } - + inline void SetWorld(LegoWorld* p_currentWorld) { m_currentWorld = p_currentWorld; } inline void SetExit(MxBool p_exit) { m_exit = p_exit; }; private: @@ -167,5 +167,6 @@ void SetIsWorldActive(MxBool p_isWorldActive); void DeleteObjects(MxAtomId* p_id, MxS32 p_first, MxS32 p_last); void RegisterScripts(); void UnregisterScripts(); +void SetCurrentWorld(LegoWorld* p_world); #endif // LEGOOMNI_H diff --git a/LEGO1/lego/legoomni/include/legopointofviewcontroller.h b/LEGO1/lego/legoomni/include/legopointofviewcontroller.h index 444a08ad..99c213e2 100644 --- a/LEGO1/lego/legoomni/include/legopointofviewcontroller.h +++ b/LEGO1/lego/legoomni/include/legopointofviewcontroller.h @@ -83,6 +83,7 @@ public: virtual void SetEntity(LegoEntity* p_entity); // vtable+0x2c MxResult Create(Lego3DView* p_lego3DView); + void OnViewSize(int p_width, int p_height); inline LegoEntity* GetEntity() { return m_entity; } diff --git a/LEGO1/lego/legoomni/include/legorace.h b/LEGO1/lego/legoomni/include/legorace.h index 530c289c..504b4cbb 100644 --- a/LEGO1/lego/legoomni/include/legorace.h +++ b/LEGO1/lego/legoomni/include/legorace.h @@ -28,7 +28,7 @@ public: return !strcmp(p_name, LegoRace::ClassName()) || LegoWorld::IsA(p_name); } - virtual MxResult Create(MxDSObject& p_dsObject) override; // vtable+0x18 + virtual MxResult Create(MxDSAction& p_dsAction) override; // vtable+0x18 virtual MxBool VTable0x5c() override; // vtable+0x5c virtual MxBool VTable0x64() override; // vtable+0x64 virtual void VTable0x68(MxBool p_add) override; // vtable+0x68 diff --git a/LEGO1/lego/legoomni/include/legoworld.h b/LEGO1/lego/legoomni/include/legoworld.h index 385e0b07..7cacf766 100644 --- a/LEGO1/lego/legoomni/include/legoworld.h +++ b/LEGO1/lego/legoomni/include/legoworld.h @@ -33,20 +33,20 @@ public: return !strcmp(p_name, LegoWorld::ClassName()) || LegoEntity::IsA(p_name); } - virtual void VTable0x50(); // vtable+50 - virtual void VTable0x54(); // vtable+54 - virtual void VTable0x58(MxCore* p_object); // vtable+58 - virtual MxBool VTable0x5c(); // vtable+5c + virtual MxResult Create(MxDSAction& p_dsAction) override; // vtable+0x18 + virtual void VTable0x50(); // vtable+0x50 + virtual LegoCameraController* VTable0x54(); // vtable+0x54 + virtual void VTable0x58(MxCore* p_object); // vtable+0x58 + virtual MxBool VTable0x5c(); // vtable+0x5c // FUNCTION: LEGO1 0x100010a0 - virtual void VTable0x60() {} // vtable+60 - virtual MxBool VTable0x64(); // vtable+64 - virtual void VTable0x68(MxBool p_add); // vtable+68 + virtual void VTable0x60() {} // vtable+0x60 + virtual MxBool VTable0x64(); // vtable+0x64 + virtual void VTable0x68(MxBool p_add); // vtable+0x68 - inline LegoCameraController* GetCamera() { return m_camera; } + inline LegoCameraController* GetCamera() { return m_cameraController; } inline undefined4 GetUnknown0xec() { return m_unk0xec; } undefined FUN_100220e0(); - MxResult SetAsCurrentWorld(MxDSObject& p_dsObject); void EndAction(MxCore* p_object); void FUN_1001fc80(IslePathActor* p_actor); MxBool FUN_100727e0(MxU32, Mx3DPointFloat& p_loc, Mx3DPointFloat& p_dir, Mx3DPointFloat& p_up); @@ -56,17 +56,17 @@ public: MxS32 GetCurrPathInfo(LegoPathBoundary** p_path, MxS32& p_value); protected: - LegoPathControllerList m_list0x68; // 0x68 - MxPresenterList m_list0x80; // 0x80 - LegoCameraController* m_camera; // 0x98 - undefined m_unk0x9c[0x1c]; // 0x9c - MxPresenterList m_list0xb8; // 0xb8 - undefined m_unk0xd0[0x1c]; // 0xd0 - undefined4 m_unk0xec; // 0xec - undefined4 m_unk0xf0; // 0xf0 - MxS16 m_unk0xf4; // 0xf4 - MxBool m_worldStarted; // 0xf6 - undefined m_unk0xf7; // 0xf7 + LegoPathControllerList m_list0x68; // 0x68 + MxPresenterList m_list0x80; // 0x80 + LegoCameraController* m_cameraController; // 0x98 + undefined m_unk0x9c[0x1c]; // 0x9c + MxPresenterList m_list0xb8; // 0xb8 + undefined m_unk0xd0[0x1c]; // 0xd0 + undefined4 m_unk0xec; // 0xec + undefined4 m_unk0xf0; // 0xf0 + MxS16 m_unk0xf4; // 0xf4 + MxBool m_worldStarted; // 0xf6 + undefined m_unk0xf7; // 0xf7 }; // SYNTHETIC: LEGO1 0x1001eed0 diff --git a/LEGO1/lego/legoomni/include/score.h b/LEGO1/lego/legoomni/include/score.h index f5950aa8..1e801aa3 100644 --- a/LEGO1/lego/legoomni/include/score.h +++ b/LEGO1/lego/legoomni/include/score.h @@ -31,7 +31,7 @@ public: // SYNTHETIC: LEGO1 0x100011e0 // Score::`scalar deleting destructor' - virtual MxResult Create(MxDSObject& p_dsObject) override; // vtable+18 + virtual MxResult Create(MxDSAction& p_dsAction) override; // vtable+18 virtual void VTable0x50() override; // vtable+50 virtual MxBool VTable0x5c() override; // vtable+5c virtual MxBool VTable0x64() override; // vtable+64 diff --git a/LEGO1/lego/legoomni/src/build/helicopter.cpp b/LEGO1/lego/legoomni/src/build/helicopter.cpp index d661b4d7..823304e8 100644 --- a/LEGO1/lego/legoomni/src/build/helicopter.cpp +++ b/LEGO1/lego/legoomni/src/build/helicopter.cpp @@ -27,9 +27,9 @@ Helicopter::~Helicopter() } // FUNCTION: LEGO1 0x100032c0 -MxResult Helicopter::Create(MxDSObject& p_dsObject) +MxResult Helicopter::Create(MxDSAction& p_dsAction) { - MxResult result = IslePathActor::Create(p_dsObject); + MxResult result = IslePathActor::Create(p_dsAction); LegoWorld* world = GetCurrentWorld(); SetWorld(world); if (world->IsA("Act3")) { diff --git a/LEGO1/lego/legoomni/src/control/legocontrolmanager.cpp b/LEGO1/lego/legoomni/src/control/legocontrolmanager.cpp index f3c70c50..24e3cb1b 100644 --- a/LEGO1/lego/legoomni/src/control/legocontrolmanager.cpp +++ b/LEGO1/lego/legoomni/src/control/legocontrolmanager.cpp @@ -12,6 +12,12 @@ LegoControlManager::~LegoControlManager() // TODO } +// STUB: LEGO1 0x10028df0 +void LegoControlManager::FUN_10028df0(MxPresenterList* p_presenterList) +{ + // TODO +} + // STUB: LEGO1 0x10028e10 void LegoControlManager::Register(MxCore* p_listener) { diff --git a/LEGO1/lego/legoomni/src/entity/legoentity.cpp b/LEGO1/lego/legoomni/src/entity/legoentity.cpp index 62058e50..e1a8c6f4 100644 --- a/LEGO1/lego/legoomni/src/entity/legoentity.cpp +++ b/LEGO1/lego/legoomni/src/entity/legoentity.cpp @@ -42,10 +42,10 @@ void LegoEntity::SetWorldTransform(const Vector3& p_loc, const Vector3& p_dir, c } // FUNCTION: LEGO1 0x100107e0 -MxResult LegoEntity::Create(MxDSObject& p_dsObject) +MxResult LegoEntity::Create(MxDSAction& p_dsAction) { - m_mxEntityId = p_dsObject.GetObjectId(); - m_atom = p_dsObject.GetAtomId(); + m_mxEntityId = p_dsAction.GetObjectId(); + m_atom = p_dsAction.GetAtomId(); Init(); return SUCCESS; } diff --git a/LEGO1/lego/legoomni/src/entity/legopovcontroller.cpp b/LEGO1/lego/legoomni/src/entity/legopovcontroller.cpp index a2e1bb04..f656022d 100644 --- a/LEGO1/lego/legoomni/src/entity/legopovcontroller.cpp +++ b/LEGO1/lego/legoomni/src/entity/legopovcontroller.cpp @@ -100,6 +100,12 @@ MxResult LegoPointOfViewController::Create(Lego3DView* p_lego3DView) return SUCCESS; } +// FUNCTION: LEGO1 0x100658a0 +void LegoPointOfViewController::OnViewSize(int p_width, int p_height) +{ + m_nav->SetControlMax(p_width, p_height); +} + // FUNCTION: LEGO1 0x100658c0 void LegoPointOfViewController::LeftDown(int p_x, int p_y) { diff --git a/LEGO1/lego/legoomni/src/entity/legorace.cpp b/LEGO1/lego/legoomni/src/entity/legorace.cpp index d5eefbd5..79565966 100644 --- a/LEGO1/lego/legoomni/src/entity/legorace.cpp +++ b/LEGO1/lego/legoomni/src/entity/legorace.cpp @@ -62,7 +62,7 @@ MxBool LegoRace::VTable0x64() } // STUB: LEGO1 0x10015ce0 -MxResult LegoRace::Create(MxDSObject& p_dsObject) +MxResult LegoRace::Create(MxDSAction& p_dsAction) { // TODO return SUCCESS; diff --git a/LEGO1/lego/legoomni/src/entity/legoworld.cpp b/LEGO1/lego/legoomni/src/entity/legoworld.cpp index 339360e7..c7a2608a 100644 --- a/LEGO1/lego/legoomni/src/entity/legoworld.cpp +++ b/LEGO1/lego/legoomni/src/entity/legoworld.cpp @@ -1,8 +1,10 @@ #include "legoworld.h" +#include "legocontrolmanager.h" #include "legoinputmanager.h" #include "legoomni.h" #include "legoutil.h" +#include "legovideomanager.h" #include "mxactionnotificationparam.h" #include "mxnotificationmanager.h" #include "mxnotificationparam.h" @@ -39,10 +41,28 @@ LegoWorld::~LegoWorld() } // STUB: LEGO1 0x1001e0b0 -MxResult LegoWorld::SetAsCurrentWorld(MxDSObject& p_dsObject) +MxResult LegoWorld::Create(MxDSAction& p_dsAction) { - // TODO - return SUCCESS; + MxEntity::Create(p_dsAction); + + // TODO: Intitialize lists + + if (VTable0x54()) { + if (p_dsAction.GetFlags() & MxDSAction::Flag_Enabled) { + if (GetCurrentWorld()) { + GetCurrentWorld()->VTable0x68(0); + } + + SetCurrentWorld(this); + ControlManager()->FUN_10028df0(&m_list0xb8); + } + + SetIsWorldActive(TRUE); + m_unk0xec = -1; + + return SUCCESS; + } + return FAILURE; } // FUNCTION: LEGO1 0x1001f5e0 @@ -63,10 +83,37 @@ MxLong LegoWorld::Notify(MxParam& p_param) return ret; } -// STUB: LEGO1 0x1001f630 -void LegoWorld::VTable0x54() +// FUNCTION: LEGO1 0x1001f630 +LegoCameraController* LegoWorld::VTable0x54() { - // TODO + MxBool success = FALSE; + + if (!VideoManager()) { + goto done; + } + if (!(m_cameraController = new LegoCameraController())) { + goto done; + } + if (m_cameraController->Create() != SUCCESS) { + goto done; + } + + m_cameraController->OnViewSize( + VideoManager()->GetVideoParam().GetRect().GetWidth(), + VideoManager()->GetVideoParam().GetRect().GetHeight() + ); + + success = TRUE; + +done: + if (!success) { + if (m_cameraController) { + delete m_cameraController; + m_cameraController = NULL; + } + } + + return m_cameraController; } // STUB: LEGO1 0x1001fc80 diff --git a/LEGO1/lego/legoomni/src/infocenter/infocenter.cpp b/LEGO1/lego/legoomni/src/infocenter/infocenter.cpp index 47d89ea5..9201adf9 100644 --- a/LEGO1/lego/legoomni/src/infocenter/infocenter.cpp +++ b/LEGO1/lego/legoomni/src/infocenter/infocenter.cpp @@ -13,7 +13,7 @@ Infocenter::~Infocenter() } // STUB: LEGO1 0x1006ed90 -MxResult Infocenter::Create(MxDSObject& p_dsObject) +MxResult Infocenter::Create(MxDSAction& p_dsAction) { return FAILURE; } diff --git a/LEGO1/lego/legoomni/src/infocenter/score.cpp b/LEGO1/lego/legoomni/src/infocenter/score.cpp index 5e9ca19c..91cfedd6 100644 --- a/LEGO1/lego/legoomni/src/infocenter/score.cpp +++ b/LEGO1/lego/legoomni/src/infocenter/score.cpp @@ -39,9 +39,9 @@ Score::~Score() } // FUNCTION: LEGO1 0x100012a0 -MxResult Score::Create(MxDSObject& p_dsObject) +MxResult Score::Create(MxDSAction& p_dsAction) { - MxResult result = SetAsCurrentWorld(p_dsObject); + MxResult result = LegoWorld::Create(p_dsAction); if (result == SUCCESS) { InputManager()->SetWorld(this); diff --git a/LEGO1/lego/legoomni/src/isle/isle.cpp b/LEGO1/lego/legoomni/src/isle/isle.cpp index f11497e6..d10e18ad 100644 --- a/LEGO1/lego/legoomni/src/isle/isle.cpp +++ b/LEGO1/lego/legoomni/src/isle/isle.cpp @@ -54,11 +54,11 @@ Isle::~Isle() } // FUNCTION: LEGO1 0x10030b20 -MxResult Isle::Create(MxDSObject& p_dsObject) +MxResult Isle::Create(MxDSAction& p_dsAction) { GameState()->FUN_1003ceb0(); - MxResult result = LegoWorld::SetAsCurrentWorld(p_dsObject); + MxResult result = LegoWorld::Create(p_dsAction); if (result == SUCCESS) { ControlManager()->Register(this); InputManager()->SetWorld(this); diff --git a/LEGO1/lego/legoomni/src/isle/islepathactor.cpp b/LEGO1/lego/legoomni/src/isle/islepathactor.cpp index 528bbde8..036b3298 100644 --- a/LEGO1/lego/legoomni/src/isle/islepathactor.cpp +++ b/LEGO1/lego/legoomni/src/isle/islepathactor.cpp @@ -12,9 +12,9 @@ IslePathActor::IslePathActor() } // FUNCTION: LEGO1 0x1001a280 -MxResult IslePathActor::Create(MxDSObject& p_dsObject) +MxResult IslePathActor::Create(MxDSAction& p_dsAction) { - return MxEntity::Create(p_dsObject); + return MxEntity::Create(p_dsAction); } // STUB: LEGO1 0x1001a350 diff --git a/LEGO1/lego/legoomni/src/main/legoomni.cpp b/LEGO1/lego/legoomni/src/main/legoomni.cpp index cd0bc4a0..ef7cca9b 100644 --- a/LEGO1/lego/legoomni/src/main/legoomni.cpp +++ b/LEGO1/lego/legoomni/src/main/legoomni.cpp @@ -216,6 +216,12 @@ MxDSAction& GetCurrentAction() return LegoOmni::GetInstance()->GetCurrentAction(); } +// FUNCTION: LEGO1 0x100158f0 +void SetCurrentWorld(LegoWorld* p_world) +{ + LegoOmni::GetInstance()->SetWorld(p_world); +} + // FUNCTION: LEGO1 0x10015900 MxTransitionManager* TransitionManager() { diff --git a/LEGO1/omni/include/mxentity.h b/LEGO1/omni/include/mxentity.h index 2dd9ccf1..40742896 100644 --- a/LEGO1/omni/include/mxentity.h +++ b/LEGO1/omni/include/mxentity.h @@ -4,7 +4,7 @@ #include "decomp.h" #include "mxatomid.h" #include "mxcore.h" -#include "mxdsobject.h" +#include "mxdsaction.h" #include "mxtypes.h" // VTABLE: LEGO1 0x100d5390 @@ -38,10 +38,10 @@ public: return SUCCESS; }; // vtable+0x14 - inline MxResult Create(MxDSObject& p_dsObject) + inline MxResult Create(MxDSAction& p_dsAction) { - m_mxEntityId = p_dsObject.GetObjectId(); - m_atom = p_dsObject.GetAtomId(); + m_mxEntityId = p_dsAction.GetObjectId(); + m_atom = p_dsAction.GetAtomId(); return SUCCESS; }