Files
isle/LEGO1/mxatomid.cpp
Anonymous Maarten fbe7f8bbb0 Fix all mingw errors & warnings (#411)
* Use COMPAT_MODE macro to fix errors with mingw gcc 12.2

* MxOmni::m_timerRunning is a MxBool

* MxDirect3D::m_unk0x88c is a MxBool

* MxBackgroundAudioManager::m_unk0x13c is a MxS32

* Fix warning: deleting 'void*' is undefined [-Wdelete-incomplete]

* Fix inline function 'void TglImpl::RendererImpl::Destroy()' used but never defined

* Fix warning: inline function 'MxStreamerSubClass1::MxStreamerSubClass1(undefined4)' used but never defined

* Use `FALSE` for m_timerRunning

* Format

* Format

* Remove comment

* Limit scope for variables in compat mode

* clang-format

---------

Co-authored-by: Christian Semmler <mail@csemmler.com>
2024-01-07 18:30:45 +01:00

104 lines
2.0 KiB
C++

#include "mxatomid.h"
#include "mxomni.h"
// FUNCTION: LEGO1 0x100acf90
MxAtomId::MxAtomId(const char* p_str, LookupMode p_mode)
{
if (!MxOmni::GetInstance())
return;
if (!AtomIdCounterSet())
return;
MxAtomIdCounter* counter = GetCounter(p_str, p_mode);
m_internal = counter->GetKey()->GetData();
counter->Inc();
}
// FUNCTION: LEGO1 0x100acfd0
MxAtomId::~MxAtomId()
{
Destroy();
}
// FUNCTION: LEGO1 0x100acfe0
void MxAtomId::Destroy()
{
if (!m_internal)
return;
if (!MxOmni::GetInstance())
return;
if (!AtomIdCounterSet())
return;
#ifdef COMPAT_MODE
MxAtomIdCounterSet::iterator it;
{
MxAtomIdCounter id_counter(m_internal);
it = AtomIdCounterSet()->find(&id_counter);
}
#else
MxAtomIdCounterSet::iterator it = AtomIdCounterSet()->find(&MxAtomIdCounter(m_internal));
#endif
MxAtomIdCounter* counter = (MxAtomIdCounter*) (*it);
counter->Dec();
}
// FUNCTION: LEGO1 0x100ad1c0
MxAtomId& MxAtomId::operator=(const MxAtomId& p_atomId)
{
if (m_internal)
Destroy();
if (p_atomId.m_internal && MxOmni::GetInstance() && AtomIdCounterSet()) {
MxAtomIdCounter* counter = GetCounter(p_atomId.m_internal, LookupMode_Exact);
counter->Inc();
}
m_internal = p_atomId.m_internal;
return *this;
}
// FUNCTION: LEGO1 0x100ad210
MxAtomIdCounter* MxAtomId::GetCounter(const char* p_str, LookupMode p_mode)
{
MxAtomId unused;
MxAtomIdCounter* counter = new MxAtomIdCounter(p_str);
switch (p_mode) {
case LookupMode_LowerCase:
case LookupMode_LowerCase2:
counter->GetKey()->ToLowerCase();
break;
case LookupMode_UpperCase:
counter->GetKey()->ToUpperCase();
break;
}
MxAtomIdCounterSet::iterator it = AtomIdCounterSet()->find(counter);
if (it != AtomIdCounterSet()->end()) {
// Counter already in the set. Delete temp value and return it.
delete counter;
counter = *it;
}
else {
// Counter is not in the set. Add it.
AtomIdCounterSet()->insert(counter);
}
return counter;
}
// FUNCTION: LEGO1 0x100ad7e0
void MxAtomId::Clear()
{
// Reset but do not delete MxAtomId object.
Destroy();
m_internal = NULL;
}