Visual replay code cleanup. Refs #3440.

Moves StartVisualReplay() from JSInterface_VisualReplay.cpp to
VisualReplay.cpp, so that the former doesn't define any logic.
Uses replayFile.string8() instead of
utf8_from_wstring(replayFile.string()).
SAFE_DELETE instead of delete.
Fixes a compiler warning in getReplayDuration().

This was SVN commit r17314.
This commit is contained in:
elexis
2015-11-29 00:23:18 +00:00
parent 8cf2333568
commit 7de746cc58
4 changed files with 29 additions and 23 deletions
@@ -17,26 +17,12 @@
#include "precompiled.h"
#include "network/NetClient.h"
#include "network/NetServer.h"
#include "ps/Filesystem.h"
#include "ps/Game.h"
#include "ps/VisualReplay.h"
#include "ps/scripting/JSInterface_VisualReplay.h"
void JSI_VisualReplay::StartVisualReplay(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), CStrW directory)
{
ENSURE(!g_NetServer);
ENSURE(!g_NetClient);
ENSURE(!g_Game);
const OsPath replayFile = VisualReplay::GetDirectoryName() / directory / L"commands.txt";
if (FileExists(replayFile))
{
g_Game = new CGame(false, false);
// TODO: support unicode when OsString() is implemented for windows
g_Game->StartVisualReplay(utf8_from_wstring(replayFile.string()));
}
VisualReplay::StartVisualReplay(directory);
}
bool JSI_VisualReplay::DeleteReplay(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), CStrW replayFile)