Isle
Loading...
Searching...
No Matches
mxvariabletable.cpp
Go to the documentation of this file.
1#include "mxvariabletable.h"
2
3// FUNCTION: LEGO1 0x100b7330
4// FUNCTION: BETA10 0x1012a470
6{
7 return p_var0->GetKey()->Compare(*p_var1->GetKey());
8}
9
10// FUNCTION: LEGO1 0x100b7370
11// FUNCTION: BETA10 0x1012a4a0
13{
14 const char* str = p_var->GetKey()->GetData();
15 MxU32 value = 0;
16
17 for (MxS32 i = 0; str[i]; i++) {
18 value += str[i];
19 }
20
21 return value;
22}
23
24// FUNCTION: LEGO1 0x100b73a0
25// FUNCTION: BETA10 0x1012a507
26void MxVariableTable::SetVariable(const char* p_key, const char* p_value)
27{
29 MxVariable* var = new MxVariable(p_key, p_value);
30
31 if (cursor.Find(var)) {
32 delete var;
33 cursor.Current(var);
34 var->SetValue(p_value);
35 }
36 else {
38 }
39}
40
41// FUNCTION: LEGO1 0x100b7740
42// FUNCTION: BETA10 0x1012a629
44{
46
47 if (cursor.Find(p_var)) {
48 cursor.DeleteMatch();
49 }
50
52}
53
54// FUNCTION: LEGO1 0x100b78f0
55// FUNCTION: BETA10 0x1012a6bd
56const char* MxVariableTable::GetVariable(const char* p_key)
57{
58 // STRING: ISLE 0x41008c
59 // STRING: LEGO1 0x100f01d4
60 const char* value = "";
62 MxVariable* var = new MxVariable(p_key);
63
64 MxBool found = cursor.Find(var);
65 delete var;
66
67 if (found) {
68 cursor.Current(var);
69 value = var->GetValue()->GetData();
70 }
71
72 return value;
73}
[AI] Non-intrusive search-and-edit cursor for navigating, querying, or deleting a specific entry in a...
Definition: mxhashtable.h:149
MxBool Find(T p_obj)
[AI] Finds and focuses the cursor on the first node matching the given object by hash and value; supp...
Definition: mxhashtable.h:190
void DeleteMatch()
[AI] If the cursor points to a match, removes it from table and destroys the node.
Definition: mxhashtable.h:214
MxBool Current(T &p_obj)
[AI] Retrieves the object at the current match position, if valid.
Definition: mxhashtable.h:204
void Add(T)
[AI] Inserts a new item into the hash table, possibly resizing if automatic resize is enabled and loa...
Definition: mxhashtable.h:309
char * GetData() const
Returns a pointer to the internal character buffer.
Definition: mxstring.h:110
MxS8 Compare(const MxString &p_str) const
Performs lexicographical comparison to another string.
Definition: mxstring.h:129
const char * GetVariable(const char *p_key)
Returns the value for the variable with a given key, or an empty string if not found.
MxS8 Compare(MxVariable *, MxVariable *) override
Implements the virtual table comparison for two MxVariable pointers.
MxU32 Hash(MxVariable *) override
Hashes the key of the given variable for use in the table.
void SetVariable(const char *p_key, const char *p_value)
Sets a variable by key and value, replacing or updating if it exists.
[AI] Represents a key-value variable as used in the variable table for the LEGO Island engine.
Definition: mxvariable.h:16
virtual MxString * GetValue()
[AI] Retrieves a pointer to the variable's value.
Definition: mxvariable.h:52
const MxString * GetKey() const
[AI] Provides read-only access to the variable's key/name.
Definition: mxvariable.h:71
virtual void SetValue(const char *p_value)
[AI] Sets the variable's value.
Definition: mxvariable.h:59
MxU8 MxBool
[AI]
Definition: mxtypes.h:124
signed int MxS32
[AI]
Definition: mxtypes.h:38
unsigned int MxU32
[AI]
Definition: mxtypes.h:32
signed char MxS8
[AI]
Definition: mxtypes.h:14