isle-portable/LEGO1/mxvariabletable.cpp

67 lines
1.3 KiB
C++
Raw Normal View History

#include "mxvariabletable.h"
// OFFSET: LEGO1 0x100b7330
2023-10-24 19:38:27 -04:00
MxS8 MxVariableTable::Compare(MxVariable* p_var0, MxVariable* p_var1)
{
return p_var0->GetKey()->Compare(*p_var1->GetKey());
}
// OFFSET: LEGO1 0x100b7370
2023-10-24 19:38:27 -04:00
MxU32 MxVariableTable::Hash(MxVariable* p_var)
{
2023-10-24 19:38:27 -04:00
const char* str = p_var->GetKey()->GetData();
MxU32 value = 0;
2023-10-24 19:38:27 -04:00
for (int i = 0; str[i]; i++) {
value += str[i];
}
return value;
}
// OFFSET: LEGO1 0x100b73a0
2023-10-24 19:38:27 -04:00
void MxVariableTable::SetVariable(const char* p_key, const char* p_value)
{
MxHashTableCursor<MxVariable*> cursor(this);
2023-10-24 19:38:27 -04:00
MxVariable* var = new MxVariable(p_key, p_value);
2023-10-24 19:38:27 -04:00
if (cursor.Find(var)) {
delete var;
cursor.Current(var);
2023-10-24 19:38:27 -04:00
var->SetValue(p_value);
}
else {
MxHashTable<MxVariable*>::Add(var);
2023-10-24 19:38:27 -04:00
}
}
// OFFSET: LEGO1 0x100b7740
void MxVariableTable::SetVariable(MxVariable* p_var)
{
MxHashTableCursor<MxVariable*> cursor(this);
MxBool found = cursor.Find(p_var);
2023-10-24 19:38:27 -04:00
if (found)
cursor.DeleteMatch();
MxHashTable<MxVariable*>::Add(p_var);
}
// OFFSET: LEGO1 0x100b78f0
2023-10-24 19:38:27 -04:00
const char* MxVariableTable::GetVariable(const char* p_key)
{
2023-10-24 19:38:27 -04:00
const char* value = "";
MxHashTableCursor<MxVariable*> cursor(this);
2023-10-24 19:38:27 -04:00
MxVariable* var = new MxVariable(p_key);
MxBool found = cursor.Find(var);
delete var;
if (found) {
cursor.Current(var);
2023-10-24 19:38:27 -04:00
value = var->GetValue()->GetData();
}
2023-10-24 19:38:27 -04:00
return value;
}