STARK: Improve the listScript console command

It now displays if a script is waiting for a resource to complete
This commit is contained in:
Bastien Bouclet 2016-01-14 15:04:45 +01:00
parent 48afd2a3ce
commit 088055e1f4
3 changed files with 25 additions and 2 deletions

View File

@ -188,11 +188,25 @@ bool Console::Cmd_ListScripts(int argc, const char **argv) {
Resources::Location *location = StarkGlobal->getCurrent()->getLocation();
Common::Array<Resources::Script *> scriptArr = level->listChildrenRecursive<Resources::Script>();
scriptArr.insert_at(scriptArr.size(), location->listChildrenRecursive<Resources::Script>());
Common::Array<Resources::Script *>::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;
}

View File

@ -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

View File

@ -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);