Isle
Loading...
Searching...
No Matches
mxdsobject.cpp
Go to the documentation of this file.
1#include "mxdsobject.h"
2
3#include "mxdsaction.h"
4#include "mxdsanim.h"
5#include "mxdsevent.h"
6#include "mxdsfile.h"
7#include "mxdsmediaaction.h"
8#include "mxdsmultiaction.h"
9#include "mxdsobjectaction.h"
10#include "mxdsparallelaction.h"
11#include "mxdsselectaction.h"
12#include "mxdsserialaction.h"
13#include "mxdssound.h"
14#include "mxdsstill.h"
15#include "mxutilities.h"
16
17#include <stdlib.h>
18#include <string.h>
19
22
23// FUNCTION: LEGO1 0x100bf6a0
24// FUNCTION: BETA10 0x101478c0
26{
27 m_type = e_object;
28 m_sourceName = NULL;
29 m_unk0x14 = 0;
30 m_objectName = NULL;
31 m_objectId = -1;
32 m_unk0x24 = -1;
33 m_unk0x28 = NULL;
34}
35
36// FUNCTION: LEGO1 0x100bf7e0
37// FUNCTION: BETA10 0x1014798e
39{
40 delete[] m_objectName;
41 delete[] m_sourceName;
42}
43
44// FUNCTION: LEGO1 0x100bf870
45// FUNCTION: BETA10 0x10147a45
47{
48 SetSourceName(p_dsObject.m_sourceName);
49 m_unk0x14 = p_dsObject.m_unk0x14;
50 SetObjectName(p_dsObject.m_objectName);
51 m_objectId = p_dsObject.m_objectId;
52 m_unk0x24 = p_dsObject.m_unk0x24;
53 m_atomId = p_dsObject.m_atomId;
54 m_unk0x28 = p_dsObject.m_unk0x28;
55}
56
57// FUNCTION: BETA10 0x10147abf
59{
60 CopyFrom(p_dsObject);
61}
62
63// FUNCTION: LEGO1 0x100bf8c0
64// FUNCTION: BETA10 0x10147b57
66{
67 if (this == &p_dsObject) {
68 return *this;
69 }
70
71 CopyFrom(p_dsObject);
72 return *this;
73}
74
75// FUNCTION: LEGO1 0x100bf8e0
76// FUNCTION: BETA10 0x10147b92
77void MxDSObject::SetObjectName(const char* p_objectName)
78{
79 if (p_objectName == m_objectName) {
80 return;
81 }
82
83 delete[] m_objectName;
84
85 if (p_objectName) {
86 m_objectName = new char[strlen(p_objectName) + 1];
87
88 if (m_objectName) {
89 strcpy(m_objectName, p_objectName);
90 }
91 }
92 else {
94 }
95}
96
97// FUNCTION: LEGO1 0x100bf950
98// FUNCTION: BETA10 0x10147c2e
99void MxDSObject::SetSourceName(const char* p_sourceName)
100{
101 if (p_sourceName == m_sourceName) {
102 return;
103 }
104
105 delete[] m_sourceName;
106
107 if (p_sourceName) {
108 m_sourceName = new char[strlen(p_sourceName) + 1];
109
110 if (m_sourceName) {
111 strcpy(m_sourceName, p_sourceName);
112 }
113 }
114 else {
116 }
117}
118
119// FUNCTION: LEGO1 0x100bf9c0
120// FUNCTION: BETA10 0x10147cca
122{
123 // DECOMP: Rendered as 8 + 2 in beta. Maybe a sizeof() call?
124 return 10;
125}
126
127// FUNCTION: LEGO1 0x100bf9d0
128// FUNCTION: BETA10 0x10147cee
130{
131 MxU32 sizeOnDisk = 0;
132
133 sizeOnDisk += 2;
134
135 if (m_sourceName) {
136 sizeOnDisk += strlen(m_sourceName) + 1;
137 }
138 else {
139 sizeOnDisk++;
140 }
141
142 sizeOnDisk += sizeof(m_unk0x14);
143
144 if (m_objectName) {
145 sizeOnDisk += strlen(m_objectName) + 1;
146 }
147 else {
148 sizeOnDisk++;
149 }
150
151 sizeOnDisk += sizeof(m_objectId);
152
153 m_sizeOnDisk = sizeOnDisk;
154 return sizeOnDisk;
155}
156
157// FUNCTION: LEGO1 0x100bfa20
158// FUNCTION: BETA10 0x10147d73
159void MxDSObject::Deserialize(MxU8*& p_source, MxS16 p_flags)
160{
161 SetSourceName((char*) p_source);
162 p_source += strlen(m_sourceName) + 1;
163
164 m_unk0x14 = *(undefined4*) p_source;
165 p_source += sizeof(m_unk0x14);
166
167 SetObjectName((char*) p_source);
168 p_source += strlen(m_objectName) + 1;
169
170 m_objectId = *(MxU32*) p_source;
171 p_source += sizeof(m_objectId);
172
173 m_unk0x24 = p_flags;
174}
175
176// FUNCTION: LEGO1 0x100bfa80
177// FUNCTION: BETA10 0x10147e02
178MxDSObject* MxDSObjectList::FindInternal(MxDSObject* p_action, MxBool p_delete)
179{
180 // DECOMP ALPHA 0x1008b99d ?
181
182 MxDSObject* found = NULL;
183
184#ifdef COMPAT_MODE
185 iterator it;
186 for (it = begin(); it != end(); it++) {
187#else
188 for (iterator it = begin(); it != end(); it++) {
189#endif
190 if (p_action->GetObjectId() == -1 || p_action->GetObjectId() == (*it)->GetObjectId()) {
191 if (p_action->GetUnknown24() == -2 || p_action->GetUnknown24() == -3 ||
192 p_action->GetUnknown24() == (*it)->GetUnknown24()) {
193 found = *it;
194 if (p_action->GetUnknown24() != -3) {
195 break;
196 }
197 }
198 }
199 }
200
201 if (p_delete && found != NULL) {
202 erase(it);
203 }
204
205 return found;
206}
207
208// FUNCTION: LEGO1 0x100bfb30
209// FUNCTION: BETA10 0x10147f35
211{
212 MxDSObject* obj = NULL;
213
214 MxU16 type = *(MxU16*) p_source;
215 p_source += 2;
216
217 switch (type) {
219 obj = new MxDSObject();
220 break;
222 obj = new MxDSAction();
223 break;
225 obj = new MxDSMediaAction();
226 break;
228 obj = new MxDSAnim();
229 break;
231 obj = new MxDSSound();
232 break;
234 obj = new MxDSEvent();
235 break;
237 obj = new MxDSStill();
238 break;
240 obj = new MxDSObjectAction();
241 break;
243 obj = new MxDSMultiAction();
244 break;
246 obj = new MxDSSerialAction();
247 break;
249 obj = new MxDSParallelAction();
250 break;
252 obj = new MxDSSelectAction();
253 break;
254 default:
255 return NULL;
256 }
257
258 if (obj) {
259 obj->Deserialize(p_source, p_flags);
260 }
261
262 return obj;
263}
264
265// FUNCTION: LEGO1 0x100c0280
267{
268 MxU8* buf;
269 _MMCKINFO tmpChunk;
270
271 if (p_file->Seek(((MxLong*) p_file->GetBuffer())[p_ofs], SEEK_SET)) {
272 return NULL;
273 }
274
275 if (p_file->Read((MxU8*) &tmpChunk.ckid, 8) == 0 && tmpChunk.ckid == FOURCC('M', 'x', 'S', 't')) {
276 if (p_file->Read((MxU8*) &tmpChunk.ckid, 8) == 0 && tmpChunk.ckid == FOURCC('M', 'x', 'O', 'b')) {
277
278 buf = new MxU8[tmpChunk.cksize];
279 if (!buf) {
280 return NULL;
281 }
282
283 if (p_file->Read(buf, tmpChunk.cksize) != 0) {
284 return NULL;
285 }
286
287 // Save a copy so we can clean up properly, because
288 // this function will alter the pointer value.
289 MxU8* copy = buf;
291 delete[] copy;
292 return obj;
293 }
294
295 return NULL;
296 }
297
298 return NULL;
299}
[AI] Represents an action deserialized from SI chunks, holding key animation or script parameters suc...
Definition: mxdsaction.h:17
Derived class representing an animation action extracted from SI files.
Definition: mxdsanim.h:14
[AI] Represents an event media action (a discrete event) parsed from script/scene data (SI files).
Definition: mxdsevent.h:13
[AI] Represents a source file handler for SI (Streamer Interface) files, providing buffered access fo...
Definition: mxdsfile.h:20
MxResult Read(unsigned char *, MxULong) override
[AI] Reads up to the specified number of bytes from the file into a buffer.
Definition: mxdsfile.cpp:108
MxResult Seek(MxLong, MxS32) override
[AI] Seeks to an absolute or relative position in the file.
Definition: mxdsfile.cpp:120
MxDSMediaAction extends MxDSAction to add media-specific playback properties and management.
[AI] Represents a container for multiple MxDSAction objects, facilitating the grouping and management...
[AI] Represents an extracted SI file action of type "ObjectAction".
[AI] Utility list for managing dynamic sequence (DS) objects, provides search and removal by pointer ...
Definition: mxdsobject.h:18
[AI] Base class for any object deserialized from an SI (script/data) file in the LEGO Island engine.
Definition: mxdsobject.h:44
char * m_sourceName
[AI] Heap copy: SI file or source identifier string. [AI]
Definition: mxdsobject.h:167
MxDSObject()
[AI] Default constructor. Initializes to e_object and clears names and pointers.
Definition: mxdsobject.cpp:25
MxPresenter * m_unk0x28
[AI] Presenter or handler associated to this object (may be null). [AI]
Definition: mxdsobject.h:173
MxS16 m_unk0x24
[AI] Unknown usage, possibly used for context or flags during loading. [AI]
Definition: mxdsobject.h:172
void SetSourceName(const char *p_sourceName)
[AI] Sets the source name (usually source SI file); deep copies the string.
Definition: mxdsobject.cpp:99
undefined4 m_unk0x14
[AI] Unknown usage, possibly flags or reserved SI-format field. [AI]
Definition: mxdsobject.h:168
~MxDSObject() override
[AI] Destructor. Frees allocated objectName/sourceName memory.
Definition: mxdsobject.cpp:38
MxDSObject & operator=(MxDSObject &p_dsObject)
[AI] Assignment operator.
Definition: mxdsobject.cpp:65
@ e_serialAction
[AI] Series of actions to play in order. [AI]
Definition: mxdsobject.h:55
@ e_objectAction
[AI] Placeholder for generic object operations. [AI]
Definition: mxdsobject.h:60
@ e_still
[AI] Still image resource. [AI]
Definition: mxdsobject.h:59
@ e_object
[AI] Base object, most basic type. [AI]
Definition: mxdsobject.h:49
@ e_parallelAction
[AI] Parallel (simultaneous) action list. [AI]
Definition: mxdsobject.h:56
@ e_multiAction
[AI] Composite/multi-action list. [AI]
Definition: mxdsobject.h:54
@ e_sound
[AI] Sound resource reference or cue. [AI]
Definition: mxdsobject.h:53
@ e_selectAction
[AI] Selects an action from several (with rules/random). [AI]
Definition: mxdsobject.h:58
@ e_anim
[AI] Animation sequence or reference. [AI]
Definition: mxdsobject.h:52
@ e_action
[AI] Simple action or command invocation. [AI]
Definition: mxdsobject.h:50
@ e_mediaAction
[AI] Media-related action (usually for videos, audio, etc). [AI]
Definition: mxdsobject.h:51
@ e_event
[AI] Scripted event type. [AI]
Definition: mxdsobject.h:57
MxU32 m_sizeOnDisk
[AI] Cached/calculated disk size of object data for serialization. [AI]
Definition: mxdsobject.h:165
virtual MxU32 GetSizeOnDisk()
[AI] Calculates serialized size of this object on disk (for buffer allocation).
Definition: mxdsobject.cpp:129
void SetObjectName(const char *p_objectName)
[AI] Sets object (internal) unique name; deep copies the string.
Definition: mxdsobject.cpp:77
MxU32 m_objectId
[AI] Numeric id (unique per file or context, often -1). [AI]
Definition: mxdsobject.h:170
virtual void Deserialize(MxU8 *&p_source, MxS16 p_unk0x24)
[AI] Initializes this object from serialized (memory buffer) data.
Definition: mxdsobject.cpp:159
void CopyFrom(MxDSObject &p_dsObject)
[AI] Copy data from another MxDSObject, performing deep string copy for names.
Definition: mxdsobject.cpp:46
virtual undefined4 VTable0x14()
[AI] Placeholder for early vtable slot (purpose unknown, may be used for RTTI).
Definition: mxdsobject.cpp:121
MxS16 GetUnknown24()
[AI] Returns the unknown 0x24 value (may be data version or usage state). [AI]
Definition: mxdsobject.h:136
char * m_objectName
[AI] Heap copy: Logical object name as referenced in script/data. [AI]
Definition: mxdsobject.h:169
MxU32 GetObjectId()
[AI] Returns the object id numeric value.
Definition: mxdsobject.h:130
MxAtomId m_atomId
[AI] String/value pair for engine lookup/reference. [AI]
Definition: mxdsobject.h:171
[AI] Represents an action that can play multiple MxDSActions in parallel.
[AI] Represents a "select" action within a DS (Script/Scene) file, deserialized from SI files to sele...
[AI] Represents a serial (sequential) action group for data-driven sequence execution in LEGO Island.
[AI] Represents a sound action extracted from an SI script and used in the data-driven action system.
Definition: mxdssound.h:14
virtual MxU32 * GetBuffer()
[AI] Returns a pointer to the internal buffer as a DWORD (32-bit) pointer.
Definition: mxdssource.h:116
[AI] Represents a "still" media action in the LEGO Island SI script system.
Definition: mxdsstill.h:20
#define DECOMP_SIZE_ASSERT(T, S)
Definition: decomp.h:19
unsigned int undefined4
Definition: decomp.h:28
#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
MxDSObject * CreateStreamObject(MxDSFile *, MxS16)
[AI] Creates and deserializes a stream object from a chunk inside a DS file.
Definition: mxdsobject.cpp:266
MxU8 MxBool
[AI]
Definition: mxtypes.h:124
int MxLong
[AI]
Definition: mxtypes.h:83
signed short MxS16
[AI]
Definition: mxtypes.h:26
#define FOURCC(a, b, c, d)
[AI] Macro to compose a 32-bit code from four 8-bit characters (e.g., for resource and chunk IDs).
Definition: mxtypes.h:162
unsigned char MxU8
[AI]
Definition: mxtypes.h:8
unsigned short MxU16
[AI]
Definition: mxtypes.h:20
unsigned int MxU32
[AI]
Definition: mxtypes.h:32