2023-06-29 04:10:08 -04:00
|
|
|
#include "mxeventpresenter.h"
|
|
|
|
|
2023-07-02 03:00:28 -04:00
|
|
|
#include "decomp.h"
|
2023-11-19 12:10:32 -05:00
|
|
|
#include "mxautolocker.h"
|
2023-10-24 19:38:27 -04:00
|
|
|
#include "mxeventmanager.h"
|
|
|
|
#include "mxomni.h"
|
2023-11-19 12:10:32 -05:00
|
|
|
#include "mxvariabletable.h"
|
2023-07-02 03:00:28 -04:00
|
|
|
|
|
|
|
DECOMP_SIZE_ASSERT(MxEventPresenter, 0x54);
|
|
|
|
|
2023-06-29 04:10:08 -04:00
|
|
|
// OFFSET: LEGO1 0x100c2b70
|
|
|
|
MxEventPresenter::MxEventPresenter()
|
|
|
|
{
|
2023-10-24 19:38:27 -04:00
|
|
|
Init();
|
2023-06-29 04:10:08 -04:00
|
|
|
}
|
|
|
|
|
2023-10-20 14:41:23 -04:00
|
|
|
// OFFSET: LEGO1 0x100c2d40
|
2023-06-29 04:10:08 -04:00
|
|
|
MxEventPresenter::~MxEventPresenter()
|
|
|
|
{
|
2023-10-24 19:38:27 -04:00
|
|
|
Destroy();
|
2023-06-29 04:10:08 -04:00
|
|
|
}
|
|
|
|
|
2023-07-02 03:00:28 -04:00
|
|
|
// OFFSET: LEGO1 0x100c2da0
|
2023-06-29 04:10:08 -04:00
|
|
|
void MxEventPresenter::Init()
|
|
|
|
{
|
2023-11-19 12:10:32 -05:00
|
|
|
m_data = NULL;
|
2023-10-20 14:41:23 -04:00
|
|
|
}
|
|
|
|
|
2023-11-05 17:45:48 -05:00
|
|
|
// OFFSET: LEGO1 0x100c2db0
|
|
|
|
MxResult MxEventPresenter::AddToManager()
|
|
|
|
{
|
|
|
|
MxResult ret = FAILURE;
|
2023-11-19 12:10:32 -05:00
|
|
|
|
2023-11-05 17:45:48 -05:00
|
|
|
if (EventManager()) {
|
|
|
|
ret = SUCCESS;
|
|
|
|
EventManager()->AddPresenter(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2023-10-20 14:41:23 -04:00
|
|
|
// OFFSET: LEGO1 0x100c2de0
|
|
|
|
void MxEventPresenter::Destroy()
|
|
|
|
{
|
2023-11-05 17:45:48 -05:00
|
|
|
if (EventManager())
|
2023-10-24 19:38:27 -04:00
|
|
|
EventManager()->RemovePresenter(*this);
|
2023-10-20 14:41:23 -04:00
|
|
|
|
2023-10-24 19:38:27 -04:00
|
|
|
m_criticalSection.Enter();
|
2023-10-20 14:41:23 -04:00
|
|
|
|
2023-11-19 12:10:32 -05:00
|
|
|
if (m_data)
|
|
|
|
delete[] m_data;
|
2023-10-20 14:41:23 -04:00
|
|
|
|
2023-10-24 19:38:27 -04:00
|
|
|
Init();
|
2023-10-20 14:41:23 -04:00
|
|
|
|
2023-10-24 19:38:27 -04:00
|
|
|
m_criticalSection.Leave();
|
2023-06-29 04:10:08 -04:00
|
|
|
}
|
2023-11-19 12:10:32 -05:00
|
|
|
|
|
|
|
// OFFSET: LEGO1 0x100c2e30
|
|
|
|
void MxEventPresenter::CopyData(MxStreamChunk* p_chunk)
|
|
|
|
{
|
|
|
|
m_data = new MxU8[p_chunk->GetLength()];
|
|
|
|
memcpy(m_data, p_chunk->GetData(), p_chunk->GetLength());
|
|
|
|
}
|
|
|
|
|
|
|
|
// OFFSET: LEGO1 0x100c2e70
|
|
|
|
void MxEventPresenter::ReadyTickle()
|
|
|
|
{
|
|
|
|
MxStreamChunk* chunk = NextChunk();
|
|
|
|
|
|
|
|
if (chunk) {
|
|
|
|
CopyData(chunk);
|
|
|
|
m_subscriber->FUN_100b8390(chunk);
|
|
|
|
ParseExtra();
|
|
|
|
m_previousTickleStates |= 1 << (unsigned char) m_currentTickleState;
|
|
|
|
m_currentTickleState = TickleState_Starting;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// OFFSET: LEGO1 0x100c2eb0
|
|
|
|
void MxEventPresenter::StartingTickle()
|
|
|
|
{
|
|
|
|
MxStreamChunk* chunk = NextChunk();
|
|
|
|
|
|
|
|
if (chunk && m_action->GetElapsedTime() >= chunk->GetTime()) {
|
|
|
|
m_previousTickleStates |= 1 << (unsigned char) m_currentTickleState;
|
|
|
|
m_currentTickleState = TickleState_Streaming;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// OFFSET: LEGO1 0x100c2ef0
|
2023-11-26 09:03:40 -05:00
|
|
|
MxResult MxEventPresenter::PutData()
|
2023-11-19 12:10:32 -05:00
|
|
|
{
|
|
|
|
MxAutoLocker lock(&m_criticalSection);
|
|
|
|
|
|
|
|
if (IsEnabled()) {
|
|
|
|
if (m_currentTickleState >= TickleState_Streaming &&
|
|
|
|
(m_currentTickleState <= TickleState_Repeating || m_currentTickleState == TickleState_Done)) {
|
|
|
|
if (m_currentChunk && m_currentChunk->GetLength()) {
|
|
|
|
if (m_data[12] == 2) {
|
|
|
|
const char* data = (const char*) m_currentChunk->GetData();
|
|
|
|
MxVariableTable* variableTable = VariableTable();
|
|
|
|
|
|
|
|
const char* key = data;
|
|
|
|
const char* value = &data[strlen(data) + 1];
|
|
|
|
strlen(value);
|
|
|
|
variableTable->SetVariable(key, value);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (m_currentTickleState == TickleState_Streaming)
|
|
|
|
m_subscriber->FUN_100b8390(m_currentChunk);
|
|
|
|
m_currentChunk = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-11-26 09:03:40 -05:00
|
|
|
return SUCCESS;
|
2023-11-19 12:10:32 -05:00
|
|
|
}
|