From 088055e1f45e49fb40eceeeb2d8620369077e7b5 Mon Sep 17 00:00:00 2001 From: Bastien Bouclet Date: Thu, 14 Jan 2016 15:04:45 +0100 Subject: [PATCH] STARK: Improve the listScript console command It now displays if a script is waiting for a resource to complete --- engines/stark/console.cpp | 16 +++++++++++++++- engines/stark/resources/script.cpp | 4 ++++ engines/stark/resources/script.h | 7 ++++++- 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/engines/stark/console.cpp b/engines/stark/console.cpp index c26f898850e..99d0aee08d9 100644 --- a/engines/stark/console.cpp +++ b/engines/stark/console.cpp @@ -188,11 +188,25 @@ bool Console::Cmd_ListScripts(int argc, const char **argv) { Resources::Location *location = StarkGlobal->getCurrent()->getLocation(); Common::Array scriptArr = level->listChildrenRecursive(); scriptArr.insert_at(scriptArr.size(), location->listChildrenRecursive()); + Common::Array::iterator it; int i = 0; for (it = scriptArr.begin(); it != scriptArr.end(); ++it) { - debugPrintf("%d: %s - enabled: %d\n", i++, (*it)->getName().c_str(), (*it)->isEnabled()); + debugPrintf("%d: %s - enabled: %d", i++, (*it)->getName().c_str(), (*it)->isEnabled()); + + // Print which resource is causing the script to wait + if ((*it)->isSuspended()) { + Resources::Object *suspending = (*it)->getSuspendingResource(); + if (suspending) { + debugPrintf(", waiting for: %s (%s)", suspending->getName().c_str(), suspending->getType().getName()); + } else { + debugPrintf(", paused"); + } + } + + debugPrintf("\n"); } + return true; } diff --git a/engines/stark/resources/script.cpp b/engines/stark/resources/script.cpp index f80595b3a38..4ce0d3efc8f 100644 --- a/engines/stark/resources/script.cpp +++ b/engines/stark/resources/script.cpp @@ -185,6 +185,10 @@ bool Script::isSuspended() { return _pauseTimeLeft >= 0 || _suspendingResource; } +Object *Script::getSuspendingResource() const { + return _suspendingResource; +} + void Script::updateSuspended() { if (_pauseTimeLeft >= 0) { // Decrease the remaining pause time diff --git a/engines/stark/resources/script.h b/engines/stark/resources/script.h index 9cac258e5c2..8ad8f7187f0 100644 --- a/engines/stark/resources/script.h +++ b/engines/stark/resources/script.h @@ -128,6 +128,12 @@ public: /** Suspend the script while the specified resource is running */ void suspend(Object *cause); + /** Is the script paused, or waiting for a resource to complete? */ + bool isSuspended(); + + /** Get the resource the script is waiting to complete, if any */ + Object *getSuspendingResource() const; + /** Returns true if the script is enabled and valid for this call mode */ bool shouldExecute(uint32 callMode); @@ -147,7 +153,6 @@ public: protected: void printData() override; - bool isSuspended(); void updateSuspended(); void resumeCallerExecution(Object *callerObject);