Beta matching MxAtom classes (#847)

* Beta matching MxAtom classes

* Remove unused getter

* Restore operator!= for modern compilers
This commit is contained in:
MS
2024-04-25 11:43:42 -04:00
committed by GitHub
parent 31f5143741
commit 612eec6889
6 changed files with 180 additions and 69 deletions

View File

@@ -4,33 +4,38 @@
#include "mxmisc.h"
#include "mxomni.h"
#include <assert.h>
DECOMP_SIZE_ASSERT(MxAtomId, 0x04);
DECOMP_SIZE_ASSERT(MxAtomIdCounter, 0x14);
DECOMP_SIZE_ASSERT(MxAtomIdCounterSet, 0x10);
DECOMP_SIZE_ASSERT(MxAtom, 0x14);
DECOMP_SIZE_ASSERT(MxAtomSet, 0x10);
// FUNCTION: LEGO1 0x100acf90
// FUNCTION: BETA10 0x1012308b
MxAtomId::MxAtomId(const char* p_str, LookupMode p_mode)
{
if (!MxOmni::GetInstance()) {
return;
}
if (!AtomIdCounterSet()) {
if (!AtomSet()) {
return;
}
MxAtomIdCounter* counter = GetCounter(p_str, p_mode);
m_internal = counter->GetKey()->GetData();
counter->Inc();
MxAtom* atom = GetAtom(p_str, p_mode);
*this = atom->GetKey();
atom->Inc();
}
// FUNCTION: LEGO1 0x100acfd0
// FUNCTION: BETA10 0x10123130
MxAtomId::~MxAtomId()
{
Destroy();
}
// FUNCTION: LEGO1 0x100acfe0
// FUNCTION: BETA10 0x101231a6
void MxAtomId::Destroy()
{
if (!m_internal) {
@@ -41,34 +46,36 @@ void MxAtomId::Destroy()
return;
}
if (!AtomIdCounterSet()) {
if (!AtomSet()) {
return;
}
#ifdef COMPAT_MODE
MxAtomIdCounterSet::iterator it;
MxAtomSet::iterator it;
{
MxAtomIdCounter idCounter(m_internal);
it = AtomIdCounterSet()->find(&idCounter);
MxAtom idAtom(m_internal);
it = AtomSet()->find(&idAtom);
}
#else
MxAtomIdCounterSet::iterator it = AtomIdCounterSet()->find(&MxAtomIdCounter(m_internal));
MxAtomSet::iterator it = AtomSet()->find(&MxAtom(m_internal));
#endif
assert(it != AtomSet()->end());
MxAtomIdCounter* counter = (MxAtomIdCounter*) (*it);
counter->Dec();
MxAtom* atom = (MxAtom*) (*it);
atom->Dec();
}
// FUNCTION: LEGO1 0x100ad1c0
// FUNCTION: BETA10 0x101232b9
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, e_exact);
counter->Inc();
if (p_atomId.m_internal && MxOmni::GetInstance() && AtomSet()) {
MxAtom* atom = GetAtom(p_atomId.m_internal, e_exact);
atom->Inc();
}
m_internal = p_atomId.m_internal;
@@ -77,36 +84,41 @@ MxAtomId& MxAtomId::operator=(const MxAtomId& p_atomId)
}
// FUNCTION: LEGO1 0x100ad210
MxAtomIdCounter* MxAtomId::GetCounter(const char* p_str, LookupMode p_mode)
// FUNCTION: BETA10 0x10123378
MxAtom* MxAtomId::GetAtom(const char* p_str, LookupMode p_mode)
{
MxAtomId unused;
MxAtomIdCounter* counter = new MxAtomIdCounter(p_str);
MxAtom* atom = new MxAtom(p_str);
assert(atom);
switch (p_mode) {
case e_lowerCase:
case e_lowerCase2:
counter->GetKey()->ToLowerCase();
case e_exact:
break;
case e_upperCase:
counter->GetKey()->ToUpperCase();
atom->GetKey().ToUpperCase();
break;
case e_lowerCase:
case e_lowerCase2:
atom->GetKey().ToLowerCase();
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;
MxAtomSet::iterator it = AtomSet()->find(atom);
if (it != AtomSet()->end()) {
// Atom already in the set. Delete temp value and return it.
delete atom;
atom = *it;
}
else {
// Counter is not in the set. Add it.
AtomIdCounterSet()->insert(counter);
// Atom is not in the set. Add it.
AtomSet()->insert(atom);
}
return counter;
return atom;
}
// FUNCTION: LEGO1 0x100ad7e0
// FUNCTION: BETA10 0x100553e0
void MxAtomId::Clear()
{
// Reset but do not delete MxAtomId object.
@@ -115,13 +127,15 @@ void MxAtomId::Clear()
}
// FUNCTION: LEGO1 0x100ad7f0
void MxAtomIdCounter::Inc()
// FUNCTION: BETA10 0x101235d5
void MxAtom::Inc()
{
m_value++;
}
// FUNCTION: LEGO1 0x100ad800
void MxAtomIdCounter::Dec()
// FUNCTION: BETA10 0x1012364a
void MxAtom::Dec()
{
if (m_value) {
m_value--;