mirror of
https://gitea.wildfiregames.com/0ad/0ad.git
synced 2026-09-21 20:06:40 +00:00
Command line option for pid+timestamp in OOS dump, mainlog and interestinglog
Reviewed by: elexis Fixes #3339 Differential Revision: https://code.wildfiregames.com/D51 This was SVN commit r20141.
This commit is contained in:
@@ -64,6 +64,8 @@ Advanced / diagnostic:
|
||||
-rejointest=N simulates a rejoin and checks simulation state each turn for serialization
|
||||
errors; this is similar to a serialization test but much faster and
|
||||
less complete. It should be enough for debugging most rejoin OOSes.
|
||||
-unique-logs adds unix timestamp and process id to the filename of mainlog.html, interestinglog.html
|
||||
and oos_dump.txt to prevent these files from becoming overwritten by another pyrogenesis process.
|
||||
|
||||
Windows-specific:
|
||||
-wQpcTscSafe allow timing via QueryPerformanceCounter despite the fact
|
||||
|
||||
@@ -83,7 +83,13 @@ that of Atlas depending on commandline parameters.
|
||||
#include <unistd.h> // geteuid
|
||||
#endif // OS_UNIX
|
||||
|
||||
#if MSC_VERSION
|
||||
#include <process.h>
|
||||
#define getpid _getpid // Use the non-deprecated function name
|
||||
#endif
|
||||
|
||||
extern bool g_GameRestarted;
|
||||
extern CStrW g_UniqueLogPostfix;
|
||||
|
||||
void kill_mainloop();
|
||||
|
||||
@@ -463,6 +469,9 @@ static void RunGameOrAtlas(int argc, const char* argv[])
|
||||
return;
|
||||
}
|
||||
|
||||
if (args.Has("unique-logs"))
|
||||
g_UniqueLogPostfix = L"_" + std::to_wstring(std::time(nullptr)) + L"_" + std::to_wstring(getpid());
|
||||
|
||||
const bool isVisualReplay = args.Has("replay-visual");
|
||||
const bool isNonVisualReplay = args.Has("replay");
|
||||
const bool isNonVisual = args.Has("autostart-nonvisual");
|
||||
|
||||
@@ -33,6 +33,8 @@
|
||||
#define NETCLIENTTURN_LOG(...)
|
||||
#endif
|
||||
|
||||
extern CStrW g_UniqueLogPostfix;
|
||||
|
||||
CNetClientTurnManager::CNetClientTurnManager(CSimulation2& simulation, CNetClient& client, int clientId, IReplayLogger& replay)
|
||||
: CTurnManager(simulation, DEFAULT_TURN_LENGTH_MP, clientId, replay), m_NetClient(client)
|
||||
{
|
||||
@@ -116,8 +118,8 @@ void CNetClientTurnManager::OnSyncError(u32 turn, const CStr& expectedHash, cons
|
||||
std::string hash;
|
||||
ENSURE(m_Simulation2.ComputeStateHash(hash, !TurnNeedsFullHash(turn)));
|
||||
|
||||
OsPath path = psLogDir() / "oos_dump.txt";
|
||||
std::ofstream file (OsString(path).c_str(), std::ofstream::out | std::ofstream::trunc);
|
||||
OsPath oosdumpPath(psLogDir() / (L"oos_dump" + g_UniqueLogPostfix + L".txt"));
|
||||
std::ofstream file (OsString(oosdumpPath).c_str(), std::ofstream::out | std::ofstream::trunc);
|
||||
m_Simulation2.DumpDebugState(file);
|
||||
file.close();
|
||||
|
||||
@@ -131,7 +133,7 @@ void CNetClientTurnManager::OnSyncError(u32 turn, const CStr& expectedHash, cons
|
||||
playerNamesStrings.push_back(name);
|
||||
}
|
||||
|
||||
LOGERROR("Out-Of-Sync on turn %d\nPlayers: %s\nDumping state to %s", turn, playerNamesString.str().c_str(), path.string8());
|
||||
LOGERROR("Out-Of-Sync on turn %d\nPlayers: %s\nDumping state to %s", turn, playerNamesString.str().c_str(), oosdumpPath.string8());
|
||||
|
||||
ScriptInterface& scriptInterface = m_NetClient.GetScriptInterface();
|
||||
JSContext* cx = scriptInterface.GetContext();
|
||||
@@ -143,7 +145,7 @@ void CNetClientTurnManager::OnSyncError(u32 turn, const CStr& expectedHash, cons
|
||||
scriptInterface.SetProperty(msg, "players", playerNamesStrings);
|
||||
scriptInterface.SetProperty(msg, "expectedHash", expectedHashHex);
|
||||
scriptInterface.SetProperty(msg, "hash", Hexify(hash));
|
||||
scriptInterface.SetProperty(msg, "path_oos_dump", wstring_from_utf8(path.string8()));
|
||||
scriptInterface.SetProperty(msg, "path_oos_dump", wstring_from_utf8(oosdumpPath.string8()));
|
||||
scriptInterface.SetProperty(msg, "path_replay", wstring_from_utf8(m_Replay.GetDirectory().string8()));
|
||||
m_NetClient.PushGuiMessage(msg);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2016 Wildfire Games.
|
||||
/* Copyright (C) 2017 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@@ -34,6 +34,7 @@
|
||||
|
||||
#include <boost/algorithm/string/replace.hpp>
|
||||
|
||||
CStrW g_UniqueLogPostfix;
|
||||
static const double RENDER_TIMEOUT = 10.0; // seconds before messages are deleted
|
||||
static const double RENDER_TIMEOUT_RATE = 10.0; // number of timed-out messages deleted per second
|
||||
static const size_t RENDER_LIMIT = 20; // maximum messages on screen at once
|
||||
@@ -65,10 +66,11 @@ const char* html_header1 = "</h2>\n";
|
||||
|
||||
CLogger::CLogger()
|
||||
{
|
||||
OsPath mainlogPath(psLogDir()/"mainlog.html");
|
||||
OsPath mainlogPath(psLogDir() / (L"mainlog" + g_UniqueLogPostfix + L".html"));
|
||||
m_MainLog = new std::ofstream(OsString(mainlogPath).c_str(), std::ofstream::out | std::ofstream::trunc);
|
||||
debug_printf("Writing the mainlog at %s\n", mainlogPath.string8().c_str());
|
||||
|
||||
OsPath interestinglogPath(psLogDir()/"interestinglog.html");
|
||||
OsPath interestinglogPath(psLogDir() / (L"interestinglog" + g_UniqueLogPostfix + L".html"));
|
||||
m_InterestingLog = new std::ofstream(OsString(interestinglogPath).c_str(), std::ofstream::out | std::ofstream::trunc);
|
||||
|
||||
m_OwnsStreams = true;
|
||||
|
||||
Reference in New Issue
Block a user