Isle
Loading...
Searching...
No Matches
mxstreamchunk.cpp
Go to the documentation of this file.
1#include "mxstreamchunk.h"
2
3#include "mxdsbuffer.h"
4#include "mxdssubscriber.h"
5#include "mxutilities.h"
6
7// FUNCTION: LEGO1 0x100c2fe0
9{
10 if (m_buffer) {
11 m_buffer->ReleaseRef(this);
12 }
13}
14
15// FUNCTION: LEGO1 0x100c3050
17{
18 MxResult result = FAILURE;
19
20 if (p_chunkData != NULL && *(MxU32*) p_chunkData == FOURCC('M', 'x', 'C', 'h')) {
21 if (ReadChunkHeader(p_chunkData + 8)) {
22 if (p_buffer) {
23 SetBuffer(p_buffer);
24 p_buffer->AddRef(this);
25 }
26 result = SUCCESS;
27 }
28 }
29
30 return result;
31}
32
33// FUNCTION: LEGO1 0x100c30a0
35{
36 MxU32 headersize = 0;
37 if (p_chunkData) {
38 MxU8* chunkData = p_chunkData;
39
40 memcpy(&m_flags, p_chunkData, sizeof(m_flags));
41 p_chunkData += sizeof(m_flags);
42
43 memcpy(&m_objectId, p_chunkData, sizeof(m_objectId));
44 p_chunkData += sizeof(m_objectId);
45
46 memcpy(&m_time, p_chunkData, sizeof(m_time));
47 p_chunkData += sizeof(m_time);
48
49 memcpy(&m_length, p_chunkData, sizeof(m_length));
50 p_chunkData += sizeof(m_length);
51
52 m_data = p_chunkData;
53 headersize = p_chunkData - chunkData;
54 }
55
56 return headersize;
57}
58
59// FUNCTION: LEGO1 0x100c30e0
60// FUNCTION: BETA10 0x10151517
61MxResult MxStreamChunk::SendChunk(MxDSSubscriberList& p_subscriberList, MxBool p_append, MxS16 p_obj24val)
62{
63 for (MxDSSubscriberList::iterator it = p_subscriberList.begin(); it != p_subscriberList.end(); it++) {
64 if ((*it)->GetObjectId() == m_objectId && (*it)->GetUnknown48() == p_obj24val) {
65 if (m_flags & DS_CHUNK_END_OF_STREAM && m_buffer) {
66 m_buffer->ReleaseRef(this);
67 m_buffer = NULL;
68 }
69
70 (*it)->AddData(this, p_append);
71
72 return SUCCESS;
73 }
74 }
75
76 return FAILURE;
77}
78
79// FUNCTION: LEGO1 0x100c3170
81{
82 m_buffer = p_buffer;
83}
84
85// FUNCTION: LEGO1 0x100c3180
86// FUNCTION: BETA10 0x101515f1
88{
89 return (MxU16*) (p_buffer + 0x08);
90}
91
92// FUNCTION: LEGO1 0x100c3190
94{
95 return (MxU32*) (p_buffer + 0x0a);
96}
97
98// FUNCTION: LEGO1 0x100c31a0
99// FUNCTION: BETA10 0x10151626
101{
102 return (MxLong*) (p_buffer + 0x0e);
103}
104
105// FUNCTION: LEGO1 0x100c31b0
107{
108 return (MxU32*) (p_buffer + 0x12);
109}
[AI] Buffer for managing streamed DS (Data Stream) chunks and actions.
Definition: mxdsbuffer.h:50
void AddRef(MxDSChunk *p_chunk)
[AI] Increment reference count for this buffer (ownership by a chunk).
Definition: mxdsbuffer.cpp:408
MxU8 ReleaseRef(MxDSChunk *)
[AI] Decrement the buffer's chunk reference count.
Definition: mxdsbuffer.cpp:399
MxLong m_time
[AI] Timestamp (tick/frame) value for the chunk. Used for ordering, sequencing, and synchronization....
Definition: mxdschunk.h:125
MxU32 m_objectId
[AI] Logical id field linking chunk to a resource, action, or entity. [AI]
Definition: mxdschunk.h:124
MxU16 m_flags
[AI] Flag bitfield indicating properties/status of the chunk. See DS_CHUNK_* defines....
Definition: mxdschunk.h:123
MxU32 m_length
[AI] Number of bytes of data in this chunk's payload. [AI]
Definition: mxdschunk.h:126
MxU8 * m_data
[AI] Pointer to chunk's raw data buffer. Ownership is determined by DS_CHUNK_BIT1 flag and usage cont...
Definition: mxdschunk.h:127
[AI] List container for pointers to MxDSSubscriber objects, with utility methods.
MxU32 ReadChunkHeader(MxU8 *p_chunkData)
[AI] Reads this chunk's header fields from the provided chunk data.
static MxU32 * IntoLength(MxU8 *p_buffer)
[AI] Utility to cast a chunk header buffer into the data length field pointer, facilitating direct pa...
static MxLong * IntoTime(MxU8 *p_buffer)
[AI] Utility to cast a chunk header buffer into the time field pointer, facilitating direct parsing.
MxResult ReadChunk(MxDSBuffer *p_buffer, MxU8 *p_chunkData)
[AI] Reads the chunk's header and initializes from a chunk data buffer of a streamed data segment.
static MxU32 * IntoObjectId(MxU8 *p_buffer)
[AI] Utility to cast a chunk header buffer into the objectId field pointer, facilitating direct parsi...
MxResult SendChunk(MxDSSubscriberList &p_subscriberList, MxBool p_append, MxS16 p_obj24val)
[AI] Dispatches this stream chunk to a list of subscribers matching certain criteria.
void SetBuffer(MxDSBuffer *p_buffer)
[AI] Sets the buffer reference for this chunk, without incrementing the reference count.
static MxU16 * IntoFlags(MxU8 *p_buffer)
[AI] Utility to cast a chunk header buffer into the flags field pointer, facilitating direct parsing.
~MxStreamChunk() override
[AI] Cleans up the stream chunk, releasing its associated buffer if any.
#define NULL
[AI] Null pointer value (C/C++ semantics).
Definition: legotypes.h:26
#define FAILURE
[AI] Used to indicate a failed operation in result codes.
Definition: legotypes.h:34
#define SUCCESS
[AI] Used to indicate a successful operation in result codes.
Definition: legotypes.h:30
#define DS_CHUNK_END_OF_STREAM
[AI] Flag bit indicating this chunk is the last in its stream.
Definition: mxdschunk.h:14
MxU8 MxBool
[AI]
Definition: mxtypes.h:124
MxLong MxResult
[AI]
Definition: mxtypes.h:106
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