Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/source/simulation2/system/ReplayTurnManager.cpp
/* Copyright (C) 2020 Wildfire Games. | /* Copyright (C) 2021 Wildfire Games. | ||||
* This file is part of 0 A.D. | * This file is part of 0 A.D. | ||||
* | * | ||||
* 0 A.D. is free software: you can redistribute it and/or modify | * 0 A.D. is free software: you can redistribute it and/or modify | ||||
* it under the terms of the GNU General Public License as published by | * it under the terms of the GNU General Public License as published by | ||||
* the Free Software Foundation, either version 2 of the License, or | * the Free Software Foundation, either version 2 of the License, or | ||||
* (at your option) any later version. | * (at your option) any later version. | ||||
* | * | ||||
* 0 A.D. is distributed in the hope that it will be useful, | * 0 A.D. is distributed in the hope that it will be useful, | ||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||
* GNU General Public License for more details. | * GNU General Public License for more details. | ||||
* | * | ||||
* You should have received a copy of the GNU General Public License | * You should have received a copy of the GNU General Public License | ||||
* along with 0 A.D. If not, see <http://www.gnu.org/licenses/>. | * along with 0 A.D. If not, see <http://www.gnu.org/licenses/>. | ||||
*/ | */ | ||||
#include "precompiled.h" | #include "precompiled.h" | ||||
#include "ReplayTurnManager.h" | #include "ReplayTurnManager.h" | ||||
#include "gui/GUIManager.h" | #include "gui/GUIManager.h" | ||||
#include "ps/CLogger.h" | #include "ps/CLogger.h" | ||||
#include "ps/Util.h" | #include "ps/Util.h" | ||||
#include "scriptinterface/ScriptInterface.h" | |||||
#include "simulation2/Simulation2.h" | #include "simulation2/Simulation2.h" | ||||
const CStr CReplayTurnManager::EventNameReplayFinished = "ReplayFinished"; | const CStr CReplayTurnManager::EventNameReplayFinished = "ReplayFinished"; | ||||
const CStr CReplayTurnManager::EventNameReplayOutOfSync = "ReplayOutOfSync"; | const CStr CReplayTurnManager::EventNameReplayOutOfSync = "ReplayOutOfSync"; | ||||
CReplayTurnManager::CReplayTurnManager(CSimulation2& simulation, IReplayLogger& replay) | CReplayTurnManager::CReplayTurnManager(CSimulation2& simulation, IReplayLogger& replay) | ||||
: CLocalTurnManager(simulation, replay) | : CLocalTurnManager(simulation, replay) | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 56 Lines • ▼ Show 20 Lines | void CReplayTurnManager::NotifyFinishedUpdate(u32 turn) | ||||
const ScriptInterface& scriptInterface = m_Simulation2.GetScriptInterface(); | const ScriptInterface& scriptInterface = m_Simulation2.GetScriptInterface(); | ||||
ScriptRequest rq(scriptInterface); | ScriptRequest rq(scriptInterface); | ||||
JS::RootedValueVector paramData(rq.cx); | JS::RootedValueVector paramData(rq.cx); | ||||
ignore_result(paramData.append(JS::NumberValue(turn))); | ignore_result(paramData.append(JS::NumberValue(turn))); | ||||
JS::RootedValue hashVal(rq.cx); | JS::RootedValue hashVal(rq.cx); | ||||
scriptInterface.ToJSVal(rq, &hashVal, hash); | ScriptInterface::ToJSVal(rq, &hashVal, hash); | ||||
ignore_result(paramData.append(hashVal)); | ignore_result(paramData.append(hashVal)); | ||||
JS::RootedValue expectedHashVal(rq.cx); | JS::RootedValue expectedHashVal(rq.cx); | ||||
scriptInterface.ToJSVal(rq, &expectedHashVal, expectedHash); | ScriptInterface::ToJSVal(rq, &expectedHashVal, expectedHash); | ||||
ignore_result(paramData.append(expectedHashVal)); | ignore_result(paramData.append(expectedHashVal)); | ||||
g_GUI->SendEventToAll(EventNameReplayOutOfSync, paramData); | g_GUI->SendEventToAll(EventNameReplayOutOfSync, paramData); | ||||
} | } | ||||
void CReplayTurnManager::DoTurn(u32 turn) | void CReplayTurnManager::DoTurn(u32 turn) | ||||
{ | { | ||||
debug_printf("Executing turn %u of %u\n", turn, m_FinalTurn); | debug_printf("Executing turn %u of %u\n", turn, m_FinalTurn); | ||||
Show All 16 Lines |
Wildfire Games · Phabricator