From d72c7676859a7547b3d9581866880037b475128c Mon Sep 17 00:00:00 2001 From: Misha <106913236+MishaProductions@users.noreply.github.com> Date: Sat, 16 Dec 2023 13:14:01 -0500 Subject: [PATCH] Implement a few legoomni/mxomni functions (#339) * LegoOmni functions * fix build * Update mxstreamcontroller.cpp * fixes + improve match * Update mxomni.cpp * Update mxdsobject.h * improve match * Update mxactionnotificationparam.h * MxOmni::HandleActionEnd * fixes * Update LEGO1/mxstreamer.cpp Co-authored-by: Joshua Peisach * A bunch of fixes --------- Co-authored-by: Joshua Peisach Co-authored-by: Christian Semmler --- CMakeLists.txt | 1 + LEGO1/lego3dmanager.h | 6 +- LEGO1/lego3dview.cpp | 10 +++ LEGO1/lego3dview.h | 4 + LEGO1/legoomni.cpp | 122 ++++++++++++++++++++++++---- LEGO1/legoomni.h | 36 ++++---- LEGO1/legoworld.cpp | 7 ++ LEGO1/legoworld.h | 2 + LEGO1/mxactionnotificationparam.cpp | 12 +++ LEGO1/mxactionnotificationparam.h | 41 ++++++++++ LEGO1/mxbackgroundaudiomanager.cpp | 2 +- LEGO1/mxdsobject.h | 26 +++--- LEGO1/mxomni.cpp | 90 ++++++++++++++++---- LEGO1/mxomni.h | 44 +++++----- LEGO1/mxstreamcontroller.cpp | 15 ++++ LEGO1/mxstreamcontroller.h | 2 + LEGO1/mxstreamer.cpp | 18 ++++ LEGO1/mxstreamer.h | 1 + 18 files changed, 355 insertions(+), 84 deletions(-) create mode 100644 LEGO1/lego3dview.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index ed3c29cf..2537059c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -47,6 +47,7 @@ add_library(lego1 SHARED LEGO1/jukebox.cpp LEGO1/jukeboxentity.cpp LEGO1/jukeboxstate.cpp + LEGO1/lego3dview.cpp LEGO1/legoact2state.cpp LEGO1/legoactioncontrolpresenter.cpp LEGO1/legoactor.cpp diff --git a/LEGO1/lego3dmanager.h b/LEGO1/lego3dmanager.h index f7638649..3e1cf202 100644 --- a/LEGO1/lego3dmanager.h +++ b/LEGO1/lego3dmanager.h @@ -8,9 +8,9 @@ class Lego3DManager { inline Lego3DView* GetLego3DView() { return this->m_3dView; } private: - int m_unk0x00; - int m_unk0x04; - Lego3DView* m_3dView; + undefined4 m_unk0x00; // 0x00 + undefined4 m_unk0x04; // 0x04 + Lego3DView* m_3dView; // 0x08 }; #endif // LEGO3DMANAGER_H diff --git a/LEGO1/lego3dview.cpp b/LEGO1/lego3dview.cpp new file mode 100644 index 00000000..0bb384e8 --- /dev/null +++ b/LEGO1/lego3dview.cpp @@ -0,0 +1,10 @@ +#include "lego3dview.h" + +#include "legoroi.h" + +// STUB: LEGO1 0x100ab2b0 +LegoROI* Lego3DView::PickROI(MxLong p_a, MxLong p_b) +{ + // TODO + return NULL; +} diff --git a/LEGO1/lego3dview.h b/LEGO1/lego3dview.h index e62a220f..cafca31a 100644 --- a/LEGO1/lego3dview.h +++ b/LEGO1/lego3dview.h @@ -1,11 +1,15 @@ #ifndef LEGO3DVIEW_H #define LEGO3DVIEW_H +#include "mxtypes.h" #include "viewmanager/viewmanager.h" +class LegoROI; + class Lego3DView { public: inline ViewManager* GetViewManager() { return this->m_viewManager; } + LegoROI* PickROI(MxLong p_a, MxLong p_b); private: char m_pad[0x88]; diff --git a/LEGO1/legoomni.cpp b/LEGO1/legoomni.cpp index d195957d..1dd1bde8 100644 --- a/LEGO1/legoomni.cpp +++ b/LEGO1/legoomni.cpp @@ -8,10 +8,12 @@ #include "legoobjectfactory.h" #include "legoplantmanager.h" #include "legosoundmanager.h" +#include "legounksavedatawriter.h" #include "legoutil.h" #include "legovideomanager.h" #include "legoworld.h" #include "legoworldlist.h" +#include "mxactionnotificationparam.h" #include "mxautolocker.h" #include "mxbackgroundaudiomanager.h" #include "mxdsfile.h" @@ -173,7 +175,7 @@ IslePathActor* GetCurrentVehicle() // FUNCTION: LEGO1 0x100157a0 LegoWorld* GetCurrentWorld() { - return LegoOmni::GetInstance()->GetCurrentWorld(); + return LegoOmni::GetInstance()->GetCurrentOmniWorld(); } // FUNCTION: LEGO1 0x100157e0 @@ -227,13 +229,14 @@ void PlayMusic(MxU32 p_index) void FUN_1001a700() { // TODO + + // This function seems to populate an unknown structure, and then calls 0x1001b230 } -// STUB: LEGO1 0x1003dd70 -LegoROI* PickROI(MxLong, MxLong) +// FUNCTION: LEGO1 0x1003dd70 +LegoROI* PickROI(MxLong p_a, MxLong p_b) { - // TODO - return NULL; + return VideoManager()->Get3DManager()->GetLego3DView()->PickROI(p_a, p_b); } // STUB: LEGO1 0x1003ddc0 @@ -379,10 +382,83 @@ void LegoOmni::Init() m_transitionManager = NULL; } -// STUB: LEGO1 0x10058c30 +// FUNCTION: LEGO1 0x10058c30 void LegoOmni::Destroy() { - // TODO + MxAutoLocker lock(&this->m_criticalsection); + + m_notificationManager->Unregister(this); + + if (m_worldList) { + delete m_worldList; + m_worldList = NULL; + } + + if (m_gameState) { + delete m_gameState; + m_gameState = NULL; + } + + if (m_animationManager) { + delete m_animationManager; + m_animationManager = NULL; + } + + if (m_saveDataWriter) { + delete m_saveDataWriter; + m_saveDataWriter = NULL; + } + + if (m_plantManager) { + delete m_plantManager; + m_plantManager = NULL; + } + + if (m_buildingManager) { + delete m_buildingManager; + m_buildingManager = NULL; + } + + if (m_gifManager) { + delete m_gifManager; + m_gifManager = NULL; + } + + if (m_unk0x6c) { + // delete m_unk0x6c; // TODO + m_unk0x6c = NULL; + } + + if (m_inputMgr) { + delete m_inputMgr; + m_inputMgr = NULL; + } + + if (m_inputMgr) { + delete m_inputMgr; + m_inputMgr = NULL; + } + + // todo FUN_10046de0 + + if (m_bkgAudioManager) { + m_bkgAudioManager->Stop(); + + delete m_bkgAudioManager; + m_bkgAudioManager = NULL; + } + + if (m_transitionManager) { + delete m_transitionManager; + m_transitionManager = NULL; + } + + m_action.ClearAtom(); + UnregisterScripts(); + + delete[] m_unk0x68; + + MxOmni::Destroy(); } // FUNCTION: LEGO1 0x10058e70 @@ -485,10 +561,9 @@ LegoEntity* LegoOmni::FindByEntityIdOrAtomId(const MxAtomId& p_atom, MxS32 p_ent } // STUB: LEGO1 0x1005b1d0 -MxResult LegoOmni::DeleteObject(MxDSAction& p_dsAction) +void LegoOmni::DeleteObject(MxDSAction& p_dsAction) { // TODO - return FAILURE; } // FUNCTION: LEGO1 0x1005b2f0 @@ -527,11 +602,14 @@ MxBool LegoOmni::DoesEntityExist(MxDSAction& p_dsAction) return FALSE; } -// STUB: LEGO1 0x1005b400 -int LegoOmni::GetCurrPathInfo(LegoPathBoundary**, int&) +// FUNCTION: LEGO1 0x1005b400 +MxS32 LegoOmni::GetCurrPathInfo(LegoPathBoundary** p_path, MxS32& p_value) { - // TODO - return 0; + if (GetCurrentWorld() == NULL) { + return -1; + } + + return GetCurrentWorld()->GetCurrPathInfo(p_path, p_value); } // FUNCTION: LEGO1 0x1005b560 @@ -551,11 +629,23 @@ MxResult LegoOmni::Start(MxDSAction* p_dsAction) return result; } -// STUB: LEGO1 0x1005b5f0 +// FUNCTION: LEGO1 0x1005b5f0 MxLong LegoOmni::Notify(MxParam& p_param) { - // TODO - return 0; + MxBool isCD = FALSE; + + if (((MxNotificationParam&) p_param).GetType() == c_notificationEndAction && + ((MxActionNotificationParam&) p_param).GetAction()->GetAtomId() == *g_nocdSourceName) { + isCD = TRUE; + } + + MxLong result = MxOmni::Notify(p_param); + if (isCD) { + // Exit the game if nocd.si ended + PostMessageA(m_windowHandle, WM_CLOSE, 0, 0); + } + + return result; } // FUNCTION: LEGO1 0x1005b640 diff --git a/LEGO1/legoomni.h b/LEGO1/legoomni.h index f8e61946..d671f6f4 100644 --- a/LEGO1/legoomni.h +++ b/LEGO1/legoomni.h @@ -89,7 +89,7 @@ class LegoOmni : public MxOmni { virtual MxResult Create(MxOmniCreateParam& p_param) override; // vtable+18 virtual void Destroy() override; // vtable+1c virtual MxResult Start(MxDSAction* p_dsAction) override; // vtable+20 - virtual MxResult DeleteObject(MxDSAction& p_dsAction) override; // vtable+24 + virtual void DeleteObject(MxDSAction& p_dsAction) override; // vtable+24 virtual MxBool DoesEntityExist(MxDSAction& p_dsAction) override; // vtable+28 virtual MxEntity* FindWorld(const char* p_id, MxS32 p_entityId, MxPresenter* p_presenter) override; // vtable+30 virtual void NotifyCurrentEntity(MxNotificationParam* p_param) override; // vtable+34 @@ -103,7 +103,7 @@ class LegoOmni : public MxOmni { LegoInputManager* GetInputManager() { return m_inputMgr; } GifManager* GetGifManager() { return m_gifManager; } - LegoWorld* GetCurrentWorld() { return m_currentWorld; } + LegoWorld* GetCurrentOmniWorld() { return m_currentWorld; } LegoNavController* GetNavController() { return m_navController; } IslePathActor* GetCurrentVehicle() { return m_currentVehicle; } LegoPlantManager* GetLegoPlantManager() { return m_plantManager; } @@ -115,24 +115,24 @@ class LegoOmni : public MxOmni { MxDSAction& GetCurrentAction() { return m_action; } private: - undefined4 m_unk0x68; - undefined4 m_unk0x6c; - LegoInputManager* m_inputMgr; // 0x70 - GifManager* m_gifManager; - LegoWorldList* m_worldList; // 0x78 - LegoWorld* m_currentWorld; - MxBool m_unk0x80; - LegoNavController* m_navController; // 0x84 - IslePathActor* m_currentVehicle; // 0x88 - LegoUnkSaveDataWriter* m_saveDataWriter; - LegoPlantManager* m_plantManager; // 0x90 - LegoAnimationManager* m_animationManager; - LegoBuildingManager* m_buildingManager; // 0x98 - LegoGameState* m_gameState; // 0x9c - MxDSAction m_action; + undefined4* m_unk0x68; // 0x68 + undefined4 m_unk0x6c; // 0x6c + LegoInputManager* m_inputMgr; // 0x70 + GifManager* m_gifManager; // 0x74 + LegoWorldList* m_worldList; // 0x78 + LegoWorld* m_currentWorld; // 0x7c + MxBool m_unk0x80; // 0x80 + LegoNavController* m_navController; // 0x84 + IslePathActor* m_currentVehicle; // 0x88 + LegoUnkSaveDataWriter* m_saveDataWriter; // 0x8c + LegoPlantManager* m_plantManager; // 0x90 + LegoAnimationManager* m_animationManager; // 0x94 + LegoBuildingManager* m_buildingManager; // 0x98 + LegoGameState* m_gameState; // 0x9c + MxDSAction m_action; // 0xa0 MxBackgroundAudioManager* m_bkgAudioManager; // 0x134 MxTransitionManager* m_transitionManager; // 0x138 - MxBool m_unk0x13c; + MxBool m_unk0x13c; // 0x13c }; __declspec(dllexport) MxBackgroundAudioManager* BackgroundAudioManager(); diff --git a/LEGO1/legoworld.cpp b/LEGO1/legoworld.cpp index 6f14b43f..f809e1a0 100644 --- a/LEGO1/legoworld.cpp +++ b/LEGO1/legoworld.cpp @@ -91,6 +91,13 @@ void LegoWorld::FUN_1001fc80(IslePathActor* p_actor) { } +// STUB: LEGO1 0x10020120 +MxS32 LegoWorld::GetCurrPathInfo(LegoPathBoundary** p_path, MxS32& p_value) +{ + // TODO + return 0; +} + // STUB: LEGO1 0x10020220 void LegoWorld::VTable0x58(MxCore* p_object) { diff --git a/LEGO1/legoworld.h b/LEGO1/legoworld.h index 6752ca9a..60989527 100644 --- a/LEGO1/legoworld.h +++ b/LEGO1/legoworld.h @@ -8,6 +8,7 @@ #include "mxpresenterlist.h" class IslePathActor; +class LegoPathBoundary; // VTABLE: LEGO1 0x100d6280 // SIZE 0xf8 @@ -50,6 +51,7 @@ class LegoWorld : public LegoEntity { MxBool FUN_10072980(MxU32, Vector3Data& p_loc, Vector3Data& p_dir, Vector3Data& p_up); void FUN_10073400(); void FUN_10073430(); + MxS32 GetCurrPathInfo(LegoPathBoundary** p_path, MxS32& p_value); protected: LegoPathControllerList m_list0x68; // 0x68 diff --git a/LEGO1/mxactionnotificationparam.cpp b/LEGO1/mxactionnotificationparam.cpp index 2122ba0d..b5d84832 100644 --- a/LEGO1/mxactionnotificationparam.cpp +++ b/LEGO1/mxactionnotificationparam.cpp @@ -14,3 +14,15 @@ MxNotificationParam* MxEndActionNotificationParam::Clone() { return new MxEndActionNotificationParam(c_notificationEndAction, this->m_sender, this->m_action, this->m_realloc); } + +// FUNCTION: LEGO1 0x100b0300 +MxNotificationParam* MxStartActionNotificationParam::Clone() +{ + return new MxEndActionNotificationParam(c_notificationStartAction, this->m_sender, this->m_action, this->m_realloc); +} + +// FUNCTION: LEGO1 0x100b04f0 +MxNotificationParam* MxType4NotificationParam::Clone() +{ + return new MxType4NotificationParam(this->m_sender, this->m_action, this->m_unk0x14); +} diff --git a/LEGO1/mxactionnotificationparam.h b/LEGO1/mxactionnotificationparam.h index cbe73fe2..24d9e5e1 100644 --- a/LEGO1/mxactionnotificationparam.h +++ b/LEGO1/mxactionnotificationparam.h @@ -4,6 +4,8 @@ #include "mxdsaction.h" #include "mxnotificationparam.h" +class MxPresenter; + // VTABLE: LEGO1 0x100d8350 // SIZE 0x14 class MxActionNotificationParam : public MxNotificationParam { @@ -50,6 +52,23 @@ class MxActionNotificationParam : public MxNotificationParam { MxBool m_realloc; // 0x10 }; +// VTABLE: LEGO1 0x100dc210 +// SIZE 0x14 +class MxStartActionNotificationParam : public MxActionNotificationParam { +public: + inline MxStartActionNotificationParam( + NotificationId p_type, + MxCore* p_sender, + MxDSAction* p_action, + MxBool p_reallocAction + ) + : MxActionNotificationParam(p_type, p_sender, p_action, p_reallocAction) + { + } + + virtual MxNotificationParam* Clone() override; // vtable+0x4 +}; + // VTABLE: LEGO1 0x100d8358 // SIZE 0x14 class MxEndActionNotificationParam : public MxActionNotificationParam { @@ -67,7 +86,29 @@ class MxEndActionNotificationParam : public MxActionNotificationParam { virtual MxNotificationParam* Clone() override; // vtable+0x4 }; +// VTABLE: LEGO1 0x100dc208 +// SIZE 0x18 +class MxType4NotificationParam : public MxActionNotificationParam { +public: + inline MxType4NotificationParam(MxCore* p_sender, MxDSAction* p_action, MxPresenter* p_unk0x14) + : MxActionNotificationParam(TYPE4, p_sender, p_action, FALSE) + { + m_unk0x14 = p_unk0x14; + } + + virtual MxNotificationParam* Clone() override; // vtable+0x4 + +private: + MxPresenter* m_unk0x14; // 0x14 +}; + // SYNTHETIC: LEGO1 0x100513a0 // MxEndActionNotificationParam::`scalar deleting destructor' +// SYNTHETIC: LEGO1 0x100b0430 +// MxStartActionNotificationParam::`scalar deleting destructor' + +// SYNTHETIC: LEGO1 0x100b05c0 +// MxType4NotificationParam::`scalar deleting destructor' + #endif diff --git a/LEGO1/mxbackgroundaudiomanager.cpp b/LEGO1/mxbackgroundaudiomanager.cpp index 74c34e06..c4b8b6bd 100644 --- a/LEGO1/mxbackgroundaudiomanager.cpp +++ b/LEGO1/mxbackgroundaudiomanager.cpp @@ -226,7 +226,7 @@ void MxBackgroundAudioManager::StopAction(MxParam& p_param) m_action2.SetObjectId(-1); } - Lego()->HandleNotificationType2(p_param); + Lego()->HandleActionEnd(p_param); } // FUNCTION: LEGO1 0x1007f2f0 diff --git a/LEGO1/mxdsobject.h b/LEGO1/mxdsobject.h index dfa967cf..e3fe75e9 100644 --- a/LEGO1/mxdsobject.h +++ b/LEGO1/mxdsobject.h @@ -6,6 +6,8 @@ #include "mxcore.h" #include "mxdstypes.h" +class MxPresenter; + // VTABLE: LEGO1 0x100dc868 // SIZE 0x2c class MxDSObject : public MxCore { @@ -38,23 +40,25 @@ class MxDSObject : public MxCore { inline MxU32 GetObjectId() { return this->m_objectId; } inline const MxAtomId& GetAtomId() { return this->m_atomId; } inline MxS16 GetUnknown24() { return this->m_unk0x24; } - inline undefined4 GetUnknown28() { return this->m_unk0x28; } + inline MxPresenter* GetUnknown28() { return this->m_unk0x28; } inline void SetType(MxDSType p_type) { this->m_type = p_type; } inline void SetObjectId(MxU32 p_objectId) { this->m_objectId = p_objectId; } inline void SetUnknown24(MxS16 p_unk0x24) { this->m_unk0x24 = p_unk0x24; } - inline void SetUnknown28(undefined4 p_unk0x28) { this->m_unk0x28 = p_unk0x28; } + inline void SetUnknown28(MxPresenter* p_unk0x28) { this->m_unk0x28 = p_unk0x28; } + + inline void ClearAtom() { m_atomId.Clear(); } private: - MxU32 m_sizeOnDisk; // 0x8 - MxU16 m_type; // 0xc - char* m_sourceName; // 0x10 - undefined4 m_unk0x14; // 0x14 - char* m_objectName; // 0x18 - MxU32 m_objectId; // 0x1c - MxAtomId m_atomId; // 0x20 - MxS16 m_unk0x24; // 0x24 - undefined4 m_unk0x28; // 0x28 + MxU32 m_sizeOnDisk; // 0x8 + MxU16 m_type; // 0xc + char* m_sourceName; // 0x10 + undefined4 m_unk0x14; // 0x14 + char* m_objectName; // 0x18 + MxU32 m_objectId; // 0x1c + MxAtomId m_atomId; // 0x20 + MxS16 m_unk0x24; // 0x24 + MxPresenter* m_unk0x28; // 0x28 }; MxDSObject* DeserializeDSObjectDispatch(char**, MxS16); diff --git a/LEGO1/mxomni.cpp b/LEGO1/mxomni.cpp index 7a7560a5..561974da 100644 --- a/LEGO1/mxomni.cpp +++ b/LEGO1/mxomni.cpp @@ -1,5 +1,6 @@ #include "mxomni.h" +#include "mxactionnotificationparam.h" #include "mxatomidcounter.h" #include "mxautolocker.h" #include "mxeventmanager.h" @@ -7,6 +8,7 @@ #include "mxnotificationmanager.h" #include "mxobjectfactory.h" #include "mxomnicreateparam.h" +#include "mxpresenter.h" #include "mxsoundmanager.h" #include "mxstreamer.h" #include "mxticklemanager.h" @@ -112,9 +114,9 @@ MxEventManager* EventManager() } // FUNCTION: LEGO1 0x100acf70 -MxResult DeleteObject(MxDSAction& p_dsAction) +void DeleteObject(MxDSAction& p_dsAction) { - return MxOmni::GetInstance()->DeleteObject(p_dsAction); + MxOmni::GetInstance()->DeleteObject(p_dsAction); } // FUNCTION: LEGO1 0x100aef10 @@ -310,17 +312,51 @@ MxResult MxOmni::Start(MxDSAction* p_dsAction) return result; } -// STUB: LEGO1 0x100b00c0 -MxResult MxOmni::DeleteObject(MxDSAction& p_dsAction) +// FUNCTION: LEGO1 0x100b00c0 +void MxOmni::DeleteObject(MxDSAction& p_dsAction) { - // TODO - return FAILURE; + if (m_streamer != NULL) { + m_streamer->DeleteObject(&p_dsAction); + } } -// STUB: LEGO1 0x100b00e0 -void MxOmni::Vtable0x2c() +// FUNCTION: LEGO1 0x100b00e0 +MxResult MxOmni::CreatePresenter(MxStreamController* p_controller, MxDSAction& p_action) { - // TODO + MxResult result = FAILURE; + MxPresenter* object = (MxPresenter*) m_objectFactory->Create(PresenterNameDispatch(p_action)); + + if (object) { + if (object->AddToManager() == SUCCESS) { + MxPresenter* sender = p_action.GetUnknown28(); + if (sender == NULL && (sender = p_controller->FUN_100c1e70(p_action)) == NULL) { + if (p_action.GetOrigin() == NULL) { + p_action.SetOrigin(this); + } + + object->SetCompositePresenter(NULL); + } + else { + p_action.SetOrigin(sender); + object->SetCompositePresenter((MxCompositePresenter*) sender); + } + + if (object->StartAction(p_controller, &p_action) == SUCCESS) { + if (sender) { + NotificationManager()->Send(sender, &MxType4NotificationParam(this, &p_action, object)); + } + + if (p_action.GetUnknown84()) { + NotificationManager()->Send( + p_action.GetUnknown84(), + &MxStartActionNotificationParam(c_notificationStartAction, this, &p_action, FALSE) + ); + } + result = SUCCESS; + } + } + } + return result; } // FUNCTION: LEGO1 0x100b0680 @@ -338,6 +374,13 @@ void MxOmni::DestroyInstance() } } +// STUB: LEGO1 0x100b06b0 +MxBool MxOmni::FUN_100b06b0(MxDSAction* p_action, const char* p_name) +{ + // TODO + return FAILURE; +} + // FUNCTION: LEGO1 0x100b07f0 MxLong MxOmni::Notify(MxParam& p_param) { @@ -346,14 +389,33 @@ MxLong MxOmni::Notify(MxParam& p_param) if (((MxNotificationParam&) p_param).GetNotification() != c_notificationEndAction) return 0; - return HandleNotificationType2(p_param); + return HandleActionEnd(p_param); } -// STUB: LEGO1 0x100b0880 -MxResult MxOmni::HandleNotificationType2(MxParam& p_param) +// FUNCTION: LEGO1 0x100b0880 +MxLong MxOmni::HandleActionEnd(MxParam& p_param) { - // TODO STUB - return FAILURE; + MxDSAction* action = ((MxEndActionNotificationParam&) p_param).GetAction(); + MxStreamController* controller = Streamer()->GetOpenStream(action->GetAtomId().GetInternal()); + + if (controller != NULL) { + action = controller->GetUnk0x54().Find(action, FALSE); + if (action) { + if (FUN_100b06b0(action, "LegoLoopingAnimPresenter") == FALSE) { + delete controller->GetUnk0x54().Find(action, TRUE); + } + } + } + + if (((MxEndActionNotificationParam&) p_param).GetSender()) { + delete ((MxEndActionNotificationParam&) p_param).GetSender(); + } + + if (((MxEndActionNotificationParam&) p_param).GetAction()) { + delete ((MxEndActionNotificationParam&) p_param).GetAction(); + } + + return 1; } // FUNCTION: LEGO1 0x100b0900 diff --git a/LEGO1/mxomni.h b/LEGO1/mxomni.h index 2f8f1efd..7bac0723 100644 --- a/LEGO1/mxomni.h +++ b/LEGO1/mxomni.h @@ -22,6 +22,7 @@ class MxTimer; class MxVariableTable; class MxVideoManager; class MxEntity; +class MxStreamController; // VTABLE: LEGO1 0x100dc168 // SIZE 0x68 @@ -39,20 +40,23 @@ class MxOmni : public MxCore { MxOmni(); virtual ~MxOmni() override; - virtual MxLong Notify(MxParam& p_param) override; // vtable+04 - virtual void Init(); // vtable+14 - virtual MxResult Create(MxOmniCreateParam& p_param); // vtable+18 - virtual void Destroy(); // vtable+1c - virtual MxResult Start(MxDSAction* p_dsAction); // vtable+20 - virtual MxResult DeleteObject(MxDSAction& p_dsAction); // vtable+24 - virtual MxBool DoesEntityExist(MxDSAction& p_dsAction); // vtable+28 - virtual void Vtable0x2c(); // vtable+2c - virtual MxEntity* FindWorld(const char*, MxS32, MxPresenter*); // vtable+30 - virtual void NotifyCurrentEntity(MxNotificationParam* p_param); // vtable+34 - virtual void StartTimer(); // vtable+38 - virtual void StopTimer(); // vtable+3c - virtual MxBool IsTimerRunning(); // vtable+40 + virtual MxLong Notify(MxParam& p_param) override; // vtable+04 + virtual void Init(); // vtable+14 + virtual MxResult Create(MxOmniCreateParam& p_param); // vtable+18 + virtual void Destroy(); // vtable+1c + virtual MxResult Start(MxDSAction* p_dsAction); // vtable+20 + virtual void DeleteObject(MxDSAction& p_dsAction); // vtable+24 + virtual MxBool DoesEntityExist(MxDSAction& p_dsAction); // vtable+28 + virtual MxResult CreatePresenter(MxStreamController* p_controller, MxDSAction& p_action); // vtable+2c + virtual MxEntity* FindWorld(const char*, MxS32, MxPresenter*); // vtable+30 + virtual void NotifyCurrentEntity(MxNotificationParam* p_param); // vtable+34 + virtual void StartTimer(); // vtable+38 + virtual void StopTimer(); // vtable+3c + virtual MxBool IsTimerRunning(); // vtable+40 + static void SetInstance(MxOmni* p_instance); + static MxBool FUN_100b06b0(MxDSAction* p_action, const char* p_name); + HWND GetWindowHandle() const { return this->m_windowHandle; } MxObjectFactory* GetObjectFactory() const { return this->m_objectFactory; } MxNotificationManager* GetNotificationManager() const { return this->m_notificationManager; } @@ -65,7 +69,7 @@ class MxOmni : public MxCore { MxMusicManager* GetMusicManager() const { return this->m_musicManager; } MxEventManager* GetEventManager() const { return this->m_eventManager; } MxAtomIdCounterSet* GetAtomIdCounterSet() const { return this->m_atomIdCounterSet; } - MxResult HandleNotificationType2(MxParam& p_param); + MxLong HandleActionEnd(MxParam& p_param); protected: static MxOmni* g_instance; @@ -82,13 +86,11 @@ class MxOmni : public MxCore { MxEventManager* m_eventManager; // 0x38 MxTimer* m_timer; // 0x3C MxStreamer* m_streamer; // 0x40 - - MxAtomIdCounterSet* m_atomIdCounterSet; // 0x44 - - MxCriticalSection m_criticalsection; // 0x48 - - MxBool m_timerRunning; // 0x64 + MxAtomIdCounterSet* m_atomIdCounterSet; // 0x44 + MxCriticalSection m_criticalsection; // 0x48 + MxBool m_timerRunning; // 0x64 }; + __declspec(dllexport) MxTickleManager* TickleManager(); __declspec(dllexport) MxTimer* Timer(); __declspec(dllexport) MxStreamer* Streamer(); @@ -101,7 +103,7 @@ __declspec(dllexport) MxNotificationManager* NotificationManager(); MxVideoManager* MVideoManager(); MxAtomIdCounterSet* AtomIdCounterSet(); MxObjectFactory* ObjectFactory(); -MxResult DeleteObject(MxDSAction& p_dsAction); +void DeleteObject(MxDSAction& p_dsAction); void DeleteObjects(MxAtomId* p_id, MxS32 p_first, MxS32 p_last); #endif // MXOMNI_H diff --git a/LEGO1/mxstreamcontroller.cpp b/LEGO1/mxstreamcontroller.cpp index 9357ebf6..d18f4bcc 100644 --- a/LEGO1/mxstreamcontroller.cpp +++ b/LEGO1/mxstreamcontroller.cpp @@ -133,6 +133,21 @@ MxResult MxStreamController::VTable0x30(MxDSAction* p_action) return result; } +// FUNCTION: LEGO1 0x100c1e70 +MxPresenter* MxStreamController::FUN_100c1e70(MxDSAction& p_action) +{ + MxAutoLocker locker(&m_criticalSection); + MxPresenter* result = NULL; + if (p_action.GetObjectId() != -1) { + MxDSAction* action = m_unk0x3c.Find(&p_action, FALSE); + if (action != NULL) { + result = action->GetUnknown28(); + } + } + + return result; +} + // STUB: LEGO1 0x100c1f00 MxResult MxStreamController::FUN_100c1f00(MxDSAction* p_action) { diff --git a/LEGO1/mxstreamcontroller.h b/LEGO1/mxstreamcontroller.h index a4d90b86..803e12b9 100644 --- a/LEGO1/mxstreamcontroller.h +++ b/LEGO1/mxstreamcontroller.h @@ -44,9 +44,11 @@ class MxStreamController : public MxCore { MxResult FUN_100c1800(MxDSAction* p_action, MxU32 p_val); MxBool FUN_100c20d0(MxDSObject& p_obj); MxResult FUN_100c1a00(MxDSAction* p_action, MxU32 p_bufferval); + MxPresenter* FUN_100c1e70(MxDSAction& p_action); MxResult FUN_100c1f00(MxDSAction* p_action); inline MxAtomId& GetAtom() { return m_atom; }; + inline MxStreamListMxDSAction& GetUnk0x54() { return m_unk0x54; }; protected: MxCriticalSection m_criticalSection; // 0x8 diff --git a/LEGO1/mxstreamer.cpp b/LEGO1/mxstreamer.cpp index 8449e086..b4357d87 100644 --- a/LEGO1/mxstreamer.cpp +++ b/LEGO1/mxstreamer.cpp @@ -143,6 +143,24 @@ MxResult MxStreamer::FUN_100b99b0(MxDSAction* p_action) return FAILURE; } +// STUB: LEGO1 0x100b99f0 +MxResult MxStreamer::DeleteObject(MxDSAction* p_dsAction) +{ + MxDSAction tempAction; + + if (p_dsAction == NULL) { + tempAction.SetUnknown24(-2); + } + else { + tempAction.SetObjectId(p_dsAction->GetObjectId()); + tempAction.SetAtomId(p_dsAction->GetAtomId()); + tempAction.SetUnknown24(p_dsAction->GetUnknown24()); + } + + // TODO: remove action from list + return FAILURE; +} + // FUNCTION: LEGO1 0x100b9b30 MxBool MxStreamer::FUN_100b9b30(MxDSObject& p_dsObject) { diff --git a/LEGO1/mxstreamer.h b/LEGO1/mxstreamer.h index 3ea0403d..3b58b260 100644 --- a/LEGO1/mxstreamer.h +++ b/LEGO1/mxstreamer.h @@ -94,6 +94,7 @@ class MxStreamer : public MxCore { MxStreamController* GetOpenStream(const char* p_name); MxResult AddStreamControllerToOpenList(MxStreamController* p_stream); MxResult FUN_100b99b0(MxDSAction* p_action); + MxResult DeleteObject(MxDSAction* p_dsAction); inline const MxStreamerSubClass2& GetSubclass1() { return m_subclass1; } inline const MxStreamerSubClass3& GetSubclass2() { return m_subclass2; }