mirror of
https://github.com/isledecomp/isle.git
synced 2025-10-24 17:04:17 +00:00
Add MxTrace function (#1054)
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
#include "mxstreamcontroller.h"
|
||||
|
||||
#include "mxautolock.h"
|
||||
#include "mxdebug.h"
|
||||
#include "mxdsmultiaction.h"
|
||||
#include "mxdsstreamingaction.h"
|
||||
#include "mxmisc.h"
|
||||
@@ -41,8 +42,10 @@ MxStreamController::MxStreamController()
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x100c1290
|
||||
// FUNCTION: BETA10 0x1014e354
|
||||
MxStreamController::~MxStreamController()
|
||||
{
|
||||
MxTrace("Destroy %s controller.\n", m_atom.GetInternal());
|
||||
AUTOLOCK(m_criticalSection);
|
||||
|
||||
MxDSSubscriber* subscriber;
|
||||
@@ -313,19 +316,27 @@ MxNextActionDataStart* MxStreamController::FindNextActionDataStartFromStreamingA
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x100c20d0
|
||||
MxBool MxStreamController::FUN_100c20d0(MxDSObject& p_obj)
|
||||
// FUNCTION: BETA10 0x1014f3b5
|
||||
MxBool MxStreamController::IsStoped(MxDSObject* p_obj)
|
||||
{
|
||||
if (m_subscriberList.Find(&p_obj)) {
|
||||
MxDSSubscriber* subscriber = m_subscriberList.Find(p_obj);
|
||||
|
||||
if (subscriber) {
|
||||
MxTrace(
|
||||
"Subscriber for action (stream %d, instance %d) from %s is still here.\n",
|
||||
subscriber->GetObjectId(),
|
||||
subscriber->GetUnknown48(),
|
||||
GetAtom().GetInternal()
|
||||
);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (p_obj.IsA("MxDSMultiAction")) {
|
||||
MxDSActionList* actions = ((MxDSMultiAction&) p_obj).GetActionList();
|
||||
MxDSActionListCursor cursor(actions);
|
||||
if (p_obj->IsA("MxDSMultiAction")) {
|
||||
MxDSActionListCursor cursor(((MxDSMultiAction*) p_obj)->GetActionList());
|
||||
MxDSAction* action;
|
||||
|
||||
while (cursor.Next(action)) {
|
||||
if (!FUN_100c20d0(*action)) {
|
||||
if (!IsStoped(action)) {
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
#include "mxstreamer.h"
|
||||
|
||||
#include "mxdebug.h"
|
||||
#include "mxdiskstreamcontroller.h"
|
||||
#include "mxmisc.h"
|
||||
#include "mxnotificationmanager.h"
|
||||
#include "mxramstreamcontroller.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <assert.h>
|
||||
|
||||
DECOMP_SIZE_ASSERT(MxStreamer, 0x2c);
|
||||
DECOMP_SIZE_ASSERT(MxMemoryPool64, 0x0c);
|
||||
@@ -14,12 +16,14 @@ DECOMP_SIZE_ASSERT(MxBitset<22>, 0x04);
|
||||
DECOMP_SIZE_ASSERT(MxBitset<2>, 0x04);
|
||||
|
||||
// FUNCTION: LEGO1 0x100b8f00
|
||||
// FUNCTION: BETA10 0x10145150
|
||||
MxStreamer::MxStreamer()
|
||||
{
|
||||
NotificationManager()->Register(this);
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x100b9190
|
||||
// FUNCTION: BETA10 0x10145220
|
||||
MxResult MxStreamer::Create()
|
||||
{
|
||||
if (m_pool64.Allocate() || m_pool128.Allocate()) {
|
||||
@@ -30,42 +34,66 @@ MxResult MxStreamer::Create()
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x100b91d0
|
||||
// FUNCTION: BETA10 0x10145268
|
||||
MxStreamer::~MxStreamer()
|
||||
{
|
||||
while (!m_openStreams.empty()) {
|
||||
MxStreamController* c = m_openStreams.front();
|
||||
MxStreamController* controller = m_openStreams.front();
|
||||
|
||||
#ifdef COMPAT_MODE
|
||||
{
|
||||
MxDSAction action;
|
||||
assert(controller->IsStoped(&action));
|
||||
}
|
||||
#else
|
||||
assert(controller->IsStoped(&MxDSAction()));
|
||||
#endif
|
||||
|
||||
m_openStreams.pop_front();
|
||||
delete c;
|
||||
delete controller;
|
||||
}
|
||||
|
||||
NotificationManager()->Unregister(this);
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x100b92c0
|
||||
// FUNCTION: BETA10 0x1014542d
|
||||
MxStreamController* MxStreamer::Open(const char* p_name, MxU16 p_lookupType)
|
||||
{
|
||||
MxTrace("Open %s as %s controller\n", p_name, !p_lookupType ? "disk" : "RAM");
|
||||
MxTrace("Heap before: %d\n", DebugHeapState());
|
||||
|
||||
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;
|
||||
}
|
||||
if (GetOpenStream(p_name)) {
|
||||
goto done;
|
||||
}
|
||||
|
||||
switch (p_lookupType) {
|
||||
case e_diskStream:
|
||||
stream = new MxDiskStreamController();
|
||||
break;
|
||||
case e_RAMStream:
|
||||
stream = new MxRAMStreamController();
|
||||
break;
|
||||
}
|
||||
|
||||
if (stream == NULL) {
|
||||
goto done;
|
||||
}
|
||||
|
||||
if (stream->Open(p_name) != SUCCESS || AddStreamControllerToOpenList(stream) != SUCCESS) {
|
||||
delete stream;
|
||||
stream = NULL;
|
||||
}
|
||||
|
||||
done:
|
||||
MxTrace("Heap after: %d\n", DebugHeapState());
|
||||
return stream;
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x100b9570
|
||||
// FUNCTION: BETA10 0x10145638
|
||||
MxLong MxStreamer::Close(const char* p_name)
|
||||
{
|
||||
MxDSAction ds;
|
||||
@@ -77,7 +105,7 @@ MxLong MxStreamer::Close(const char* p_name)
|
||||
if (!p_name || !strcmp(p_name, c->GetAtom().GetInternal())) {
|
||||
m_openStreams.erase(it);
|
||||
|
||||
if (c->FUN_100c20d0(ds)) {
|
||||
if (c->IsStoped(&ds)) {
|
||||
delete c;
|
||||
}
|
||||
else {
|
||||
@@ -98,6 +126,7 @@ MxNotificationParam* MxStreamerNotification::Clone() const
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x100b9870
|
||||
// FUNCTION: BETA10 0x1014584b
|
||||
MxStreamController* MxStreamer::GetOpenStream(const char* p_name)
|
||||
{
|
||||
for (list<MxStreamController*>::iterator it = m_openStreams.begin(); it != m_openStreams.end(); it++) {
|
||||
@@ -178,7 +207,7 @@ MxBool MxStreamer::FUN_100b9b30(MxDSObject& p_dsObject)
|
||||
{
|
||||
MxStreamController* controller = GetOpenStream(p_dsObject.GetAtomId().GetInternal());
|
||||
if (controller) {
|
||||
return controller->FUN_100c20d0(p_dsObject);
|
||||
return controller->IsStoped(&p_dsObject);
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
@@ -193,7 +222,7 @@ MxLong MxStreamer::Notify(MxParam& p_param)
|
||||
|
||||
MxStreamController* c = static_cast<MxStreamerNotification&>(p_param).GetController();
|
||||
|
||||
if (c->FUN_100c20d0(ds)) {
|
||||
if (c->IsStoped(&ds)) {
|
||||
delete c;
|
||||
}
|
||||
else {
|
||||
|
||||
Reference in New Issue
Block a user