Isle
Loading...
Searching...
No Matches
mxdsselectaction.cpp
Go to the documentation of this file.
1#include "mxdsselectaction.h"
2
3#include "mxmisc.h"
4#include "mxtimer.h"
5#include "mxvariabletable.h"
6
11
12// FUNCTION: LEGO1 0x100cb2b0
13// FUNCTION: BETA10 0x1015a515
15{
16 m_type = e_selectAction;
17 m_unk0xac = new MxStringList;
18}
19
20// FUNCTION: LEGO1 0x100cb8d0
21// FUNCTION: BETA10 0x1015a5fd
23{
24 delete m_unk0xac;
25}
26
27// FUNCTION: LEGO1 0x100cb950
28// FUNCTION: BETA10 0x1015a6ae
30{
31 m_unk0x9c = p_dsSelectAction.m_unk0x9c;
32
33 m_unk0xac->DeleteAll();
34
35 MxStringListCursor cursor(p_dsSelectAction.m_unk0xac);
36 MxString string;
37 while (cursor.Next(string)) {
38 m_unk0xac->Append(string);
39 }
40}
41
42// FUNCTION: BETA10 0x1015a7ad
44{
45 CopyFrom(p_dsSelectAction);
46}
47
48// FUNCTION: LEGO1 0x100cbd50
49// FUNCTION: BETA10 0x1015a84f
51{
52 if (this != &p_dsSelectAction) {
53 MxDSParallelAction::operator=(p_dsSelectAction);
54 CopyFrom(p_dsSelectAction);
55 }
56 return *this;
57}
58
59// FUNCTION: LEGO1 0x100cbd80
60// FUNCTION: BETA10 0x1015a88e
62{
64
65 if (clone) {
66 *clone = *this;
67 }
68
69 return clone;
70}
71
72// FUNCTION: LEGO1 0x100cbe10
73// FUNCTION: BETA10 0x1015a938
75{
76 MxU32 totalSizeOnDisk = MxDSParallelAction::GetSizeOnDisk();
77
78 totalSizeOnDisk += strlen(m_unk0x9c.GetData()) + 1;
79
80 MxStringListCursor cursor(m_unk0xac);
81 MxString string;
82 while (cursor.Next(string)) {
83 totalSizeOnDisk += strlen(string.GetData()) + 1;
84 }
85
86 // Note: unlike the other classes, MxDSSelectAction does not have its own
87 // sizeOnDisk member. Instead, it overrides the one from MxDSMultiAction.
88 m_sizeOnDisk = totalSizeOnDisk;
89
90 return totalSizeOnDisk;
91}
92
93// FUNCTION: LEGO1 0x100cbf60
94// FUNCTION: BETA10 0x1015aa30
95void MxDSSelectAction::Deserialize(MxU8*& p_source, MxS16 p_flags)
96{
97 MxDSAction* action = NULL;
98 MxString string;
99 MxDSAction::Deserialize(p_source, p_flags);
100
101 MxU32 extraFlag = *(MxU32*) (p_source + 4) & 1;
102 p_source += 12;
103
104 m_unk0x9c = (char*) p_source;
105
106 if (strnicmp(m_unk0x9c.GetData(), "RANDOM_", strlen("RANDOM_")) != 0) {
107 string = VariableTable()->GetVariable((char*) p_source);
108 }
109 else {
110 char buffer[10];
111 MxS16 value = atoi(&m_unk0x9c.GetData()[strlen("RANDOM_")]);
112
113 srand(Timer()->GetTime());
114 MxS32 random = rand() % value;
115 string = itoa((MxS16) random, buffer, 10);
116 }
117
118 p_source += strlen((char*) p_source) + 1;
119
120 MxU32 count = *(MxU32*) p_source;
121 p_source += sizeof(MxU32);
122
123 if (count) {
124 MxS32 index = -1;
125 m_unk0xac->DeleteAll();
126
127 MxU32 i;
128 for (i = 0; i < count; i++) {
129 if (!strcmp(string.GetData(), (char*) p_source)) {
130 index = i;
131 }
132
133 m_unk0xac->Append((char*) p_source);
134 p_source += strlen((char*) p_source) + 1;
135 }
136
137 for (i = 0; i < count; i++) {
138 MxU32 extraFlag = *(MxU32*) (p_source + 4) & 1;
139 p_source += 8;
140
141 action = (MxDSAction*) DeserializeDSObjectDispatch(p_source, p_flags);
142
143 if (index == i) {
144 m_actionList->Append(action);
145 }
146 else {
147 delete action;
148 }
149
150 p_source += extraFlag;
151 }
152 }
153
154 p_source += extraFlag;
155}
[AI] Represents an action deserialized from SI chunks, holding key animation or script parameters suc...
Definition: mxdsaction.h:17
MxU32 GetSizeOnDisk() override
[AI] Serializes the size on disk of this action (all fields + extra data length)
Definition: mxdsaction.cpp:113
void Deserialize(MxU8 *&p_source, MxS16 p_unk0x24) override
[AI] Deserializes this action's data from a binary buffer.
Definition: mxdsaction.cpp:259
MxDSActionList * m_actionList
[AI] List of contained actions (ownership: this owns and deletes subactions).
MxU32 m_sizeOnDisk
[AI] Stores the last-computed disk storage size for m_actionList and metadata.
[AI] Represents an action that can play multiple MxDSActions in parallel.
MxDSParallelAction & operator=(MxDSParallelAction &p_dsParallelAction)
[AI] Assignment operator.
[AI] Represents a "select" action within a DS (Script/Scene) file, deserialized from SI files to sele...
MxDSAction * Clone() override
[AI] Creates a deep copy ("clone") of this select action, including its internal strings and selected...
~MxDSSelectAction() override
[AI] Destructor.
void CopyFrom(MxDSSelectAction &p_dsSelectAction)
[AI] Copies all internal data from another MxDSSelectAction including string list and selection varia...
MxDSSelectAction()
[AI] Default constructor.
void Deserialize(MxU8 *&p_source, MxS16 p_unk0x24) override
[AI] Loads (deserializes) this action from a binary source buffer.
MxU32 GetSizeOnDisk() override
[AI] Computes the total size needed to serialize this object to disk, including selection strings and...
MxDSSelectAction & operator=(MxDSSelectAction &p_dsSelectAction)
[AI] Assignment operator; performs a deep copy of the source select action, including all sub-actions...
MxBool Next()
[AI]
[AI]
Definition: mxlist.h:20
void DeleteAll()
[AI]
void Append(T p_obj)
[AI]
Definition: mxlist.h:100
[AI] Cursor class for traversing an MxStringList.
Definition: mxstringlist.h:23
[AI] Specialized list class for storing MxString objects.
Definition: mxstringlist.h:16
Mindscape custom string class for managing dynamic C-strings within the game engine.
Definition: mxstring.h:14
char * GetData() const
Returns a pointer to the internal character buffer.
Definition: mxstring.h:110
const char * GetVariable(const char *p_key)
Returns the value for the variable with a given key, or an empty string if not found.
#define DECOMP_SIZE_ASSERT(T, S)
Definition: decomp.h:19
#define NULL
[AI] Null pointer value (C/C++ semantics).
Definition: legotypes.h:26
MxDSObject * DeserializeDSObjectDispatch(MxU8 *&, MxS16)
[AI] Reads and deserializes a DS object of the specific type from an SI buffer.
Definition: mxdsobject.cpp:210
MxTimer * Timer()
[AI] Returns the global simulation timer.
Definition: mxmisc.cpp:33
MxVariableTable * VariableTable()
[AI] Returns the variable table used for script variables and global key/value state.
Definition: mxmisc.cpp:73
signed short MxS16
[AI]
Definition: mxtypes.h:26
unsigned char MxU8
[AI]
Definition: mxtypes.h:8
signed int MxS32
[AI]
Definition: mxtypes.h:38
unsigned int MxU32
[AI]
Definition: mxtypes.h:32