Isle
Loading...
Searching...
No Matches
mxdssubscriber.cpp
Go to the documentation of this file.
1#include "mxdssubscriber.h"
2
4
7
8// FUNCTION: LEGO1 0x100b7bb0
10{
11 m_unk0x48 = -1;
12 m_objectId = -1;
13 m_pendingChunkCursor = NULL;
14 m_consumedChunkCursor = NULL;
15}
16
17// FUNCTION: LEGO1 0x100b7e00
19{
20 if (m_controller) {
21 m_controller->RemoveSubscriber(this);
22 }
23
25
26 if (m_pendingChunkCursor) {
27 delete m_pendingChunkCursor;
28 }
29 m_pendingChunkCursor = NULL;
30
31 if (m_consumedChunkCursor) {
32 delete m_consumedChunkCursor;
33 }
34 m_consumedChunkCursor = NULL;
35}
36
37// FUNCTION: LEGO1 0x100b7ed0
38MxResult MxDSSubscriber::Create(MxStreamController* p_controller, MxU32 p_objectId, MxS16 p_unk0x48)
39{
40 m_objectId = p_objectId;
41 m_unk0x48 = p_unk0x48;
42
43 if (!p_controller) {
44 return FAILURE;
45 }
46 m_controller = p_controller;
47
48 m_pendingChunkCursor = new MxStreamChunkListCursor(&m_pendingChunks);
49 if (!m_pendingChunkCursor) {
50 return FAILURE;
51 }
52
53 m_consumedChunkCursor = new MxStreamChunkListCursor(&m_consumedChunks);
54 if (!m_consumedChunkCursor) {
55 return FAILURE;
56 }
57
58 m_controller->AddSubscriber(this);
59 return SUCCESS;
60}
61
62// FUNCTION: LEGO1 0x100b8030
64{
65 if (m_controller) {
66 MxStreamChunk* chunk = NULL;
67
68 while (m_pendingChunkCursor->First(chunk)) {
69 m_pendingChunkCursor->Detach();
70 delete chunk;
71 }
72
73 while (m_consumedChunkCursor->First(chunk)) {
74 m_consumedChunkCursor->Detach();
75 delete chunk;
76 }
77 }
78}
79
80// FUNCTION: LEGO1 0x100b8150
82{
83 if (m_pendingChunkCursor) {
84 if (p_append) {
85 m_pendingChunks.Append(p_chunk);
86 }
87 else {
88 m_pendingChunks.Prepend(p_chunk);
89 }
90 }
91
92 return SUCCESS;
93}
94
95// FUNCTION: LEGO1 0x100b8250
97{
98 MxStreamChunk* chunk = NULL;
99
100 if (m_pendingChunkCursor) {
101 m_pendingChunkCursor->First(chunk);
102 }
103
104 if (chunk) {
105 m_pendingChunkCursor->Detach();
106 m_consumedChunks.Append(chunk);
107 }
108
109 return chunk;
110}
111
112// FUNCTION: LEGO1 0x100b8360
114{
115 MxStreamChunk* chunk = NULL;
116
117 if (m_pendingChunkCursor) {
118 m_pendingChunkCursor->First(chunk);
119 }
120
121 return chunk;
122}
123
124// FUNCTION: LEGO1 0x100b8390
126{
127 if (p_chunk) {
128 if (m_consumedChunkCursor->Find(p_chunk)) {
129 m_consumedChunkCursor->Detach();
130 if (p_chunk) {
131 delete p_chunk;
132 }
133 }
134 else if (p_chunk->GetChunkFlags() & DS_CHUNK_BIT1 && p_chunk) {
135 delete p_chunk;
136 }
137 }
138}
139
140// FUNCTION: LEGO1 0x100b8450
141// FUNCTION: BETA10 0x10134c1d
143{
144 for (iterator it = begin(); it != end(); it++) {
145 if (p_object->GetObjectId() == -1 || p_object->GetObjectId() == (*it)->GetObjectId()) {
146 if (p_object->GetUnknown24() == -2 || p_object->GetUnknown24() == (*it)->GetUnknown48()) {
147 return *it;
148 }
149 }
150 }
151
152 return NULL;
153}
MxU16 GetChunkFlags()
[AI] Returns the chunk's flag bitfield. [AI]
Definition: mxdschunk.h:96
[AI] Base class for any object deserialized from an SI (script/data) file in the LEGO Island engine.
Definition: mxdsobject.h:44
MxS16 GetUnknown24()
[AI] Returns the unknown 0x24 value (may be data version or usage state). [AI]
Definition: mxdsobject.h:136
MxU32 GetObjectId()
[AI] Returns the object id numeric value.
Definition: mxdsobject.h:130
[AI] List container for pointers to MxDSSubscriber objects, with utility methods.
MxDSSubscriber * Find(MxDSObject *p_object)
[AI] Searches for a subscriber corresponding to the provided MxDSObject.
[AI] Handles the receipt, queuing, and batch management of data chunks streamed by a MxStreamControll...
MxResult Create(MxStreamController *p_controller, MxU32 p_objectId, MxS16 p_unk0x48)
[AI] Initializes subscription to a streaming controller, sets identifiers, and establishes chunk curs...
MxResult AddData(MxStreamChunk *p_chunk, MxBool p_append)
[AI] Appends or prepends a new data chunk to the pending stream buffer.
MxStreamChunk * PopData()
[AI] Pops the next available pending data chunk for consumption, moving it to the consumed list.
void DestroyData()
[AI] Frees and detaches all currently managed/pending/consumed data chunks from both lists; intended ...
~MxDSSubscriber() override
[AI] Destructor, unregisters and frees associated memory/buffers.
void FreeDataChunk(MxStreamChunk *p_chunk)
[AI] Frees (deletes) a data chunk if it's found in the consumed data list; also forcibly deletes sing...
MxStreamChunk * PeekData()
[AI] Returns but does not remove the first pending data chunk ("peek" operation).
void Detach()
[AI]
MxBool Find(T p_obj)
[AI]
MxBool First(T &p_obj)
[AI]
void Prepend(T p_obj)
[AI]
Definition: mxlist.h:105
void Append(T p_obj)
[AI]
Definition: mxlist.h:100
[AI] Cursor for iterating over a MxStreamChunkList.
[AI] Represents a streamable chunk of data, typically sourced from a media buffer and designed for no...
Definition: mxstreamchunk.h:19
[AI] Controller for streaming and managing multimedia resources and actions during gameplay.
void RemoveSubscriber(MxDSSubscriber *p_subscriber)
[AI] Removes a previously registered subscriber from the stream notification list.
void AddSubscriber(MxDSSubscriber *p_subscriber)
[AI] Adds a subscriber to the list who will receive streaming action data.
#define DECOMP_SIZE_ASSERT(T, S)
Definition: decomp.h:19
#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_BIT1
[AI] Flag bit indicating that the data should be released (freed) when the chunk is destroyed.
Definition: mxdschunk.h:10
MxU8 MxBool
[AI]
Definition: mxtypes.h:124
MxLong MxResult
[AI]
Definition: mxtypes.h:106
signed short MxS16
[AI]
Definition: mxtypes.h:26
unsigned int MxU32
[AI]
Definition: mxtypes.h:32