Changeset View
Changeset View
Standalone View
Standalone View
source/ps/Replay.cpp
/* Copyright (C) 2018 Wildfire Games. | /* Copyright (C) 2019 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, | ||||
▲ Show 20 Lines • Show All 57 Lines • ▼ Show 20 Lines | void CReplayLogger::StartGame(JS::MutableHandleValue attribs) | ||||
// Add timestamp, since the file-modification-date can change | // Add timestamp, since the file-modification-date can change | ||||
m_ScriptInterface.SetProperty(attribs, "timestamp", (double)std::time(nullptr)); | m_ScriptInterface.SetProperty(attribs, "timestamp", (double)std::time(nullptr)); | ||||
// Add engine version and currently loaded mods for sanity checks when replaying | // Add engine version and currently loaded mods for sanity checks when replaying | ||||
m_ScriptInterface.SetProperty(attribs, "engine_version", CStr(engine_version)); | m_ScriptInterface.SetProperty(attribs, "engine_version", CStr(engine_version)); | ||||
JS::RootedValue mods(cx, Mod::GetLoadedModsWithVersions(m_ScriptInterface)); | JS::RootedValue mods(cx, Mod::GetLoadedModsWithVersions(m_ScriptInterface)); | ||||
m_ScriptInterface.SetProperty(attribs, "mods", mods); | m_ScriptInterface.SetProperty(attribs, "mods", mods); | ||||
m_Directory = createDateIndexSubdirectory(VisualReplay::GetDirectoryName()); | m_Directory = createDateIndexSubdirectory(VisualReplay::GetDirectoryPath()); | ||||
debug_printf("Writing replay to %s\n", m_Directory.string8().c_str()); | debug_printf("Writing replay to %s\n", m_Directory.string8().c_str()); | ||||
m_Stream = new std::ofstream(OsString(m_Directory / L"commands.txt").c_str(), std::ofstream::out | std::ofstream::trunc); | m_Stream = new std::ofstream(OsString(m_Directory / L"commands.txt").c_str(), std::ofstream::out | std::ofstream::trunc); | ||||
*m_Stream << "start " << m_ScriptInterface.StringifyJSON(attribs, false) << "\n"; | *m_Stream << "start " << m_ScriptInterface.StringifyJSON(attribs, false) << "\n"; | ||||
} | } | ||||
void CReplayLogger::Turn(u32 n, u32 turnLength, std::vector<SimulationCommand>& commands) | void CReplayLogger::Turn(u32 n, u32 turnLength, std::vector<SimulationCommand>& commands) | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 231 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator