From 08f578b79f2369e3757193440271690dfef7f490 Mon Sep 17 00:00:00 2001 From: Misha <106913236+MishaProductions@users.noreply.github.com> Date: Sat, 16 Dec 2023 12:27:15 -0500 Subject: [PATCH] MxOmni::HandleActionEnd --- LEGO1/mxbackgroundaudiomanager.cpp | 2 +- LEGO1/mxomni.cpp | 43 ++++++++++++++++++++++++------ LEGO1/mxomni.h | 3 ++- LEGO1/mxstreamcontroller.h | 1 + LEGO1/mxstreamer.cpp | 21 +++++++++++++++ LEGO1/mxstreamer.h | 1 + 6 files changed, 61 insertions(+), 10 deletions(-) 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/mxomni.cpp b/LEGO1/mxomni.cpp index c74cdf53..00b5651a 100644 --- a/LEGO1/mxomni.cpp +++ b/LEGO1/mxomni.cpp @@ -312,11 +312,15 @@ MxResult MxOmni::Start(MxDSAction* p_dsAction) return result; } -// STUB: LEGO1 0x100b00c0 +// FUNCTION: LEGO1 0x100b00c0 MxResult MxOmni::DeleteObject(MxDSAction& p_dsAction) { - // TODO - return FAILURE; + MxResult result; + if (m_streamer != NULL) { + result = m_streamer->DeleteObject(&p_dsAction); + } + + return result; } // FUNCTION: LEGO1 0x100b00e0 @@ -375,6 +379,12 @@ void MxOmni::DestroyInstance() } } +MxBool MxOmni::FUN_100b06b0(MxDSAction* p_action) +{ + // TODO STUB + return FAILURE; +} + // FUNCTION: LEGO1 0x100b07f0 MxLong MxOmni::Notify(MxParam& p_param) { @@ -383,14 +393,31 @@ 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) { + if (controller->GetUnk0x54().Find(action, FALSE)) { + if (FUN_100b06b0(action) == 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 0ac78acb..16f1a320 100644 --- a/LEGO1/mxomni.h +++ b/LEGO1/mxomni.h @@ -54,6 +54,7 @@ class MxOmni : public MxCore { virtual void StopTimer(); // vtable+3c virtual MxBool IsTimerRunning(); // vtable+40 static void SetInstance(MxOmni* p_instance); + static MxBool FUN_100b06b0(MxDSAction* p_action); HWND GetWindowHandle() const { return this->m_windowHandle; } MxObjectFactory* GetObjectFactory() const { return this->m_objectFactory; } MxNotificationManager* GetNotificationManager() const { return this->m_notificationManager; } @@ -66,7 +67,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; diff --git a/LEGO1/mxstreamcontroller.h b/LEGO1/mxstreamcontroller.h index df61085b..3329237f 100644 --- a/LEGO1/mxstreamcontroller.h +++ b/LEGO1/mxstreamcontroller.h @@ -48,6 +48,7 @@ class MxStreamController : public MxCore { 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..5614f431 100644 --- a/LEGO1/mxstreamer.cpp +++ b/LEGO1/mxstreamer.cpp @@ -143,6 +143,27 @@ 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 -1; +} + // 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; }