implement MxStreamer::Notify

This commit is contained in:
MattKC 2023-09-25 17:38:49 -07:00
parent 82d11dd6dc
commit bb01c62c43
5 changed files with 52 additions and 9 deletions

View File

@ -1,6 +1,7 @@
#ifndef MXPARAM_H
#define MXPARAM_H
#include "compat.h"
#include "mxomnicreateparambase.h"
#include "mxtypes.h"
@ -12,7 +13,7 @@ class MxParam : public MxOmniCreateParamBase
public:
inline MxParam(MxS32 p_type, MxCore *p_sender) : MxOmniCreateParamBase(), m_type(p_type), m_sender(p_sender){}
virtual ~MxParam(){}; // vtable+0x0 (scalar deleting destructor)
virtual ~MxParam() override {} // vtable+0x0 (scalar deleting destructor)
virtual MxParam *Clone(); // vtable+0x4
inline MxS32 GetType() const
@ -25,7 +26,7 @@ class MxParam : public MxOmniCreateParamBase
return m_sender;
}
private:
protected:
MxS32 m_type; // 0x4
MxCore *m_sender; // 0x8
};

View File

@ -15,7 +15,7 @@ MxStreamController::~MxStreamController()
}
// OFFSET: LEGO1 0x100c20d0 STUB
MxBool MxStreamController::CanBeDeleted()
MxBool MxStreamController::FUN_100c20d0(MxDSObject &p_obj)
{
// TODO
return TRUE;

View File

@ -5,6 +5,7 @@
#include "mxatomid.h"
#include "mxcriticalsection.h"
#include "mxcore.h"
#include "mxdsobject.h"
// VTABLE 0x100dc968
// SIZE 0x64
@ -30,7 +31,7 @@ class MxStreamController : public MxCore
virtual MxResult Open(const char *p_filename); // vtable+0x14
MxBool CanBeDeleted();
MxBool FUN_100c20d0(MxDSObject &p_obj);
MxCriticalSection m_criticalSection;
MxAtomId atom;

View File

@ -8,6 +8,8 @@
DECOMP_SIZE_ASSERT(MxStreamer, 0x2c);
#define MXSTREAMER_DELETE_NOTIFY 6
// OFFSET: LEGO1 0x100b8f00
MxStreamer::MxStreamer()
{
@ -69,10 +71,9 @@ MxStreamController *MxStreamer::Open(const char *p_name, MxU16 p_lookupType)
return stream;
}
// OFFSET: LEGO1 0x100b9570 STUB
// OFFSET: LEGO1 0x100b9570
MxLong MxStreamer::Close(const char *p)
{
// TODO: Incomplete
MxDSAction ds;
ds.SetUnknown24(-2);
@ -83,8 +84,10 @@ MxLong MxStreamer::Close(const char *p)
if (!p || !strcmp(p, c->atom.GetInternal())) {
m_openStreams.erase(it);
if (!c->CanBeDeleted()) {
// TODO: Send notification to `c`
if (!c->FUN_100c20d0(ds)) {
MxStreamerNotification notif(MXSTREAMER_DELETE_NOTIFY, NULL, c);
NotificationManager()->Send(this, &notif);
} else {
delete c;
}
@ -96,6 +99,12 @@ MxLong MxStreamer::Close(const char *p)
return FAILURE;
}
// OFFSET: LEGO1 0x100b9700
MxParam *MxStreamerNotification::Clone()
{
return new MxStreamerNotification(m_type, m_sender, m_controller);
}
// OFFSET: LEGO1 0x100b9870
MxStreamController *MxStreamer::GetOpenStream(const char *p_name)
{
@ -127,7 +136,20 @@ MxResult MxStreamer::AddStreamControllerToOpenList(MxStreamController *stream)
// OFFSET: LEGO1 0x100b9b60
MxLong MxStreamer::Notify(MxParam &p)
{
// TODO
if (p.GetType() == MXSTREAMER_DELETE_NOTIFY) {
MxDSAction ds;
ds.SetUnknown24(-2);
MxStreamController *c = static_cast<MxStreamerNotification&>(p).GetController();
if (!c->FUN_100c20d0(ds)) {
MxStreamerNotification notif(MXSTREAMER_DELETE_NOTIFY, NULL, c);
NotificationManager()->Send(this, &notif);
} else {
delete c;
}
}
return 0;
}

View File

@ -5,6 +5,7 @@
#include "decomp.h"
#include "mxcore.h"
#include "mxparam.h"
#include "mxstreamcontroller.h"
#include "mxtypes.h"
@ -39,6 +40,24 @@ class MxStreamerSubClass3 : public MxStreamerSubClass1
inline MxStreamerSubClass3() : MxStreamerSubClass1(0x80) {}
};
class MxStreamerNotification : public MxParam
{
public:
inline MxStreamerNotification(MxS32 p_type, MxCore *p_sender, MxStreamController *p_ctrlr) : MxParam(p_type, p_sender)
{
m_controller = p_ctrlr;
}
virtual ~MxStreamerNotification() override {}
virtual MxParam *Clone() override;
MxStreamController *GetController() { return m_controller; }
private:
MxStreamController *m_controller;
};
// VTABLE 0x100dc710
// SIZE 0x2c
class MxStreamer : public MxCore