begin implementation of InfoCenter class (#444)

* Push changes

* fixes

* Implement Infocenter::HandleEndAction

* match Infocenter::StopCutScene

* implement Infocenter::HandleKeyPress

* fixes

* Update infocenter.cpp

* Update legoworld.cpp

* use enums

* WIP Fixes

* Fix

* Fix

* Fix

* Rename function

* Change enum

* Update enums

* Refactor another enum

* Refactor MxDSType

* Refactor HashTableOpt

* Fixes

* Refactor tickle enum

* Update other enums

* Add EnumConstantName to ncc

* Move enum to global namespace

* Rename enum

---------

Co-authored-by: Christian Semmler <mail@csemmler.com>
This commit is contained in:
Misha
2024-01-17 11:53:53 -05:00
committed by GitHub
parent aaa18bc9e2
commit f50b771fff
100 changed files with 1160 additions and 555 deletions

View File

@@ -129,7 +129,7 @@ void MxDiskStreamController::FUN_100c7980()
if (m_unk0x3c.size() && m_unk0x8c < m_provider->GetStreamBuffersNum()) {
buffer = new MxDSBuffer();
if (buffer->AllocateBuffer(m_provider->GetFileSize(), MxDSBufferType_Chunk) != SUCCESS) {
if (buffer->AllocateBuffer(m_provider->GetFileSize(), MxDSBuffer::e_chunk) != SUCCESS) {
if (buffer)
delete buffer;
return;
@@ -213,10 +213,10 @@ void MxDiskStreamController::FUN_100c7cb0(MxDSStreamingAction* p_action)
void MxDiskStreamController::FUN_100c7ce0(MxDSBuffer* p_buffer)
{
switch (p_buffer->GetMode()) {
case MxDSBufferType_Chunk:
case MxDSBuffer::e_chunk:
m_unk0x8c--;
case MxDSBufferType_Allocate:
case MxDSBufferType_Unknown:
case MxDSBuffer::e_allocate:
case MxDSBuffer::e_unknown:
delete p_buffer;
break;
}

View File

@@ -174,7 +174,7 @@ MxResult MxDiskStreamProvider::FUN_100d1780(MxDSStreamingAction* p_action)
if (!buffer)
return FAILURE;
if (buffer->AllocateBuffer(GetFileSize(), MxDSBufferType_Allocate) != SUCCESS) {
if (buffer->AllocateBuffer(GetFileSize(), MxDSBuffer::e_allocate) != SUCCESS) {
delete buffer;
return FAILURE;
}
@@ -282,7 +282,7 @@ MxResult MxDiskStreamProvider::FUN_100d1b20(MxDSStreamingAction* p_action)
MxU32 size = p_action->GetUnknowna0()->GetWriteOffset() - p_action->GetUnknown94() + p_action->GetBufferOffset() +
(p_action->GetUnknowna4() ? p_action->GetUnknowna4()->GetWriteOffset() : 0);
if (buffer->AllocateBuffer(size, MxDSBufferType_Allocate) != SUCCESS) {
if (buffer->AllocateBuffer(size, MxDSBuffer::e_allocate) != SUCCESS) {
if (!buffer)
return FAILURE;
@@ -330,12 +330,12 @@ MxResult MxDiskStreamProvider::FUN_100d1b20(MxDSStreamingAction* p_action)
if (!buffer3)
return FAILURE;
if (buffer3->AllocateBuffer(size, MxDSBufferType_Allocate) == SUCCESS) {
if (buffer3->AllocateBuffer(size, MxDSBuffer::e_allocate) == SUCCESS) {
memcpy(buffer3->GetBuffer(), p_action->GetUnknowna4()->GetBuffer(), size);
p_action->GetUnknowna4()->SetMode(MxDSBufferType_Allocate);
p_action->GetUnknowna4()->SetMode(MxDSBuffer::e_allocate);
delete p_action->GetUnknowna4();
buffer3->SetMode(MxDSBufferType_Unknown);
buffer3->SetMode(MxDSBuffer::e_unknown);
p_action->SetUnknowna4(buffer3);
MxDSBuffer* buffer4 = p_action->GetUnknowna0();
MxU32 unk0x14 = buffer4->GetUnknown14();

View File

@@ -22,7 +22,7 @@ MxDSBuffer::MxDSBuffer()
m_unk0x1c = 0;
m_writeOffset = 0;
m_bytesRemaining = 0;
m_mode = MxDSBufferType_Preallocated;
m_mode = e_preallocated;
m_unk0x30 = 0;
}
@@ -31,12 +31,12 @@ MxDSBuffer::~MxDSBuffer()
{
if (m_pBuffer != NULL) {
switch (m_mode) {
case MxDSBufferType_Allocate:
case MxDSBufferType_Unknown:
case e_allocate:
case e_unknown:
delete[] m_pBuffer;
break;
case MxDSBufferType_Chunk: {
case e_chunk: {
MxU32 offset = m_writeOffset / 1024;
MxStreamer* streamer = Streamer();
@@ -77,16 +77,16 @@ MxDSBuffer::~MxDSBuffer()
}
// FUNCTION: LEGO1 0x100c6640
MxResult MxDSBuffer::AllocateBuffer(MxU32 p_bufferSize, MxDSBufferType p_mode)
MxResult MxDSBuffer::AllocateBuffer(MxU32 p_bufferSize, Type p_mode)
{
MxResult result = FAILURE;
switch (p_mode) {
case MxDSBufferType_Allocate:
case e_allocate:
m_pBuffer = new MxU8[p_bufferSize];
break;
case MxDSBufferType_Chunk: {
case e_chunk: {
MxStreamer* streamer = Streamer();
switch (p_bufferSize / 1024) {
@@ -150,7 +150,7 @@ MxResult MxDSBuffer::SetBufferPointer(MxU8* p_buffer, MxU32 p_size)
m_pIntoBuffer2 = p_buffer;
m_bytesRemaining = p_size;
m_writeOffset = p_size;
m_mode = MxDSBufferType_Preallocated;
m_mode = e_preallocated;
return SUCCESS;
}
@@ -291,24 +291,24 @@ MxResult MxDSBuffer::ParseChunk(
{
MxResult result = SUCCESS;
if (m_unk0x30->GetFlags() & MxDSAction::Flag_Bit3 && m_unk0x30->GetUnknowna8() && p_header->GetTime() < 0) {
if (m_unk0x30->GetFlags() & MxDSAction::c_bit3 && m_unk0x30->GetUnknowna8() && p_header->GetTime() < 0) {
delete p_header;
return SUCCESS;
}
p_header->SetTime(p_header->GetTime() + m_unk0x30->GetUnknowna8());
if (p_header->GetFlags() & MxDSChunk::Flag_Split) {
if (p_header->GetFlags() & MxDSChunk::c_split) {
MxU32 length = p_header->GetLength() + MxDSChunk::GetHeaderSize() + 8;
MxDSBuffer* buffer = new MxDSBuffer();
if (buffer && buffer->AllocateBuffer(length, MxDSBufferType_Allocate) == SUCCESS &&
if (buffer && buffer->AllocateBuffer(length, e_allocate) == SUCCESS &&
buffer->CalcBytesRemaining((MxU8*) p_data) == SUCCESS) {
*p_streamingAction = new MxDSStreamingAction((MxDSStreamingAction&) *p_action);
if (*p_streamingAction) {
MxU16* flags = MxStreamChunk::IntoFlags(buffer->GetBuffer());
*flags = p_header->GetFlags() & ~MxDSChunk::Flag_Split;
*flags = p_header->GetFlags() & ~MxDSChunk::c_split;
delete p_header;
(*p_streamingAction)->SetUnknowna0(buffer);
@@ -323,9 +323,9 @@ MxResult MxDSBuffer::ParseChunk(
return FAILURE;
}
else {
if (p_header->GetFlags() & MxDSChunk::Flag_End) {
if (p_header->GetFlags() & MxDSChunk::c_end) {
if (m_unk0x30->HasId(p_header->GetObjectId())) {
if (m_unk0x30->GetFlags() & MxDSAction::Flag_Bit3 &&
if (m_unk0x30->GetFlags() & MxDSAction::c_bit3 &&
(m_unk0x30->GetLoopCount() > 1 || m_unk0x30->GetDuration() == -1)) {
if (p_action->GetObjectId() == p_header->GetObjectId()) {
@@ -456,7 +456,7 @@ MxResult MxDSBuffer::CalcBytesRemaining(MxU8* p_data)
{
MxResult result = FAILURE;
if (m_mode == MxDSBufferType_Allocate && m_bytesRemaining != 0) {
if (m_mode == e_allocate && m_bytesRemaining != 0) {
MxU32 bytesRead;
MxU8* ptr;

View File

@@ -15,7 +15,7 @@ MxDSChunk::MxDSChunk()
// FUNCTION: LEGO1 0x100be170
MxDSChunk::~MxDSChunk()
{
if (m_flags & Flag_Bit1)
if (m_flags & c_bit1)
delete[] m_data;
}

View File

@@ -119,7 +119,7 @@ void MxDSSubscriber::DestroyChunk(MxStreamChunk* p_chunk)
if (p_chunk)
delete p_chunk;
}
else if (p_chunk->GetFlags() & MxDSChunk::Flag_Bit1 && p_chunk)
else if (p_chunk->GetFlags() & MxDSChunk::c_bit1 && p_chunk)
delete p_chunk;
}
}

View File

@@ -124,22 +124,22 @@ MxU32 ReadData(MxU8* p_buffer, MxU32 p_size)
data += MxDSChunk::Size(*psize);
if ((*MxDSChunk::IntoType(data2) == FOURCC('M', 'x', 'C', 'h')) &&
(*MxStreamChunk::IntoFlags(data2) & MxDSChunk::Flag_Split)) {
(*MxStreamChunk::IntoFlags(data2) & MxDSChunk::c_split)) {
if (*MxStreamChunk::IntoObjectId(data2) == *MxStreamChunk::IntoObjectId(data3) &&
(*MxStreamChunk::IntoFlags(data3) & MxDSChunk::Flag_Split) &&
(*MxStreamChunk::IntoFlags(data3) & MxDSChunk::c_split) &&
*MxStreamChunk::IntoTime(data2) == *MxStreamChunk::IntoTime(data3)) {
MxDSBuffer::Append(data2, data3);
continue;
}
else
*MxStreamChunk::IntoFlags(data2) &= ~MxDSChunk::Flag_Split;
*MxStreamChunk::IntoFlags(data2) &= ~MxDSChunk::c_split;
}
data2 += MxDSChunk::Size(*MxDSChunk::IntoLength(data2));
memcpy(data2, data3, MxDSChunk::Size(*psize));
if (*MxStreamChunk::IntoObjectId(data2) == id &&
(*MxStreamChunk::IntoFlags(data2) & MxDSChunk::Flag_End))
(*MxStreamChunk::IntoFlags(data2) & MxDSChunk::c_end))
break;
}
else
@@ -151,6 +151,6 @@ MxU32 ReadData(MxU8* p_buffer, MxU32 p_size)
} while (data < end);
}
*MxStreamChunk::IntoFlags(data2) &= ~MxDSChunk::Flag_Split;
*MxStreamChunk::IntoFlags(data2) &= ~MxDSChunk::c_split;
return MxDSChunk::End(data2) - p_buffer;
}

View File

@@ -54,7 +54,7 @@ MxResult MxStreamChunk::SendChunk(MxStreamListMxDSSubscriber& p_subscriberList,
{
for (MxStreamListMxDSSubscriber::iterator it = p_subscriberList.begin(); it != p_subscriberList.end(); it++) {
if ((*it)->GetObjectId() == m_objectId && (*it)->GetUnknown48() == p_obj24val) {
if (m_flags & MxDSChunk::Flag_End && m_buffer) {
if (m_flags & MxDSChunk::c_end && m_buffer) {
m_buffer->ReleaseRef(this);
m_buffer = NULL;
}

View File

@@ -82,7 +82,7 @@ MxResult MxStreamController::Open(const char* p_filename)
MxAutoLocker lock(&m_criticalSection);
MakeSourceName(sourceName, p_filename);
this->m_atom = MxAtomId(sourceName, LookupMode_LowerCase2);
this->m_atom = MxAtomId(sourceName, e_lowerCase2);
return SUCCESS;
}
@@ -271,7 +271,7 @@ MxResult MxStreamController::FUN_100c1f00(MxDSAction* p_action)
if (!chunk)
return FAILURE;
chunk->SetFlags(MxDSChunk::Flag_Bit3);
chunk->SetFlags(MxDSChunk::c_bit3);
chunk->SetObjectId(objectId);
if (chunk->SendChunk(m_subscriberList, FALSE, p_action->GetUnknown24()) != SUCCESS)

View File

@@ -50,7 +50,7 @@ MxStreamController* MxStreamer::Open(const char* p_name, MxU16 p_lookupType)
if (!GetOpenStream(p_name)) {
switch (p_lookupType) {
case e_DiskStream:
case e_diskStream:
stream = new MxDiskStreamController();
break;
case e_RAMStream:
@@ -84,11 +84,11 @@ MxLong MxStreamer::Close(const char* p_name)
else {
#ifdef COMPAT_MODE
{
MxStreamerNotification notification(MXSTREAMER_DELETE_NOTIFY, NULL, c);
MxStreamerNotification notification(c_notificationStreamer, NULL, c);
NotificationManager()->Send(this, &notification);
}
#else
NotificationManager()->Send(this, &MxStreamerNotification(MXSTREAMER_DELETE_NOTIFY, NULL, c));
NotificationManager()->Send(this, &MxStreamerNotification(c_notificationStreamer, NULL, c));
#endif
}
@@ -184,7 +184,7 @@ MxBool MxStreamer::FUN_100b9b30(MxDSObject& p_dsObject)
// FUNCTION: LEGO1 0x100b9b60
MxLong MxStreamer::Notify(MxParam& p_param)
{
if (((MxNotificationParam&) p_param).GetNotification() == MXSTREAMER_DELETE_NOTIFY) {
if (((MxNotificationParam&) p_param).GetNotification() == c_notificationStreamer) {
MxDSAction ds;
ds.SetUnknown24(-2);
@@ -196,11 +196,11 @@ MxLong MxStreamer::Notify(MxParam& p_param)
else {
#ifdef COMPAT_MODE
{
MxStreamerNotification notification(MXSTREAMER_DELETE_NOTIFY, NULL, c);
MxStreamerNotification notification(c_notificationStreamer, NULL, c);
NotificationManager()->Send(this, &notification);
}
#else
NotificationManager()->Send(this, &MxStreamerNotification(MXSTREAMER_DELETE_NOTIFY, NULL, c));
NotificationManager()->Send(this, &MxStreamerNotification(c_notificationStreamer, NULL, c));
#endif
}
}