mirror of
https://github.com/isledecomp/isle.git
synced 2024-11-22 23:57:54 -05:00
494a556f8e
* Adjustments to "decomp" language * Fix a comment * Fix accidental clang-formatting * Fix order * Fix order * Remove junk * Fix OFFSET * Adjustments based on new suggestions * Annotate globals * Globals in ISLE * More globals * Merge from parser2 branch * Allow prepending space for exact marker match * To eliminate noise, require the 0x prefix on offset for marker match * fix test from previous * Count tab stops for indented functions to reduce MISSED_END_OF_FUNCTION noise * FUNCTION to SYNTHETIC where needed * Missed marker conversion on SetAtomId * pylint cleanup, remove unused code * Fix unexpected function end, add more unit tests * Be more strict about synthetic name syntax * Revert "Missed marker conversion on SetAtomId" This reverts commitd87d665127
. * Revert "FUNCTION to SYNTHETIC where needed" This reverts commit8c815418d2
. * Implicit lookup by name for functions * Fix VTABLE SYNTHETIC and other decomp markers * Get vtable class name * Vtable marker should identify struct * No colon for SIZE comment * Update README.md * Update README.md * Update CONTRIBUTING.md * Update README.md * Update README.md * Update CONTRIBUTING.md * Update README.md * Update CONTRIBUTING.md * Fix destructor/annotation * Update README.md * Update README.md * Update README.md * Update README.md * Update README.md --------- Co-authored-by: disinvite <disinvite@users.noreply.github.com>
187 lines
4 KiB
C++
187 lines
4 KiB
C++
#include "mxstreamer.h"
|
|
|
|
#include "legoomni.h"
|
|
#include "mxdiskstreamcontroller.h"
|
|
#include "mxnotificationmanager.h"
|
|
#include "mxramstreamcontroller.h"
|
|
|
|
#include <algorithm>
|
|
|
|
DECOMP_SIZE_ASSERT(MxStreamer, 0x2c);
|
|
|
|
// FUNCTION: LEGO1 0x100b8f00
|
|
MxStreamer::MxStreamer()
|
|
{
|
|
NotificationManager()->Register(this);
|
|
}
|
|
|
|
// FUNCTION: LEGO1 0x100b9190
|
|
MxResult MxStreamer::Create()
|
|
{
|
|
undefined* b = new undefined[m_subclass1.GetSize() * 0x5800];
|
|
m_subclass1.SetBuffer(b);
|
|
if (b) {
|
|
b = new undefined[m_subclass2.GetSize() * 0x800];
|
|
m_subclass2.SetBuffer(b);
|
|
if (b) {
|
|
return SUCCESS;
|
|
}
|
|
}
|
|
|
|
return FAILURE;
|
|
}
|
|
|
|
// FUNCTION: LEGO1 0x100b91d0
|
|
MxStreamer::~MxStreamer()
|
|
{
|
|
while (!m_openStreams.empty()) {
|
|
MxStreamController* c = m_openStreams.front();
|
|
m_openStreams.pop_front();
|
|
delete c;
|
|
}
|
|
|
|
NotificationManager()->Unregister(this);
|
|
}
|
|
|
|
// FUNCTION: LEGO1 0x100b92c0
|
|
MxStreamController* MxStreamer::Open(const char* p_name, MxU16 p_lookupType)
|
|
{
|
|
// TODO
|
|
MxStreamController* stream = NULL;
|
|
|
|
if (!GetOpenStream(p_name)) {
|
|
switch (p_lookupType) {
|
|
case e_DiskStream:
|
|
stream = new MxDiskStreamController();
|
|
break;
|
|
case e_RAMStream:
|
|
stream = new MxRAMStreamController();
|
|
break;
|
|
}
|
|
|
|
if (!stream || stream->Open(p_name) != SUCCESS || AddStreamControllerToOpenList(stream) != SUCCESS) {
|
|
delete stream;
|
|
stream = NULL;
|
|
}
|
|
}
|
|
|
|
return stream;
|
|
}
|
|
|
|
// FUNCTION: LEGO1 0x100b9570
|
|
MxLong MxStreamer::Close(const char* p)
|
|
{
|
|
MxDSAction ds;
|
|
|
|
ds.SetUnknown24(-2);
|
|
|
|
for (list<MxStreamController*>::iterator it = m_openStreams.begin(); it != m_openStreams.end(); it++) {
|
|
MxStreamController* c = *it;
|
|
|
|
if (!p || !strcmp(p, c->GetAtom().GetInternal())) {
|
|
m_openStreams.erase(it);
|
|
|
|
if (!c->FUN_100c20d0(ds)) {
|
|
MxStreamerNotification notif(MXSTREAMER_DELETE_NOTIFY, NULL, c);
|
|
|
|
NotificationManager()->Send(this, ¬if);
|
|
}
|
|
else {
|
|
delete c;
|
|
}
|
|
|
|
return SUCCESS;
|
|
}
|
|
}
|
|
|
|
return FAILURE;
|
|
}
|
|
|
|
// FUNCTION: LEGO1 0x100b9700
|
|
MxNotificationParam* MxStreamerNotification::Clone()
|
|
{
|
|
return new MxStreamerNotification(m_type, m_sender, m_controller);
|
|
}
|
|
|
|
// FUNCTION: LEGO1 0x100b9870
|
|
MxStreamController* MxStreamer::GetOpenStream(const char* p_name)
|
|
{
|
|
for (list<MxStreamController*>::iterator it = m_openStreams.begin(); it != m_openStreams.end(); it++) {
|
|
MxStreamController* c = *it;
|
|
MxAtomId& atom = c->GetAtom();
|
|
if (p_name) {
|
|
if (!strcmp(atom.GetInternal(), p_name)) {
|
|
return *it;
|
|
}
|
|
}
|
|
}
|
|
|
|
return NULL;
|
|
}
|
|
|
|
// FUNCTION: LEGO1 0x100b9930
|
|
MxResult MxStreamer::AddStreamControllerToOpenList(MxStreamController* stream)
|
|
{
|
|
if (find(m_openStreams.begin(), m_openStreams.end(), stream) == m_openStreams.end()) {
|
|
m_openStreams.push_back(stream);
|
|
return SUCCESS;
|
|
}
|
|
|
|
return FAILURE;
|
|
}
|
|
|
|
// FUNCTION: LEGO1 0x100b99b0
|
|
MxResult MxStreamer::FUN_100b99b0(MxDSAction* p_action)
|
|
{
|
|
MxStreamController* controller;
|
|
if (p_action != NULL && p_action->GetAtomId().GetInternal() != NULL && p_action->GetObjectId() != -1) {
|
|
controller = GetOpenStream(p_action->GetAtomId().GetInternal());
|
|
if (controller == NULL) {
|
|
return FAILURE;
|
|
}
|
|
return controller->vtable0x20(p_action);
|
|
}
|
|
return FAILURE;
|
|
}
|
|
|
|
// FUNCTION: LEGO1 0x100b9b30
|
|
MxBool MxStreamer::FUN_100b9b30(MxDSObject& p_dsObject)
|
|
{
|
|
MxStreamController* controller = GetOpenStream(p_dsObject.GetAtomId().GetInternal());
|
|
if (controller)
|
|
return controller->FUN_100c20d0(p_dsObject);
|
|
return TRUE;
|
|
}
|
|
|
|
// FUNCTION: LEGO1 0x100b9b60
|
|
MxLong MxStreamer::Notify(MxParam& p)
|
|
{
|
|
if (((MxNotificationParam&) p).GetNotification() == MXSTREAMER_DELETE_NOTIFY) {
|
|
MxDSAction ds;
|
|
|
|
ds.SetUnknown24(-2);
|
|
|
|
MxStreamController* c = static_cast<MxStreamerNotification&>(p).GetController();
|
|
|
|
if (!c->FUN_100c20d0(ds)) {
|
|
MxStreamerNotification notif(MXSTREAMER_DELETE_NOTIFY, NULL, c);
|
|
NotificationManager()->Send(this, ¬if);
|
|
}
|
|
else {
|
|
delete c;
|
|
}
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
// No offset, function is always inlined
|
|
MxStreamerSubClass1::MxStreamerSubClass1(undefined4 size)
|
|
{
|
|
m_buffer = NULL;
|
|
m_size = size;
|
|
undefined4* ptr = &m_unk08;
|
|
for (int i = 0; i >= 0; i--) {
|
|
ptr[i] = 0;
|
|
}
|
|
}
|