Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/source/simulation2/components/CCmpCommandQueue.cpp
Show First 20 Lines • Show All 97 Lines • ▼ Show 20 Lines | if (g_Game && g_Game->GetTurnManager()) | ||||
g_Game->GetTurnManager()->PostCommand(cmd); | g_Game->GetTurnManager()->PostCommand(cmd); | ||||
} | } | ||||
virtual void FlushTurn(const std::vector<SimulationCommand>& commands) | virtual void FlushTurn(const std::vector<SimulationCommand>& commands) | ||||
{ | { | ||||
const ScriptInterface& scriptInterface = GetSimContext().GetScriptInterface(); | const ScriptInterface& scriptInterface = GetSimContext().GetScriptInterface(); | ||||
ScriptInterface::Request rq(scriptInterface); | ScriptInterface::Request rq(scriptInterface); | ||||
JS::RootedValue global(rq.cx, scriptInterface.GetGlobalObject()); | JS::RootedValue global(rq.cx, rq.globalValue()); | ||||
std::vector<SimulationCommand> localCommands; | std::vector<SimulationCommand> localCommands; | ||||
m_LocalQueue.swap(localCommands); | m_LocalQueue.swap(localCommands); | ||||
for (size_t i = 0; i < localCommands.size(); ++i) | for (size_t i = 0; i < localCommands.size(); ++i) | ||||
{ | { | ||||
bool ok = scriptInterface.CallFunctionVoid(global, "ProcessCommand", localCommands[i].player, localCommands[i].data); | bool ok = scriptInterface.CallFunctionVoid(global, "ProcessCommand", localCommands[i].player, localCommands[i].data); | ||||
if (!ok) | if (!ok) | ||||
LOGERROR("Failed to call ProcessCommand() global script function"); | LOGERROR("Failed to call ProcessCommand() global script function"); | ||||
Show All 12 Lines |
Wildfire Games · Phabricator