Skip to content

Commit

Permalink
Refactor|Hexen: Removed redundant code (DeferredTask deserialization)
Browse files Browse the repository at this point in the history
Also print ACS world/map variables in the "scriptinfo" command.
  • Loading branch information
skyjake committed Jan 14, 2015
1 parent 23a5957 commit d15ba01
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 12 deletions.
2 changes: 2 additions & 0 deletions doomsday/plugins/hexen/include/acscript.h
Expand Up @@ -243,6 +243,8 @@ class ACScriptInterpreter
int scriptNumber; ///< On the target map.
byte args[4];

DeferredTask();

/**
* @param mapUri Unique identifier of the target map. A copy is made.
* @param scriptNumber Script number to execute on the target map.
Expand Down
34 changes: 22 additions & 12 deletions doomsday/plugins/hexen/src/acscript.cpp
Expand Up @@ -65,6 +65,12 @@ struct BytecodeScriptInfo
int waitValue;
};

ACScriptInterpreter::DeferredTask::DeferredTask()
: scriptNumber(-1)
{
de::zap(args);
}

ACScriptInterpreter::DeferredTask::DeferredTask(de::Uri const &mapUri, int scriptNumber, byte const args_[])
: mapUri (mapUri)
, scriptNumber(scriptNumber)
Expand All @@ -74,17 +80,9 @@ ACScriptInterpreter::DeferredTask::DeferredTask(de::Uri const &mapUri, int scrip

ACScriptInterpreter::DeferredTask *ACScriptInterpreter::DeferredTask::newFromReader(de::Reader &from) //static
{
de::String mapUriStr;
from >> mapUriStr;
de::Uri mapUri(mapUriStr, RC_NULL);
int scriptNumber; ///< On the target map.
from >> scriptNumber;
byte args[4];
for(int i = 0; i < 4; ++i)
{
from >> args[i];
}
return new DeferredTask(mapUri, scriptNumber, args);
std::unique_ptr<DeferredTask> task(new DeferredTask);
from >> *task;

This comment has been minimized.

Copy link
@skyjake

skyjake Jan 14, 2015

Author Owner

I don't think it was intentional that operator << () forced the "Maps" scheme on the URI while newFromReader() didn't. Now the behavior is consistent no matter which method is used.

return task.release();
}

void ACScriptInterpreter::DeferredTask::operator >> (de::Writer &to) const
Expand Down Expand Up @@ -1892,12 +1890,24 @@ D_CMD(ListACScripts)
App_Log(DE2_SCR_MSG, "No ACScripts are currently loaded.");
return true;
}

App_Log(DE2_SCR_MSG, "World variables:");
for(int i = 0; i < MAX_ACS_WORLD_VARS; ++i)
{
App_Log(DE2_SCR_MSG, " #%i: %i", i, interp.worldVars[i]);
}

App_Log(DE2_SCR_MSG, "Map variables:");
for(int i = 0; i < MAX_ACS_MAP_VARS; ++i)
{
App_Log(DE2_SCR_MSG, " #%i: %i", i, interp.mapVars[i]);
}

App_Log(DE2_SCR_MSG, "Available ACScripts:");
for(int i = 0; i < interp.scriptCount(); ++i)
{
BytecodeScriptInfo &info = interp.scriptInfoByIndex(i);
App_Log(DE2_SCR_MSG, "%s - args: %i",
App_Log(DE2_SCR_MSG, " %s - args: %i",
Str_Text(interp.scriptName(info.scriptNumber)), info.argCount);
}

Expand Down

0 comments on commit d15ba01

Please sign in to comment.