Merge pull request #1 from foxtacles/notification-refactor

Refactor MxParam/MxNotificationParam
This commit is contained in:
vMidz 2023-10-10 01:37:36 +03:00 committed by GitHub
commit 1b7be67219
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
18 changed files with 148 additions and 160 deletions

View File

@ -93,6 +93,7 @@ add_library(lego1 SHARED
LEGO1/legoworld.cpp LEGO1/legoworld.cpp
LEGO1/legoworldpresenter.cpp LEGO1/legoworldpresenter.cpp
LEGO1/motorcycle.cpp LEGO1/motorcycle.cpp
LEGO1/mxactionnotificationparam.cpp
LEGO1/mxatomid.cpp LEGO1/mxatomid.cpp
LEGO1/mxatomidcounter.cpp LEGO1/mxatomidcounter.cpp
LEGO1/mxaudiomanager.cpp LEGO1/mxaudiomanager.cpp
@ -144,11 +145,11 @@ add_library(lego1 SHARED
LEGO1/mxmusicmanager.cpp LEGO1/mxmusicmanager.cpp
LEGO1/mxmusicpresenter.cpp LEGO1/mxmusicpresenter.cpp
LEGO1/mxnotificationmanager.cpp LEGO1/mxnotificationmanager.cpp
LEGO1/mxnotificationparam.cpp
LEGO1/mxobjectfactory.cpp LEGO1/mxobjectfactory.cpp
LEGO1/mxomni.cpp LEGO1/mxomni.cpp
LEGO1/mxomnicreateflags.cpp LEGO1/mxomnicreateflags.cpp
LEGO1/mxomnicreateparam.cpp LEGO1/mxomnicreateparam.cpp
LEGO1/mxomnicreateparambase.cpp
LEGO1/mxpalette.cpp LEGO1/mxpalette.cpp
LEGO1/mxparam.cpp LEGO1/mxparam.cpp
LEGO1/mxpresenter.cpp LEGO1/mxpresenter.cpp

View File

@ -0,0 +1,16 @@
#include "mxactionnotificationparam.h"
DECOMP_SIZE_ASSERT(MxActionNotificationParam, 0x14)
DECOMP_SIZE_ASSERT(MxEndActionNotificationParam, 0x14)
// OFFSET: LEGO1 0x100510c0
MxNotificationParam *MxActionNotificationParam::Clone()
{
return new MxActionNotificationParam(this->m_type, this->m_sender, this->m_action, this->m_realloc);
}
// OFFSET: LEGO1 0x10051270
MxNotificationParam *MxEndActionNotificationParam::Clone()
{
return new MxEndActionNotificationParam(MXSTREAMER_UNKNOWN, this->m_sender, this->m_action, this->m_realloc);
}

View File

@ -0,0 +1,59 @@
#ifndef MXACTIONNOTIFICATIONPARAM_H
#define MXACTIONNOTIFICATIONPARAM_H
#include "mxnotificationparam.h"
#include "mxdsaction.h"
// VTABLE 0x100d8350
// SIZE 0x14
class MxActionNotificationParam : public MxNotificationParam
{
public:
inline MxActionNotificationParam(MxParamType p_type, MxCore *p_sender, MxDSAction *p_action, MxBool p_reallocAction) : MxNotificationParam(p_type, p_sender)
{
MxDSAction *oldAction = p_action;
this->m_realloc = p_reallocAction;
if (p_reallocAction)
this->m_action = new MxDSAction();
else {
this->m_action = oldAction;
return;
}
this->m_action->SetAtomId(oldAction->GetAtomId());
this->m_action->SetObjectId(oldAction->GetObjectId());
this->m_action->SetUnknown24(oldAction->GetUnknown24());
}
// OFFSET: LEGO1 0x10051050
inline virtual MxActionNotificationParam::~MxActionNotificationParam() override
{
if (!this->m_realloc)
return;
if (this->m_action)
delete this->m_action;
}
virtual MxNotificationParam *Clone() override; // vtable+0x4
protected:
MxDSAction *m_action; // 0xc
MxBool m_realloc; // 0x10
};
// VTABLE 0x100d8358
// SIZE 0x14
class MxEndActionNotificationParam : public MxActionNotificationParam
{
public:
inline MxEndActionNotificationParam(MxParamType p_type, MxCore *p_sender, MxDSAction *p_action, MxBool p_reallocAction)
: MxActionNotificationParam(p_type, p_sender, p_action, p_reallocAction) {}
inline virtual ~MxEndActionNotificationParam() override {}; // 0x100513a0
virtual MxNotificationParam *Clone() override; // vtable+0x4
};
#endif

View File

@ -46,6 +46,7 @@ class MxDSObject : public MxCore
inline void SetType(MxDSType p_type) { this->m_type = p_type; } inline void SetType(MxDSType p_type) { this->m_type = p_type; }
inline MxDSType GetType() const { return (MxDSType) this->m_type; } inline MxDSType GetType() const { return (MxDSType) this->m_type; }
private:
MxU32 m_sizeOnDisk; // 0x8 MxU32 m_sizeOnDisk; // 0x8
MxU16 m_type; // 0xc MxU16 m_type; // 0xc
char* m_sourceName; // 0x10 char* m_sourceName; // 0x10
@ -55,8 +56,6 @@ class MxDSObject : public MxCore
MxAtomId m_atomId; // 0x20 MxAtomId m_atomId; // 0x20
MxS16 m_unk24; // 0x24 MxS16 m_unk24; // 0x24
undefined4 m_unk28; // 0x28 undefined4 m_unk28; // 0x28
private:
}; };
MxDSObject *DeserializeDSObjectDispatch(char **, MxS16); MxDSObject *DeserializeDSObjectDispatch(char **, MxS16);

View File

@ -13,7 +13,7 @@ DECOMP_SIZE_ASSERT(MxNotification, 0x8);
DECOMP_SIZE_ASSERT(MxNotificationManager, 0x40); DECOMP_SIZE_ASSERT(MxNotificationManager, 0x40);
// OFFSET: LEGO1 0x100ac220 // OFFSET: LEGO1 0x100ac220
MxNotification::MxNotification(MxCore *p_target, MxParam *p_param) MxNotification::MxNotification(MxCore *p_target, MxNotificationParam *p_param)
{ {
m_target = p_target; m_target = p_target;
m_param = p_param->Clone(); m_param = p_param->Clone();
@ -161,7 +161,7 @@ void MxNotificationManager::FlushPending(MxCore *p_listener)
} }
// OFFSET: LEGO1 0x100ac6c0 // OFFSET: LEGO1 0x100ac6c0
MxResult MxNotificationManager::Send(MxCore *p_listener, MxParam *p_param) MxResult MxNotificationManager::Send(MxCore *p_listener, MxNotificationParam *p_param)
{ {
MxAutoLocker lock(&m_lock); MxAutoLocker lock(&m_lock);

View File

@ -3,6 +3,7 @@
#include "mxcore.h" #include "mxcore.h"
#include "mxcriticalsection.h" #include "mxcriticalsection.h"
#include "mxnotificationparam.h"
#include "mxtypes.h" #include "mxtypes.h"
#include "compat.h" #include "compat.h"
@ -10,22 +11,15 @@
class MxNotification class MxNotification
{ {
public: public:
MxNotification(MxCore *p_target, MxParam *p_param); MxNotification(MxCore *p_target, MxNotificationParam *p_param);
~MxNotification(); ~MxNotification();
inline MxCore *GetTarget() inline MxCore *GetTarget() { return m_target; }
{ inline MxNotificationParam *GetParam() { return m_param; }
return m_target;
}
inline MxParam *GetParam()
{
return m_param;
}
private: private:
MxCore *m_target; // 0x0 MxCore *m_target; // 0x0
MxParam *m_param; // 0x4 MxNotificationParam *m_param; // 0x4
}; };
class MxIdList : public list<MxU32> class MxIdList : public list<MxU32>
@ -54,7 +48,7 @@ class MxNotificationManager : public MxCore
virtual MxResult Create(MxS32 p_unk1, MxS32 p_unk2); // vtable+0x14 virtual MxResult Create(MxS32 p_unk1, MxS32 p_unk2); // vtable+0x14
void Register(MxCore *p_listener); void Register(MxCore *p_listener);
void Unregister(MxCore *p_listener); void Unregister(MxCore *p_listener);
MxResult Send(MxCore *p_listener, MxParam *p_param); MxResult Send(MxCore *p_listener, MxNotificationParam *p_param);
private: private:
void FlushPending(MxCore *p_listener); void FlushPending(MxCore *p_listener);

View File

@ -0,0 +1,11 @@
#include "mxnotificationparam.h"
#include "decomp.h"
DECOMP_SIZE_ASSERT(MxNotificationParam, 0xc);
// OFFSET: LEGO1 0x10010390
MxNotificationParam* MxNotificationParam::Clone()
{
return new MxNotificationParam(m_type, m_sender);
}

View File

@ -0,0 +1,35 @@
#ifndef MXNOTIFICATIONPARAM_H
#define MXNOTIFICATIONPARAM_H
#include "compat.h"
#include "mxparam.h"
#include "mxtypes.h"
class MxCore;
enum MxParamType
{
MXSTREAMER_UNKNOWN = 2,
MXPRESENTER_NOTIFICATION = 5,
MXSTREAMER_DELETE_NOTIFY = 6,
MXTRANSITIONMANAGER_TRANSITIONENDED = 24
};
// VTABLE 0x100d56e0
class MxNotificationParam : public MxParam
{
public:
inline MxNotificationParam(MxParamType p_type, MxCore *p_sender) : MxParam(), m_type(p_type), m_sender(p_sender){}
virtual ~MxNotificationParam() override {} // vtable+0x0 (scalar deleting destructor)
virtual MxNotificationParam *Clone(); // vtable+0x4
inline MxParamType GetType() const { return m_type; }
inline MxCore *GetSender() const { return m_sender; }
protected:
MxParamType m_type; // 0x4
MxCore *m_sender; // 0x8
};
#endif // MXNOTIFICATIONPARAM_H

View File

@ -351,7 +351,7 @@ MxLong MxOmni::Notify(MxParam &p)
{ {
MxAutoLocker lock(&this->m_criticalsection); MxAutoLocker lock(&this->m_criticalsection);
if (p.GetType() != MXSTREAMER_UNKNOWN) if (((MxNotificationParam&) p).GetType() != MXSTREAMER_UNKNOWN)
return 0; return 0;
return HandleNotificationType2(p); return HandleNotificationType2(p);

View File

@ -4,11 +4,11 @@
#include <windows.h> #include <windows.h>
#include "mxomnicreateflags.h" #include "mxomnicreateflags.h"
#include "mxomnicreateparambase.h" #include "mxparam.h"
#include "mxstring.h" #include "mxstring.h"
#include "mxvideoparam.h" #include "mxvideoparam.h"
class MxOmniCreateParam : public MxOmniCreateParamBase class MxOmniCreateParam : public MxParam
{ {
public: public:
__declspec(dllexport) MxOmniCreateParam(const char *mediaPath, struct HWND__ *windowHandle, MxVideoParam &vparam, MxOmniCreateFlags flags); __declspec(dllexport) MxOmniCreateParam(const char *mediaPath, struct HWND__ *windowHandle, MxVideoParam &vparam, MxOmniCreateFlags flags);

View File

@ -1 +0,0 @@
#include "mxomnicreateparam.h"

View File

@ -1,12 +0,0 @@
#ifndef MXOMNICREATEPARAMBASE_H
#define MXOMNICREATEPARAMBASE_H
// FIXME: Clearly not its real name
class MxOmniCreateParamBase
{
public:
virtual ~MxOmniCreateParamBase(){}
};
#endif // MXOMNICREATEPARAMBASE_H

View File

@ -1,11 +1 @@
#include "mxparam.h" #include "mxparam.h"
#include "decomp.h"
DECOMP_SIZE_ASSERT(MxParam, 0xc);
// OFFSET: LEGO1 0x10010390
MxParam* MxParam::Clone()
{
return new MxParam(m_type, m_sender);
}

View File

@ -1,42 +1,10 @@
#ifndef MXPARAM_H #ifndef MXPARAM_H
#define MXPARAM_H #define MXPARAM_H
#include "compat.h" class MxParam
#include "mxomnicreateparambase.h"
#include "mxtypes.h"
class MxCore;
enum MxParamType
{
MXSTREAMER_UNKNOWN = 2,
MXPRESENTER_NOTIFICATION = 5,
MXSTREAMER_DELETE_NOTIFY = 6,
MXTRANSITIONMANAGER_TRANSITIONENDED = 24
};
// VTABLE 0x100d56e0
class MxParam : public MxOmniCreateParamBase
{ {
public: public:
inline MxParam(MxParamType p_type, MxCore *p_sender) : MxOmniCreateParamBase(), m_type(p_type), m_sender(p_sender){} virtual ~MxParam() {}
virtual ~MxParam() override {} // vtable+0x0 (scalar deleting destructor)
virtual MxParam *Clone(); // vtable+0x4
inline MxParamType GetType() const
{
return m_type;
}
inline MxCore *GetSender() const
{
return m_sender;
}
protected:
MxParamType m_type; // 0x4
MxCore *m_sender; // 0x8
}; };
#endif // MXPARAM_H #endif // MXPARAM_H

View File

@ -6,6 +6,7 @@
#include "mxdsanim.h" #include "mxdsanim.h"
#include "mxdssound.h" #include "mxdssound.h"
#include "mxnotificationmanager.h" #include "mxnotificationmanager.h"
#include "mxactionnotificationparam.h"
#include "mxstreamer.h" #include "mxstreamer.h"
#include "decomp.h" #include "decomp.h"
#include "define.h" #include "define.h"
@ -65,7 +66,7 @@ void MxPresenter::SendTo_unkPresenter(MxOmni *p_omni)
if (m_unkPresenter) { if (m_unkPresenter) {
MxAutoLocker lock(&m_criticalSection); MxAutoLocker lock(&m_criticalSection);
NotificationManager()->Send(m_unkPresenter, &MxParam(MXPRESENTER_NOTIFICATION, this)); NotificationManager()->Send(m_unkPresenter, &MxNotificationParam(MXPRESENTER_NOTIFICATION, this));
m_action->SetOmni(p_omni ? p_omni : MxOmni::GetInstance()); m_action->SetOmni(p_omni ? p_omni : MxOmni::GetInstance());
m_unkPresenter = NULL; m_unkPresenter = NULL;
@ -143,7 +144,7 @@ void MxPresenter::EndAction()
MxAutoLocker lock(&this->m_criticalSection); MxAutoLocker lock(&this->m_criticalSection);
if (!this->m_unkPresenter) if (!this->m_unkPresenter)
{ {
MxOmni::GetInstance()->NotifyCurrentEntity(&MxUnknown2(MXSTREAMER_UNKNOWN, NULL, this->m_action, TRUE)); MxOmni::GetInstance()->NotifyCurrentEntity(&MxEndActionNotificationParam(MXSTREAMER_UNKNOWN, NULL, this->m_action, TRUE));
} }
this->m_action = FALSE; this->m_action = FALSE;

View File

@ -8,8 +8,6 @@
#include <algorithm> #include <algorithm>
DECOMP_SIZE_ASSERT(MxStreamer, 0x2c); DECOMP_SIZE_ASSERT(MxStreamer, 0x2c);
DECOMP_SIZE_ASSERT(MxUnknown1, 0x14)
DECOMP_SIZE_ASSERT(MxUnknown2, 0x14)
// OFFSET: LEGO1 0x100b8f00 // OFFSET: LEGO1 0x100b8f00
MxStreamer::MxStreamer() MxStreamer::MxStreamer()
@ -101,7 +99,7 @@ MxLong MxStreamer::Close(const char *p)
} }
// OFFSET: LEGO1 0x100b9700 // OFFSET: LEGO1 0x100b9700
MxParam *MxStreamerNotification::Clone() MxNotificationParam *MxStreamerNotification::Clone()
{ {
return new MxStreamerNotification(m_type, m_sender, m_controller); return new MxStreamerNotification(m_type, m_sender, m_controller);
} }
@ -122,7 +120,6 @@ MxStreamController *MxStreamer::GetOpenStream(const char *p_name)
return NULL; return NULL;
} }
// OFFSET: LEGO1 0x100b9930 // OFFSET: LEGO1 0x100b9930
MxResult MxStreamer::AddStreamControllerToOpenList(MxStreamController *stream) MxResult MxStreamer::AddStreamControllerToOpenList(MxStreamController *stream)
{ {
@ -153,7 +150,7 @@ MxResult MxStreamer::Unknown100b99b0(MxDSAction* p_action)
// OFFSET: LEGO1 0x100b9b60 // OFFSET: LEGO1 0x100b9b60
MxLong MxStreamer::Notify(MxParam &p) MxLong MxStreamer::Notify(MxParam &p)
{ {
if (p.GetType() == MXSTREAMER_DELETE_NOTIFY) { if (((MxNotificationParam&) p).GetType() == MXSTREAMER_DELETE_NOTIFY) {
MxDSAction ds; MxDSAction ds;
ds.SetUnknown24(-2); ds.SetUnknown24(-2);
@ -180,16 +177,4 @@ MxStreamerSubClass1::MxStreamerSubClass1(undefined4 size)
for (int i = 0; i >= 0; i--) { for (int i = 0; i >= 0; i--) {
ptr[i] = 0; ptr[i] = 0;
} }
} }
// OFFSET: LEGO1 0x100510c0
MxParam *MxUnknown1::Clone()
{
return new MxUnknown1(this->m_type, this->m_sender, this->m_action, this->m_realloc);
}
// OFFSET: LEGO1 0x10051270
MxParam *MxUnknown2::Clone()
{
return new MxUnknown2(MXSTREAMER_UNKNOWN, this->m_sender, this->m_action, this->m_realloc);
}

View File

@ -5,7 +5,7 @@
#include "decomp.h" #include "decomp.h"
#include "mxcore.h" #include "mxcore.h"
#include "mxparam.h" #include "mxnotificationparam.h"
#include "mxstreamcontroller.h" #include "mxstreamcontroller.h"
#include "mxtypes.h" #include "mxtypes.h"
@ -40,17 +40,17 @@ class MxStreamerSubClass3 : public MxStreamerSubClass1
inline MxStreamerSubClass3() : MxStreamerSubClass1(0x80) {} inline MxStreamerSubClass3() : MxStreamerSubClass1(0x80) {}
}; };
class MxStreamerNotification : public MxParam class MxStreamerNotification : public MxNotificationParam
{ {
public: public:
inline MxStreamerNotification(MxParamType p_type, MxCore *p_sender, MxStreamController *p_ctrlr) : MxParam(p_type, p_sender) inline MxStreamerNotification(MxParamType p_type, MxCore *p_sender, MxStreamController *p_ctrlr) : MxNotificationParam(p_type, p_sender)
{ {
m_controller = p_ctrlr; m_controller = p_ctrlr;
} }
virtual ~MxStreamerNotification() override {} virtual ~MxStreamerNotification() override {}
virtual MxParam *Clone() override; virtual MxNotificationParam *Clone() override;
MxStreamController *GetController() { return m_controller; } MxStreamController *GetController() { return m_controller; }
@ -102,64 +102,6 @@ class MxStreamer : public MxCore
list<MxStreamController *> m_openStreams; // 0x8 list<MxStreamController *> m_openStreams; // 0x8
MxStreamerSubClass2 m_subclass1; // 0x14 MxStreamerSubClass2 m_subclass1; // 0x14
MxStreamerSubClass3 m_subclass2; // 0x20 MxStreamerSubClass3 m_subclass2; // 0x20
};
// VTABLE 0x100d8350
// SIZE 0x14
class MxUnknown1 : public MxParam
{
public:
inline MxUnknown1(MxParamType p_type, MxCore *p_sender, MxDSAction *p_action, MxBool p_reallocAction) : MxParam(p_type, p_sender)
{
MxDSAction *oldAction = p_action;
this->m_realloc = p_reallocAction;
if (p_reallocAction)
{
this->m_action = new MxDSAction();
}
else
{
this->m_action = oldAction;
return;
}
this->m_action->SetAtomId(oldAction->m_atomId);
this->m_action->m_objectId = oldAction->m_objectId;
this->m_action->m_unk24 = oldAction->m_unk24;
}
inline virtual MxUnknown1::~MxUnknown1() override // 0x100511e0
{
if (this->m_realloc == FALSE)
{
return;
}
if (this->m_action)
{
delete this->m_action;
}
}
virtual MxParam *Clone() override; // vtable+0x4
MxDSAction *m_action; // 0xc
MxBool m_realloc; // 0x10
};
// VTABLE 0x100d8358
// SIZE 0x14
class MxUnknown2 : public MxUnknown1
{
public:
inline MxUnknown2(MxParamType p_type, MxCore *p_sender, MxDSAction *p_action, MxBool p_reallocAction)
: MxUnknown1(p_type, p_sender, p_action, p_reallocAction) {}
inline virtual ~MxUnknown2() override {}; // 0x100513a0
virtual MxParam *Clone() override; // vtable+0x4
}; };
#endif // MXSTREAMER_H #endif // MXSTREAMER_H

View File

@ -85,7 +85,7 @@ void MxTransitionManager::EndTransition(MxBool p_notifyWorld)
LegoWorld *world = GetCurrentWorld(); LegoWorld *world = GetCurrentWorld();
if (world) { if (world) {
world->Notify(MxParam(MXTRANSITIONMANAGER_TRANSITIONENDED, this)); world->Notify(MxNotificationParam(MXTRANSITIONMANAGER_TRANSITIONENDED, this));
} }
} }
} }