From 7703b56374f65570399806298b36aa71f6f0a53f Mon Sep 17 00:00:00 2001 From: Brendan Dougherty Date: Wed, 12 Jul 2023 10:57:36 -0500 Subject: [PATCH] Remove MxList, use one inherited class per type. Improves accuracy again. --- CMakeLists.txt | 1 - LEGO1/mxlist.cpp | 6 ------ LEGO1/mxlist.h | 19 ------------------- LEGO1/mxnotificationmanager.cpp | 11 +++++------ LEGO1/mxnotificationmanager.h | 15 +++++++++++---- LEGO1/stlcompat.h | 3 +++ 6 files changed, 19 insertions(+), 36 deletions(-) delete mode 100644 LEGO1/mxlist.cpp delete mode 100644 LEGO1/mxlist.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 67e9fd9c..48daddd2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -121,7 +121,6 @@ add_library(lego1 SHARED LEGO1/mxeventpresenter.cpp LEGO1/mxflcpresenter.cpp LEGO1/mxioinfo.cpp - LEGO1/mxlist.cpp LEGO1/mxloopingflcpresenter.cpp LEGO1/mxloopingmidipresenter.cpp LEGO1/mxloopingsmkpresenter.cpp diff --git a/LEGO1/mxlist.cpp b/LEGO1/mxlist.cpp deleted file mode 100644 index 380d85e3..00000000 --- a/LEGO1/mxlist.cpp +++ /dev/null @@ -1,6 +0,0 @@ -#include "mxlist.h" - -#include "decomp.h" - -// Can't use DECOMP_SIZE_ASSERT due to STL type size changes. -//DECOMP_SIZE_ASSERT(MxList, 0xc); diff --git a/LEGO1/mxlist.h b/LEGO1/mxlist.h deleted file mode 100644 index c13c75ae..00000000 --- a/LEGO1/mxlist.h +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef MXLIST_H -#define MXLIST_H - -#include "stlcompat.h" -#ifndef ISLE_COMPAT -#define LIST_T List -#else -#define LIST_T list -#endif - -template -class MxList : public LIST_T -{ -public: - inline MxList() : LIST_T() {} - inline ~MxList() {} -}; - -#endif // MXLIST_H diff --git a/LEGO1/mxnotificationmanager.cpp b/LEGO1/mxnotificationmanager.cpp index 06f4a20c..66034563 100644 --- a/LEGO1/mxnotificationmanager.cpp +++ b/LEGO1/mxnotificationmanager.cpp @@ -1,7 +1,6 @@ #include "legoomni.h" #include "mxautolocker.h" #include "mxcore.h" -#include "mxlist.h" #include "mxnotificationmanager.h" #include "mxparam.h" #include "mxtypes.h" @@ -49,7 +48,7 @@ MxNotificationManager::~MxNotificationManager() // OFFSET: LEGO1 0x100ac800 MxResult MxNotificationManager::Tickle() { - m_sendList = new MxList(); + m_sendList = new MxNotificationPtrList(); if (m_sendList == NULL) { return FAILURE; } @@ -76,7 +75,7 @@ MxResult MxNotificationManager::Tickle() MxResult MxNotificationManager::Create(MxS32 p_unk1, MxS32 p_unk2) { MxResult result = SUCCESS; - m_queue = new MxList(); + m_queue = new MxNotificationPtrList(); if (m_queue == NULL) { result = FAILURE; @@ -94,7 +93,7 @@ void MxNotificationManager::Register(MxCore *p_listener) MxAutoLocker lock(&m_lock); MxU32 listenerId = p_listener->GetId(); - MxList::iterator it = find(m_listenerIds.begin(), m_listenerIds.end(), listenerId); + MxIdList::iterator it = find(m_listenerIds.begin(), m_listenerIds.end(), listenerId); if (it != m_listenerIds.end()) return; @@ -106,7 +105,7 @@ void MxNotificationManager::Unregister(MxCore *p_listener) { MxAutoLocker lock(&m_lock); - MxList::iterator it = find(m_listenerIds.begin(), m_listenerIds.end(), p_listener->GetId()); + MxIdList::iterator it = find(m_listenerIds.begin(), m_listenerIds.end(), p_listener->GetId()); if (it != m_listenerIds.end()) { m_listenerIds.erase(it); @@ -129,7 +128,7 @@ MxResult MxNotificationManager::Send(MxCore *p_listener, MxParam *p_param) return FAILURE; } else { - MxList::iterator it = find(m_listenerIds.begin(), m_listenerIds.end(), p_listener->GetId()); + MxIdList::iterator it = find(m_listenerIds.begin(), m_listenerIds.end(), p_listener->GetId()); if (it == m_listenerIds.end()) { return FAILURE; } diff --git a/LEGO1/mxnotificationmanager.h b/LEGO1/mxnotificationmanager.h index 191b7ffd..06c11dc8 100644 --- a/LEGO1/mxnotificationmanager.h +++ b/LEGO1/mxnotificationmanager.h @@ -3,9 +3,10 @@ #include "mxcore.h" #include "mxcriticalsection.h" -#include "mxlist.h" #include "mxtypes.h" +#include "stlcompat.h" + class MxNotification { public: @@ -27,15 +28,21 @@ class MxNotification MxParam *m_param; // 0x4 }; +class MxIdList : public List +{}; + +class MxNotificationPtrList : public List +{}; + // VTABLE 0x100dc078 class MxNotificationManager : public MxCore { private: - MxList *m_queue; // 0x8 - MxList *m_sendList; // 0xc + MxNotificationPtrList *m_queue; // 0x8 + MxNotificationPtrList *m_sendList; // 0xc MxCriticalSection m_lock; // 0x10 MxS32 m_unk2c; // 0x2c - MxList m_listenerIds; // 0x30 + MxIdList m_listenerIds; // 0x30 MxBool m_active; // 0x3c public: diff --git a/LEGO1/stlcompat.h b/LEGO1/stlcompat.h index 7fae2769..5607590f 100644 --- a/LEGO1/stlcompat.h +++ b/LEGO1/stlcompat.h @@ -4,8 +4,11 @@ #ifndef ISLE_COMPAT #include #else +#include #include using namespace std; +template +using List = list; #endif #endif // STLCOMPAT_H