Clean up Destroy pattern everywhere, fix missing overrides (#202)

* Rename MxMusicPresenter function vtable38

* Rename MxMusicPresenter function vtable38

* MxMediaPresenter, MxMusicManager and MxMusicPresenter
* Refactoring Destroy functions

* MxMediaManager & MxMusicPresenter

* Fix some vtable declarations, more renames

* Fix MxEventManager

* More rename fixes

---------

Co-authored-by: Christian Semmler <mail@csemmler.com>
This commit is contained in:
DmitriLeon2000
2023-10-14 01:43:45 +09:00
committed by GitHub
parent 91c3ed3e70
commit 34e09c2bb3
24 changed files with 104 additions and 115 deletions

View File

@@ -15,7 +15,7 @@ MxMusicManager::MxMusicManager()
// OFFSET: LEGO1 0x100c0630
MxMusicManager::~MxMusicManager()
{
LockedReinitialize(TRUE);
Destroy(TRUE);
}
// OFFSET: LEGO1 0x100c0b20
@@ -23,47 +23,47 @@ void MxMusicManager::DeinitializeMIDI()
{
m_criticalSection.Enter();
if (this->m_MIDIInitialized)
if (m_MIDIInitialized)
{
this->m_MIDIInitialized = FALSE;
midiStreamStop(this->m_MIDIStreamH);
midiOutUnprepareHeader(this->m_MIDIStreamH, this->m_MIDIHdrP, sizeof(MIDIHDR));
midiOutSetVolume(this->m_MIDIStreamH, this->m_MIDIVolume);
midiStreamClose(this->m_MIDIStreamH);
delete this->m_MIDIHdrP;
this->InitData();
m_MIDIInitialized = FALSE;
midiStreamStop(m_MIDIStreamH);
midiOutUnprepareHeader(m_MIDIStreamH, m_MIDIHdrP, sizeof(MIDIHDR));
midiOutSetVolume(m_MIDIStreamH, m_MIDIVolume);
midiStreamClose(m_MIDIStreamH);
delete m_MIDIHdrP;
InitData();
}
this->m_criticalSection.Leave();
m_criticalSection.Leave();
}
// OFFSET: LEGO1 0x100c0690
void MxMusicManager::Init()
{
this->m_multiplier = 100;
m_multiplier = 100;
InitData();
}
// OFFSET: LEGO1 0x100c06a0
void MxMusicManager::InitData()
{
this->m_MIDIStreamH = 0;
this->m_MIDIInitialized = FALSE;
this->m_unk38 = 0;
this->m_unk3c = 0;
this->m_unk40 = 0;
this->m_unk44 = 0;
this->m_unk48 = 0;
this->m_MIDIHdrP = NULL;
m_MIDIStreamH = 0;
m_MIDIInitialized = FALSE;
m_unk38 = 0;
m_unk3c = 0;
m_unk40 = 0;
m_unk44 = 0;
m_unk48 = 0;
m_MIDIHdrP = NULL;
}
// OFFSET: LEGO1 0x100c06c0
void MxMusicManager::LockedReinitialize(MxBool p_skipDestroy)
void MxMusicManager::Destroy(MxBool p_fromDestructor)
{
if (this->m_thread)
if (m_thread)
{
this->m_thread->Terminate();
if (this->m_thread)
m_thread->Terminate();
if (m_thread)
{
delete m_thread;
}
@@ -73,12 +73,12 @@ void MxMusicManager::LockedReinitialize(MxBool p_skipDestroy)
TickleManager()->UnregisterClient(this);
}
this->m_criticalSection.Enter();
m_criticalSection.Enter();
DeinitializeMIDI();
Init();
this->m_criticalSection.Leave();
m_criticalSection.Leave();
if (!p_skipDestroy)
if (!p_fromDestructor)
{
MxAudioManager::Destroy();
}
@@ -87,7 +87,7 @@ void MxMusicManager::LockedReinitialize(MxBool p_skipDestroy)
// OFFSET: LEGO1 0x100c0930
void MxMusicManager::Destroy()
{
LockedReinitialize(FALSE);
Destroy(FALSE);
}
// OFFSET: LEGO1 0x100c09a0
@@ -100,8 +100,8 @@ MxS32 MxMusicManager::CalculateVolume(MxS32 p_volume)
// OFFSET: LEGO1 0x100c07f0
void MxMusicManager::SetMIDIVolume()
{
MxS32 result = (this->m_volume * this->m_multiplier) / 0x64;
HMIDISTRM streamHandle = this->m_MIDIStreamH;
MxS32 result = (m_volume * m_multiplier) / 0x64;
HMIDISTRM streamHandle = m_MIDIStreamH;
if (streamHandle)
{
@@ -114,9 +114,9 @@ void MxMusicManager::SetMIDIVolume()
void MxMusicManager::SetVolume(MxS32 p_volume)
{
MxAudioManager::SetVolume(p_volume);
this->m_criticalSection.Enter();
m_criticalSection.Enter();
SetMIDIVolume();
this->m_criticalSection.Leave();
m_criticalSection.Leave();
}
// OFFSET: LEGO1 0x100c0840
@@ -130,13 +130,13 @@ MxResult MxMusicManager::StartMIDIThread(MxU32 p_frequencyMS, MxBool p_noRegiste
{
if (p_noRegister)
{
this->m_criticalSection.Enter();
m_criticalSection.Enter();
locked = TRUE;
this->m_thread = new MxTickleThread(this, p_frequencyMS);
m_thread = new MxTickleThread(this, p_frequencyMS);
if (this->m_thread)
if (m_thread)
{
if (this->m_thread->Start(0, 0) == SUCCESS)
if (m_thread->Start(0, 0) == SUCCESS)
{
status = SUCCESS;
}
@@ -156,7 +156,7 @@ MxResult MxMusicManager::StartMIDIThread(MxU32 p_frequencyMS, MxBool p_noRegiste
if (locked)
{
this->m_criticalSection.Leave();
m_criticalSection.Leave();
}
return status;