diff --git a/LEGO1/omni/include/mxcore.h b/LEGO1/omni/include/mxcore.h index 7fe5afbc..badecfa7 100644 --- a/LEGO1/omni/include/mxcore.h +++ b/LEGO1/omni/include/mxcore.h @@ -9,6 +9,7 @@ class MxParam; // VTABLE: LEGO1 0x100dc0f8 +// VTABLE: BETA10 0x101c1bc8 // SIZE 0x08 class MxCore { public: @@ -17,9 +18,11 @@ class MxCore { virtual MxLong Notify(MxParam& p_param); // vtable+04 // FUNCTION: LEGO1 0x10001f70 + // FUNCTION: BETA10 0x1000f380 virtual MxResult Tickle() { return SUCCESS; } // vtable+08 // FUNCTION: LEGO1 0x100144c0 + // FUNCTION: BETA10 0x100126d0 inline virtual const char* ClassName() const // vtable+0c { // STRING: LEGO1 0x100f007c @@ -27,6 +30,7 @@ class MxCore { } // FUNCTION: LEGO1 0x100140d0 + // FUNCTION: BETA10 0x10012680 inline virtual MxBool IsA(const char* p_name) const // vtable+10 { return !strcmp(p_name, MxCore::ClassName()); @@ -35,6 +39,7 @@ class MxCore { inline MxU32 GetId() { return m_id; } // SYNTHETIC: LEGO1 0x100ae1c0 + // SYNTHETIC: BETA10 0x1012c0d0 // MxCore::`scalar deleting destructor' private: diff --git a/LEGO1/omni/include/mxhashtable.h b/LEGO1/omni/include/mxhashtable.h index f2506758..e15128e9 100644 --- a/LEGO1/omni/include/mxhashtable.h +++ b/LEGO1/omni/include/mxhashtable.h @@ -13,12 +13,12 @@ class MxHashTableCursor; template class MxHashTableNode { public: - MxHashTableNode(T p_obj, MxU32 p_hash) + MxHashTableNode(T p_obj, MxU32 p_hash, MxHashTableNode* p_prev, MxHashTableNode* p_next) { m_obj = p_obj; m_hash = p_hash; - m_prev = NULL; - m_next = NULL; + m_prev = p_prev; + m_next = p_next; } // DECOMP: Should use getter and setter methods here per the style guide. @@ -41,7 +41,8 @@ class MxHashTable : protected MxCollection { MxHashTable() { m_numSlots = HASH_TABLE_INIT_SIZE; - m_slots = new MxHashTableNode*[HASH_TABLE_INIT_SIZE]; + MxU32 unused = 0; + m_slots = new MxHashTableNode*[m_numSlots]; memset(m_slots, 0, sizeof(MxHashTableNode*) * m_numSlots); m_resizeOption = e_noExpand; } @@ -94,15 +95,11 @@ template MxBool MxHashTableCursor::Find(T p_obj) { MxU32 hash = m_table->Hash(p_obj); - MxS32 bucket = hash % m_table->m_numSlots; - MxHashTableNode* t = m_table->m_slots[bucket]; - - while (t) { + for (MxHashTableNode* t = m_table->m_slots[hash % m_table->m_numSlots]; t; t = t->m_next) { if (t->m_hash == hash && !m_table->Compare(t->m_obj, p_obj)) { m_match = t; } - t = t->m_next; } return m_match != NULL; @@ -123,52 +120,46 @@ void MxHashTableCursor::DeleteMatch() { // Cut the matching node out of the linked list // by updating pointer references. - if (m_match == NULL) { - return; - } + if (m_match) { + if (m_match->m_prev) { + m_match->m_prev->m_next = m_match->m_next; + } + else { + // No "prev" node, so move "next" to the head of the list. + m_table->m_slots[m_match->m_hash % m_table->m_numSlots] = m_match->m_next; + } - if (m_match->m_prev) { - m_match->m_prev->m_next = m_match->m_next; - } - else { - // No "prev" node, so move "next" to the head of the list. - MxS32 bucket = m_match->m_hash % m_table->m_numSlots; - m_table->m_slots[bucket] = m_match->m_next; - } + if (m_match->m_next) { + m_match->m_next->m_prev = m_match->m_prev; + } - if (m_match->m_next) { - m_match->m_next->m_prev = m_match->m_prev; + m_table->m_customDestructor(m_match->m_obj); + delete m_match; + m_table->m_count--; } - - m_table->m_customDestructor(m_match->m_obj); - delete m_match; - m_table->m_count--; } template MxHashTable::~MxHashTable() { DeleteAll(); + delete[] m_slots; } template void MxHashTable::DeleteAll() { for (MxS32 i = 0; i < m_numSlots; i++) { - MxHashTableNode* t = m_slots[i]; - - while (t) { - MxHashTableNode* next = t->m_next; + MxHashTableNode* next; + for (MxHashTableNode* t = m_slots[i]; t != NULL; t = next) { + next = t->m_next; this->m_customDestructor(t->m_obj); delete t; - t = next; } } this->m_count = 0; memset(m_slots, 0, sizeof(MxHashTableNode*) * m_numSlots); - - delete[] m_slots; } template @@ -188,18 +179,16 @@ inline void MxHashTable::Resize() break; } - MxHashTableNode** newTable = new MxHashTableNode*[m_numSlots]; - m_slots = newTable; + MxU32 unused = 0; + m_slots = new MxHashTableNode*[m_numSlots]; memset(m_slots, 0, sizeof(MxHashTableNode*) * m_numSlots); this->m_count = 0; - for (MxS32 i = 0; i != oldSize; i++) { - MxHashTableNode* t = oldTable[i]; - - while (t) { - MxHashTableNode* next = t->m_next; + for (MxS32 i = 0; i < oldSize; i++) { + MxHashTableNode* next; + for (MxHashTableNode* t = oldTable[i]; t != NULL; t = next) { + next = t->m_next; NodeInsert(t); - t = next; } } @@ -229,7 +218,9 @@ inline void MxHashTable::Add(T p_newobj) } MxU32 hash = Hash(p_newobj); - MxHashTableNode* node = new MxHashTableNode(p_newobj, hash); + MxU32 unused = 0; + + MxHashTableNode* node = new MxHashTableNode(p_newobj, hash, NULL, NULL); MxHashTable::NodeInsert(node); } diff --git a/LEGO1/omni/include/mxvariable.h b/LEGO1/omni/include/mxvariable.h index d201cd39..6ad125de 100644 --- a/LEGO1/omni/include/mxvariable.h +++ b/LEGO1/omni/include/mxvariable.h @@ -5,31 +5,38 @@ #include "mxstring.h" // VTABLE: LEGO1 0x100d7498 +// VTABLE: BETA10 0x101bc038 // SIZE 0x24 class MxVariable { public: MxVariable() {} - MxVariable(const char* p_key) - { - m_key = p_key; - m_key.ToUpperCase(); - } + // FUNCTION: BETA10 0x1012a840 MxVariable(const char* p_key, const char* p_value) { m_key = p_key; m_key.ToUpperCase(); m_value = p_value; } + // FUNCTION: BETA10 0x1012aa30 + MxVariable(const char* p_key) + { + m_key = p_key; + m_key.ToUpperCase(); + } // FUNCTION: LEGO1 0x1003bea0 + // FUNCTION: BETA10 0x1007b810 virtual MxString* GetValue() { return &m_value; } // vtable+0x00 // FUNCTION: LEGO1 0x1003beb0 + // FUNCTION: BETA10 0x1007b840 virtual void SetValue(const char* p_value) { m_value = p_value; } // vtable+0x04 // FUNCTION: LEGO1 0x1003bec0 + // FUNCTION: BETA10 0x1007b870 virtual void Destroy() { delete this; } // vtable+0x08 + // FUNCTION: BETA10 0x1012a7f0 inline const MxString* GetKey() const { return &m_key; } protected: diff --git a/LEGO1/omni/include/mxvariabletable.h b/LEGO1/omni/include/mxvariabletable.h index 81059f9d..a9dab29e 100644 --- a/LEGO1/omni/include/mxvariabletable.h +++ b/LEGO1/omni/include/mxvariabletable.h @@ -6,66 +6,115 @@ #include "mxvariable.h" // VTABLE: LEGO1 0x100dc1c8 +// VTABLE: BETA10 0x101c1c78 // SIZE 0x28 class MxVariableTable : public MxHashTable { public: - MxVariableTable() { m_customDestructor = Destroy; } + // FUNCTION: BETA10 0x10130e50 + MxVariableTable() { SetDestroy(Destroy); } void SetVariable(const char* p_key, const char* p_value); void SetVariable(MxVariable* p_var); const char* GetVariable(const char* p_key); + // FUNCTION: LEGO1 0x100afdb0 + // FUNCTION: BETA10 0x10130f00 static void Destroy(MxVariable* p_obj) { p_obj->Destroy(); } MxS8 Compare(MxVariable*, MxVariable*) override; // vtable+0x14 MxU32 Hash(MxVariable*) override; // vtable+0x18 // SYNTHETIC: LEGO1 0x100afdd0 + // SYNTHETIC: BETA10 0x10130f20 // MxVariableTable::`scalar deleting destructor' }; // VTABLE: LEGO1 0x100dc1b0 +// VTABLE: BETA10 0x101c1cd0 // class MxCollection // VTABLE: LEGO1 0x100dc1e8 +// VTABLE: BETA10 0x101c1cb0 // class MxHashTable // VTABLE: LEGO1 0x100dc680 +// VTABLE: BETA10 0x101c1b48 // class MxHashTableCursor // TEMPLATE: LEGO1 0x100afcd0 +// TEMPLATE: BETA10 0x10132950 // MxCollection::Compare // TEMPLATE: LEGO1 0x100afce0 +// TEMPLATE: BETA10 0x10132a00 // MxCollection::~MxCollection // TEMPLATE: LEGO1 0x100afd30 +// TEMPLATE: BETA10 0x10132a70 // MxCollection::Destroy // SYNTHETIC: LEGO1 0x100afd40 +// SYNTHETIC: BETA10 0x10132a80 // MxCollection::`scalar deleting destructor' -// TEMPLATE: LEGO1 0x100afdb0 -// MxVariableTable::Destroy - // TEMPLATE: LEGO1 0x100afdc0 +// TEMPLATE: BETA10 0x10132ac0 // MxHashTable::Hash // TEMPLATE: LEGO1 0x100b0bd0 +// TEMPLATE: BETA10 0x10132ae0 // MxHashTable::~MxHashTable // SYNTHETIC: LEGO1 0x100b0ca0 +// SYNTHETIC: BETA10 0x10132b70 // MxHashTable::`scalar deleting destructor' // TEMPLATE: LEGO1 0x100b7680 +// TEMPLATE: BETA10 0x1012a990 // MxHashTableCursor::~MxHashTableCursor // SYNTHETIC: LEGO1 0x100b76d0 +// SYNTHETIC: BETA10 0x1012a9f0 // MxHashTableCursor::`scalar deleting destructor' // TEMPLATE: LEGO1 0x100b7ab0 +// TEMPLATE: BETA10 0x1012adc0 // MxHashTable::Resize // TEMPLATE: LEGO1 0x100b7b80 +// TEMPLATE: BETA10 0x1012af10 // MxHashTable::NodeInsert +// TEMPLATE: BETA10 0x1012a900 +// MxHashTableCursor::MxHashTableCursor + +// TEMPLATE: BETA10 0x1012aae0 +// MxHashTable::Add + +// TEMPLATE: BETA10 0x1012abd0 +// MxHashTableCursor::Current + +// TEMPLATE: BETA10 0x1012ac20 +// MxHashTableCursor::DeleteMatch + +// TEMPLATE: BETA10 0x1012ad00 +// MxHashTableCursor::Find + +// TEMPLATE: BETA10 0x1012af90 +// MxHashTableNode::MxHashTableNode + +// TEMPLATE: BETA10 0x10132890 +// MxHashTable::MxHashTable + +// TEMPLATE: BETA10 0x10130ed0 +// MxCollection::SetDestroy + +// SYNTHETIC: BETA10 0x10130f60 +// MxVariableTable::~MxVariableTable + +// SYNTHETIC: BETA10 0x10132970 +// MxCollection::MxCollection + +// TEMPLATE: BETA10 0x10132bb0 +// MxHashTable::DeleteAll + #endif // MXVARIABLETABLE_H diff --git a/LEGO1/omni/src/common/mxcore.cpp b/LEGO1/omni/src/common/mxcore.cpp index c07cc51a..cb315432 100644 --- a/LEGO1/omni/src/common/mxcore.cpp +++ b/LEGO1/omni/src/common/mxcore.cpp @@ -3,9 +3,11 @@ #include // GLOBAL: LEGO1 0x1010141c +// GLOBAL: BETA10 0x10201f88 MxU32 MxCore::g_nextCoreId = 0; // FUNCTION: LEGO1 0x100ae1a0 +// FUNCTION: BETA10 0x1012c020 MxCore::MxCore() { m_id = g_nextCoreId++; @@ -13,11 +15,13 @@ MxCore::MxCore() } // FUNCTION: LEGO1 0x100ae1e0 +// FUNCTION: BETA10 0x1012c077 MxCore::~MxCore() { } // FUNCTION: LEGO1 0x100ae1f0 +// FUNCTION: BETA10 0x1012c096 MxLong MxCore::Notify(MxParam& p_param) { assert(0); diff --git a/LEGO1/omni/src/common/mxvariabletable.cpp b/LEGO1/omni/src/common/mxvariabletable.cpp index 94bdbacb..6e76ddc4 100644 --- a/LEGO1/omni/src/common/mxvariabletable.cpp +++ b/LEGO1/omni/src/common/mxvariabletable.cpp @@ -1,18 +1,20 @@ #include "mxvariabletable.h" // FUNCTION: LEGO1 0x100b7330 +// FUNCTION: BETA10 0x1012a470 MxS8 MxVariableTable::Compare(MxVariable* p_var0, MxVariable* p_var1) { return p_var0->GetKey()->Compare(*p_var1->GetKey()); } // FUNCTION: LEGO1 0x100b7370 +// FUNCTION: BETA10 0x1012a4a0 MxU32 MxVariableTable::Hash(MxVariable* p_var) { const char* str = p_var->GetKey()->GetData(); MxU32 value = 0; - for (int i = 0; str[i]; i++) { + for (MxS32 i = 0; str[i]; i++) { value += str[i]; } @@ -20,6 +22,7 @@ MxU32 MxVariableTable::Hash(MxVariable* p_var) } // FUNCTION: LEGO1 0x100b73a0 +// FUNCTION: BETA10 0x1012a507 void MxVariableTable::SetVariable(const char* p_key, const char* p_value) { MxHashTableCursor cursor(this); @@ -36,12 +39,12 @@ void MxVariableTable::SetVariable(const char* p_key, const char* p_value) } // FUNCTION: LEGO1 0x100b7740 +// FUNCTION: BETA10 0x1012a629 void MxVariableTable::SetVariable(MxVariable* p_var) { MxHashTableCursor cursor(this); - MxBool found = cursor.Find(p_var); - if (found) { + if (cursor.Find(p_var)) { cursor.DeleteMatch(); } @@ -49,6 +52,7 @@ void MxVariableTable::SetVariable(MxVariable* p_var) } // FUNCTION: LEGO1 0x100b78f0 +// FUNCTION: BETA10 0x1012a6bd const char* MxVariableTable::GetVariable(const char* p_key) { // STRING: ISLE 0x41008c diff --git a/LEGO1/omni/src/main/mxomni.cpp b/LEGO1/omni/src/main/mxomni.cpp index 052099b1..bcd5cc75 100644 --- a/LEGO1/omni/src/main/mxomni.cpp +++ b/LEGO1/omni/src/main/mxomni.cpp @@ -77,6 +77,7 @@ void MxOmni::SetInstance(MxOmni* p_instance) } // FUNCTION: LEGO1 0x100af0c0 +// FUNCTION: BETA10 0x1012f3ff MxResult MxOmni::Create(MxOmniCreateParam& p_param) { MxResult result = FAILURE;