mirror of
https://github.com/isledecomp/isle.git
synced 2025-10-23 08:24:16 +00:00
Refactor MxHashTable/MxVariableTable (#283)
* Refactor MxHashTable/MxVariableTable * Use MxS8 for Compare return type * Cursor::DeleteMatch check and clang fix
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
// OFFSET: LEGO1 0x100b7330
|
||||
MxS8 MxVariableTable::Compare(MxVariable* p_var0, MxVariable* p_var1)
|
||||
{
|
||||
return strcmp(p_var0->GetKey()->GetData(), p_var1->GetKey()->GetData());
|
||||
return p_var0->GetKey()->Compare(*p_var1->GetKey());
|
||||
}
|
||||
|
||||
// OFFSET: LEGO1 0x100b7370
|
||||
@@ -22,43 +22,43 @@ MxU32 MxVariableTable::Hash(MxVariable* p_var)
|
||||
// OFFSET: LEGO1 0x100b73a0
|
||||
void MxVariableTable::SetVariable(const char* p_key, const char* p_value)
|
||||
{
|
||||
MxHashTableCursor<MxVariable> cursor(this);
|
||||
MxHashTableCursor<MxVariable*> cursor(this);
|
||||
MxVariable* var = new MxVariable(p_key, p_value);
|
||||
|
||||
if (cursor.Find(var)) {
|
||||
delete var;
|
||||
cursor.GetMatch(var);
|
||||
cursor.Current(var);
|
||||
var->SetValue(p_value);
|
||||
}
|
||||
else {
|
||||
MxHashTable<MxVariable>::Add(var);
|
||||
MxHashTable<MxVariable*>::Add(var);
|
||||
}
|
||||
}
|
||||
|
||||
// OFFSET: LEGO1 0x100b7740
|
||||
void MxVariableTable::SetVariable(MxVariable* var)
|
||||
void MxVariableTable::SetVariable(MxVariable* p_var)
|
||||
{
|
||||
MxHashTableCursor<MxVariable> cursor(this);
|
||||
MxBool found = cursor.Find(var);
|
||||
MxHashTableCursor<MxVariable*> cursor(this);
|
||||
MxBool found = cursor.Find(p_var);
|
||||
|
||||
if (found)
|
||||
cursor.DeleteMatch();
|
||||
|
||||
MxHashTable<MxVariable>::Add(var);
|
||||
MxHashTable<MxVariable*>::Add(p_var);
|
||||
}
|
||||
|
||||
// OFFSET: LEGO1 0x100b78f0
|
||||
const char* MxVariableTable::GetVariable(const char* p_key)
|
||||
{
|
||||
const char* value = "";
|
||||
MxHashTableCursor<MxVariable> cursor(this);
|
||||
MxHashTableCursor<MxVariable*> cursor(this);
|
||||
MxVariable* var = new MxVariable(p_key);
|
||||
|
||||
MxBool found = cursor.Find(var);
|
||||
delete var;
|
||||
|
||||
if (found) {
|
||||
cursor.GetMatch(var);
|
||||
cursor.Current(var);
|
||||
value = var->GetValue()->GetData();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user