Remove MxList, use one inherited class per type. Improves accuracy again.

This commit is contained in:
Brendan Dougherty 2023-07-12 10:57:36 -05:00
parent b5cba1eebc
commit 7703b56374
6 changed files with 19 additions and 36 deletions

View File

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

View File

@ -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<MxU32>, 0xc);

View File

@ -1,19 +0,0 @@
#ifndef MXLIST_H
#define MXLIST_H
#include "stlcompat.h"
#ifndef ISLE_COMPAT
#define LIST_T List<T>
#else
#define LIST_T list<T>
#endif
template <class T>
class MxList : public LIST_T
{
public:
inline MxList() : LIST_T() {}
inline ~MxList() {}
};
#endif // MXLIST_H

View File

@ -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<MxNotification *>();
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<MxNotification *>();
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<MxU32>::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<MxU32>::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<MxU32>::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;
}

View File

@ -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<MxU32>
{};
class MxNotificationPtrList : public List<MxNotification *>
{};
// VTABLE 0x100dc078
class MxNotificationManager : public MxCore
{
private:
MxList<MxNotification *> *m_queue; // 0x8
MxList<MxNotification *> *m_sendList; // 0xc
MxNotificationPtrList *m_queue; // 0x8
MxNotificationPtrList *m_sendList; // 0xc
MxCriticalSection m_lock; // 0x10
MxS32 m_unk2c; // 0x2c
MxList<MxU32> m_listenerIds; // 0x30
MxIdList m_listenerIds; // 0x30
MxBool m_active; // 0x3c
public:

View File

@ -4,8 +4,11 @@
#ifndef ISLE_COMPAT
#include <STL.H>
#else
#include <algorithm>
#include <list>
using namespace std;
template <class T>
using List = list<T>;
#endif
#endif // STLCOMPAT_H