Improve MxOmni::Create match, make Create calls consistent

This commit is contained in:
Christian Semmler 2023-10-14 16:54:00 -04:00
parent 0c8705a9df
commit 689bc32a03
14 changed files with 70 additions and 101 deletions

View File

@ -37,14 +37,14 @@ void MxEventManager::Destroy(MxBool p_fromDestructor)
} }
// OFFSET: LEGO1 0x100c04a0 // OFFSET: LEGO1 0x100c04a0
MxResult MxEventManager::CreateEventThread(MxU32 p_frequencyMS, MxBool p_noRegister) MxResult MxEventManager::Create(MxU32 p_frequencyMS, MxBool p_createThread)
{ {
MxResult status = FAILURE; MxResult status = FAILURE;
MxBool locked = FALSE; MxBool locked = FALSE;
MxResult result = MxMediaManager::InitPresenters(); MxResult result = MxMediaManager::InitPresenters();
if (result == SUCCESS) { if (result == SUCCESS) {
if (p_noRegister) { if (p_createThread) {
this->m_criticalSection.Enter(); this->m_criticalSection.Enter();
locked = TRUE; locked = TRUE;
this->m_thread = new MxTickleThread(this, p_frequencyMS); this->m_thread = new MxTickleThread(this, p_frequencyMS);

View File

@ -13,7 +13,7 @@ class MxEventManager : public MxMediaManager
virtual ~MxEventManager() override; virtual ~MxEventManager() override;
virtual void Destroy() override; // vtable+18 virtual void Destroy() override; // vtable+18
virtual MxResult CreateEventThread(MxU32 p_frequencyMS, MxBool p_noRegister); // vtable+28 virtual MxResult Create(MxU32 p_frequencyMS, MxBool p_createThread); // vtable+28
private: private:
void Init(); void Init();

View File

@ -120,7 +120,7 @@ void MxMusicManager::SetVolume(MxS32 p_volume)
} }
// OFFSET: LEGO1 0x100c0840 // OFFSET: LEGO1 0x100c0840
MxResult MxMusicManager::StartMIDIThread(MxU32 p_frequencyMS, MxBool p_createThread) MxResult MxMusicManager::Create(MxU32 p_frequencyMS, MxBool p_createThread)
{ {
MxResult status = FAILURE; MxResult status = FAILURE;
MxBool locked = FALSE; MxBool locked = FALSE;

View File

@ -14,7 +14,7 @@ class MxMusicManager : public MxAudioManager
virtual void Destroy() override; // vtable+18 virtual void Destroy() override; // vtable+18
virtual void SetVolume(MxS32 p_volume) override; // vtable+2c virtual void SetVolume(MxS32 p_volume) override; // vtable+2c
virtual MxResult StartMIDIThread(MxU32 p_frequencyMS, MxBool p_createThread); // vtable+30 virtual MxResult Create(MxU32 p_frequencyMS, MxBool p_createThread); // vtable+30
inline MxBool GetMIDIInitialized() { return m_MIDIInitialized; } inline MxBool GetMIDIInitialized() { return m_MIDIInitialized; }

View File

@ -72,7 +72,7 @@ MxResult MxNotificationManager::Tickle()
} }
// OFFSET: LEGO1 0x100ac600 // OFFSET: LEGO1 0x100ac600
MxResult MxNotificationManager::Create(MxS32 p_unk1, MxS32 p_unk2) MxResult MxNotificationManager::Create(MxU32 p_frequencyMS, MxBool p_createThread)
{ {
MxResult result = SUCCESS; MxResult result = SUCCESS;
m_queue = new MxNotificationPtrList(); m_queue = new MxNotificationPtrList();

View File

@ -45,7 +45,7 @@ class MxNotificationManager : public MxCore
virtual MxResult Tickle(); // vtable+0x8 virtual MxResult Tickle(); // vtable+0x8
// TODO: Where does this method come from? // TODO: Where does this method come from?
virtual MxResult Create(MxS32 p_unk1, MxS32 p_unk2); // vtable+0x14 virtual MxResult Create(MxU32 p_frequencyMS, MxBool p_createThread); // 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, MxNotificationParam *p_param); MxResult Send(MxCore *p_listener, MxNotificationParam *p_param);

View File

@ -189,118 +189,87 @@ void MxOmni::SetInstance(MxOmni *instance)
MxResult MxOmni::Create(MxOmniCreateParam &p) MxResult MxOmni::Create(MxOmniCreateParam &p)
{ {
MxResult result = FAILURE; MxResult result = FAILURE;
m_atomIdCounterSet = new MxAtomIdCounterSet();
if (m_atomIdCounterSet == NULL) if (!(m_atomIdCounterSet = new MxAtomIdCounterSet()))
{ goto done;
goto failure;
}
m_mediaPath = p.GetMediaPath(); m_mediaPath = p.GetMediaPath();
m_windowHandle = p.GetWindowHandle(); m_windowHandle = p.GetWindowHandle();
if (p.CreateFlags().CreateObjectFactory())
{
MxObjectFactory *objectFactory = new MxObjectFactory();
this->m_objectFactory = objectFactory;
if (objectFactory == NULL) if (p.CreateFlags().CreateObjectFactory()) {
goto failure; if (!(m_objectFactory = new MxObjectFactory()))
goto done;
} }
if (p.CreateFlags().CreateVariableTable()) if (p.CreateFlags().CreateVariableTable()) {
{ if (!(m_variableTable = new MxVariableTable()))
MxVariableTable *variableTable = new MxVariableTable(); goto done;
this->m_variableTable = variableTable;
if (variableTable == NULL)
goto failure;
} }
if (p.CreateFlags().CreateTimer()) if (p.CreateFlags().CreateTimer()) {
{ if (!(m_timer = new MxTimer()))
MxTimer *timer = new MxTimer(); goto done;
this->m_timer = timer;
if (timer == NULL)
return FAILURE;
} }
if (p.CreateFlags().CreateTickleManager()) if (p.CreateFlags().CreateTickleManager()) {
{ if (!(m_tickleManager = new MxTickleManager()))
this->m_tickleManager = new MxTickleManager(); goto done;
if (m_tickleManager == NULL)
goto failure;
} }
if (p.CreateFlags().CreateNotificationManager()) if (p.CreateFlags().CreateNotificationManager()) {
{ if (m_notificationManager = new MxNotificationManager()) {
MxNotificationManager *notificationManager = new MxNotificationManager(); if (m_notificationManager->Create(100, 0) != SUCCESS)
this->m_notificationManager = notificationManager; goto done;
if (notificationManager == NULL || notificationManager->Create(100, 0) != SUCCESS)
goto failure;
}
if (p.CreateFlags().CreateStreamer())
{
MxStreamer *streamer = new MxStreamer();
this->m_streamer = streamer;
if (streamer == NULL || streamer->Init() != SUCCESS)
goto failure;
}
if (p.CreateFlags().CreateVideoManager())
{
MxVideoManager *videoManager = new MxVideoManager();
this->m_videoManager = videoManager;
if (videoManager && videoManager->Create(p.GetVideoParam(), 100, 0) != SUCCESS) {
delete m_videoManager;
m_videoManager = NULL;
} }
} }
if (p.CreateFlags().CreateSoundManager()) if (p.CreateFlags().CreateStreamer()) {
{ if (m_streamer = new MxStreamer()) {
MxSoundManager *soundManager = new MxSoundManager(); if (m_streamer->Create() != SUCCESS)
this->m_soundManager = soundManager; goto done;
//TODO
if (soundManager != NULL && soundManager->StartDirectSound(10, 0) != SUCCESS)
{
delete m_soundManager;
m_soundManager = NULL;
} }
} }
if (p.CreateFlags().CreateMusicManager()) if (p.CreateFlags().CreateVideoManager()) {
{ if (m_videoManager = new MxVideoManager()) {
MxMusicManager *musicManager = new MxMusicManager(); if (m_videoManager->Create(p.GetVideoParam(), 100, 0) != SUCCESS) {
this->m_musicManager = musicManager; delete m_videoManager;
if (musicManager != NULL && musicManager->StartMIDIThread(50, 0) != SUCCESS) m_videoManager = NULL;
{ }
delete m_musicManager;
m_musicManager = NULL;
} }
} }
if (p.CreateFlags().CreateEventManager()) if (p.CreateFlags().CreateSoundManager()) {
{ if (m_soundManager = new MxSoundManager()) {
MxEventManager *eventManager = new MxEventManager(); if (m_soundManager->Create(10, 0) != SUCCESS) {
this->m_eventManager = eventManager; delete m_soundManager;
if (m_eventManager != NULL && m_eventManager->CreateEventThread(50, 0) != SUCCESS) m_soundManager = NULL;
{ }
delete m_eventManager; }
m_eventManager = NULL; }
if (p.CreateFlags().CreateMusicManager()) {
if (m_musicManager = new MxMusicManager()) {
if (m_musicManager->Create(50, 0) != SUCCESS) {
delete m_musicManager;
m_musicManager = NULL;
}
}
}
if (p.CreateFlags().CreateEventManager()) {
if (m_eventManager = new MxEventManager()) {
if (m_eventManager->Create(50, 0) != SUCCESS) {
delete m_eventManager;
m_eventManager = NULL;
}
} }
} }
result = SUCCESS; result = SUCCESS;
failure: done:
if (result != SUCCESS) if (result != SUCCESS)
{
Destroy(); Destroy();
}
return result; return result;
} }

View File

@ -14,7 +14,7 @@ class MxOmniCreateParam : public MxParam
__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);
const MxOmniCreateFlags& CreateFlags() const { return this->m_createFlags; } const MxOmniCreateFlags& CreateFlags() const { return this->m_createFlags; }
const MxString GetMediaPath() const { return m_mediaPath; } const const MxString& GetMediaPath() const { return m_mediaPath; }
const HWND GetWindowHandle() const { return m_windowHandle; } const HWND GetWindowHandle() const { return m_windowHandle; }
MxVideoParam& GetVideoParam() { return m_videoParam; } MxVideoParam& GetVideoParam() { return m_videoParam; }

View File

@ -49,9 +49,9 @@ void MxSoundManager::Destroy(MxBool p_fromDestructor)
} }
// OFFSET: LEGO1 0x100ae8b0 STUB // OFFSET: LEGO1 0x100ae8b0 STUB
MxResult MxSoundManager::StartDirectSound(undefined4 p_unknown1, MxBool p_unknown2) MxResult MxSoundManager::Create(MxU32 p_frequencyMS, MxBool p_createThread)
{ {
// TODO STUB // TODO
return FAILURE; return FAILURE;
} }

View File

@ -14,7 +14,7 @@ class MxSoundManager : public MxAudioManager
MxSoundManager(); MxSoundManager();
virtual ~MxSoundManager() override; // vtable+0x0 virtual ~MxSoundManager() override; // vtable+0x0
virtual MxResult StartDirectSound(undefined4 p_unknown1, MxBool p_unknown2); //vtable+0x30 virtual MxResult Create(MxU32 p_frequencyMS, MxBool p_createThread); //vtable+0x30
virtual void vtable0x34(); // vtable+0x34 virtual void vtable0x34(); // vtable+0x34
virtual void vtable0x38(); // vtable+0x38 virtual void vtable0x38(); // vtable+0x38

View File

@ -16,7 +16,7 @@ MxStreamer::MxStreamer()
} }
// OFFSET: LEGO1 0x100b9190 // OFFSET: LEGO1 0x100b9190
MxResult MxStreamer::Init() MxResult MxStreamer::Create()
{ {
undefined *b = new undefined[m_subclass1.GetSize() * 0x5800]; undefined *b = new undefined[m_subclass1.GetSize() * 0x5800];
m_subclass1.SetBuffer(b); m_subclass1.SetBuffer(b);

View File

@ -90,7 +90,7 @@ class MxStreamer : public MxCore
return !strcmp(p_name, MxStreamer::ClassName()) || MxCore::IsA(p_name); return !strcmp(p_name, MxStreamer::ClassName()) || MxCore::IsA(p_name);
} }
virtual MxResult Init(); // vtable+0x14 virtual MxResult Create(); // vtable+0x14
MxStreamController *GetOpenStream(const char *p_name); MxStreamController *GetOpenStream(const char *p_name);

View File

@ -56,7 +56,7 @@ void MxString::ToLowerCase()
} }
// OFFSET: LEGO1 0x100ae4b0 // OFFSET: LEGO1 0x100ae4b0
MxString &MxString::operator=(MxString &param) MxString &MxString::operator=(const MxString &param)
{ {
if (this->m_data != param.m_data) if (this->m_data != param.m_data)
{ {

View File

@ -15,7 +15,7 @@ class MxString : public MxCore
MxString(const char *); MxString(const char *);
void ToUpperCase(); void ToUpperCase();
void ToLowerCase(); void ToLowerCase();
MxString& operator=(MxString &); MxString& operator=(const MxString &);
MxString operator+(const char *); MxString operator+(const char *);
MxString& operator+=(const char *); MxString& operator+=(const char *);