Isle
Loading...
Searching...
No Matches
mxeventpresenter.cpp
Go to the documentation of this file.
1#include "mxeventpresenter.h"
2
3#include "decomp.h"
4#include "mxautolock.h"
5#include "mxdsaction.h"
6#include "mxdssubscriber.h"
7#include "mxeventmanager.h"
8#include "mxmisc.h"
9#include "mxvariabletable.h"
10
11#include <assert.h>
12
14
15// FUNCTION: LEGO1 0x100c2b70
17{
18 Init();
19}
20
21// FUNCTION: LEGO1 0x100c2d40
23{
24 Destroy();
25}
26
27// FUNCTION: LEGO1 0x100c2da0
28void MxEventPresenter::Init()
29{
30 m_data = NULL;
31}
32
33// FUNCTION: LEGO1 0x100c2db0
35{
36 MxResult ret = FAILURE;
37
38 if (EventManager()) {
39 ret = SUCCESS;
41 }
42
43 return ret;
44}
45
46// FUNCTION: LEGO1 0x100c2de0
48{
49 if (EventManager()) {
51 }
52
54
55 if (m_data) {
56 delete[] m_data;
57 }
58
59 Init();
60
62}
63
64// FUNCTION: LEGO1 0x100c2e30
66{
67 m_data = new MxU8[p_chunk->GetLength()];
68 memcpy(m_data, p_chunk->GetData(), p_chunk->GetLength());
69}
70
71// FUNCTION: LEGO1 0x100c2e70
73{
74 MxStreamChunk* chunk = NextChunk();
75
76 if (chunk) {
77 CopyData(chunk);
79 ParseExtra();
81 }
82}
83
84// FUNCTION: LEGO1 0x100c2eb0
86{
87 MxStreamChunk* chunk = CurrentChunk();
88
89 if (chunk && m_action->GetElapsedTime() >= chunk->GetTime()) {
91 }
92}
93
94// FUNCTION: LEGO1 0x100c2ef0
95// FUNCTION: BETA10 0x10152d26
97{
99
100 if (IsEnabled()) {
104 if (m_data[12] == 2) {
105 const char* data = (const char*) m_currentChunk->GetData();
106 MxVariableTable* variableTable = VariableTable();
107
108 const char* name = data;
109 assert(name);
110 data += strlen(data) + 1;
111
112 const char* value = data;
113 assert(value);
114 data += strlen(data) + 1;
115
116 variableTable->SetVariable(name, value);
117 }
118
121 }
123 }
124 }
125 }
126
127 return SUCCESS;
128}
void Enter()
[AI] Acquires/gains entry to the critical section or mutex, blocking if not available.
void Leave()
[AI] Releases/leaves the critical section or mutex.
virtual MxLong GetElapsedTime()
[AI] Gets elapsed time for this action since the last time field 0x90 was set.
Definition: mxdsaction.cpp:159
MxU32 GetLength()
[AI] Returns the length in bytes of the data payload. [AI]
Definition: mxdschunk.h:105
MxLong GetTime()
[AI] Returns the time (timestamp or tick) associated with this chunk. [AI]
Definition: mxdschunk.h:102
MxU8 * GetData()
[AI] Returns a pointer to the start of the data payload. [AI]
Definition: mxdschunk.h:108
void FreeDataChunk(MxStreamChunk *p_chunk)
[AI] Frees (deletes) a data chunk if it's found in the consumed data list; also forcibly deletes sing...
[AI] Presenter for handling "Event" stream data, typically parsed from event actions in SI files.
MxEventPresenter()
[AI] Constructs an event presenter and initializes internal state.
MxResult PutData() override
[AI] If the event is a variable table command (event type == 2), parses and updates the variable tabl...
virtual void CopyData(MxStreamChunk *p_chunk)
[AI] Copies raw chunk data from a stream chunk (e.g., from a SI file), for use by the event presenter...
void ReadyTickle() override
[AI] Processes event data in the ready state; copies the next chunk's data and prepares for parsing e...
~MxEventPresenter() override
[AI] Destructor, unregisters from event manager and releases memory.
void Destroy() override
[AI] Unregisters this presenter from the event manager and frees owned resources, including event dat...
MxResult AddToManager() override
[AI] Registers this presenter with the event manager for tickling and notification.
void StartingTickle() override
[AI] Processes "starting" state, transitioning to streaming if elapsed time has passed the chunk time...
virtual void RegisterPresenter(MxPresenter &p_presenter)
[AI] Register a new presenter for tickle management and playback coordination.
virtual void UnregisterPresenter(MxPresenter &p_presenter)
[AI] Remove a presenter from tickle and managed output lists.
MxStreamChunk * CurrentChunk()
[AI] Returns a pointer to the current data chunk at the head of the stream, without consuming it.
MxStreamChunk * NextChunk()
[AI] Returns the next data chunk in the stream, removing it from the stream queue.
MxDSSubscriber * m_subscriber
[AI] Subscriber that provides the stream data (e.g., audio/video chunks) for this presenter.
MxStreamChunk * m_currentChunk
[AI] Currently active data chunk for playback or processing.
virtual void ParseExtra()
[AI] Parses additional data from the associated action for configuration or world interaction.
Definition: mxpresenter.cpp:80
void ProgressTickleState(TickleState p_tickleState)
[AI] Helper for advancing the presenter's tickle state and updating transition history.
Definition: mxpresenter.h:72
MxBool IsEnabled()
[AI] Returns whether this presenter is logically enabled (based on the associated action's flags).
MxDSAction * m_action
[AI] The associated action currently being presented by this presenter.
Definition: mxpresenter.h:211
TickleState m_currentTickleState
[AI] Current state in the tickle lifecycle.
Definition: mxpresenter.h:199
@ e_repeating
[AI] Presentation is repeating (e.g., looping media).
Definition: mxpresenter.h:28
@ e_done
[AI] Completed processing the current action.
Definition: mxpresenter.h:30
@ e_starting
[AI] In the process of starting playback/presentation.
Definition: mxpresenter.h:26
@ e_streaming
[AI] Streaming or rendering actively.
Definition: mxpresenter.h:27
MxCriticalSection m_criticalSection
[AI] Thread synchronization for presenter state and data.
Definition: mxpresenter.h:214
[AI] Represents a streamable chunk of data, typically sourced from a media buffer and designed for no...
Definition: mxstreamchunk.h:19
MxVariableTable is a specialized hash table for storing key/value string variables used by the LEGO I...
void SetVariable(const char *p_key, const char *p_value)
Sets a variable by key and value, replacing or updating if it exists.
#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 AUTOLOCK(CS)
[AI] Macro for automatic locking using the MxAutoLock class. This macro instantiates an MxAutoLock ob...
Definition: mxautolock.h:5
MxEventManager * EventManager()
[AI] Returns the event manager responsible for handling event messages in the game.
Definition: mxmisc.cpp:89
MxVariableTable * VariableTable()
[AI] Returns the variable table used for script variables and global key/value state.
Definition: mxmisc.cpp:73
MxLong MxResult
[AI]
Definition: mxtypes.h:106
unsigned char MxU8
[AI]
Definition: mxtypes.h:8