Ticket #3339: t3339_command_line_option_ooslog_unique_v1.patch
File t3339_command_line_option_ooslog_unique_v1.patch, 2.8 KB (added by , 9 years ago) |
---|
-
binaries/system/readme.txt
51 51 -writableRoot store runtime game data in root data directory 52 52 (only use if you have write permissions on that directory) 53 53 -ooslog dumps simulation state in binary and ASCII representations each turn, 54 54 files created in sim_log within the game's log folder. NOTE: game will 55 55 run much slower with this option! 56 -ooslog-unique adds unix timestamp and process id to the filename of the out of sync log 57 to prevent the file from being overwritten by another process. 56 58 -serializationtest checks simulation state each turn for serialization errors; on test 57 59 failure, error is displayed and logs created in oos_log within the 58 60 game's log folder. NOTE: game will run much slower with this option! 59 61 60 62 Windows-specific: -
source/network/NetTurnManager.cpp
24 24 #include "network/NetMessage.h" 25 25 26 26 #include "gui/GUIManager.h" 27 27 #include "maths/MathUtil.h" 28 28 #include "ps/CLogger.h" 29 #include "ps/GameSetup/CmdLineArgs.h" 29 30 #include "ps/Profile.h" 30 31 #include "ps/Pyrogenesis.h" 31 32 #include "ps/Replay.h" 32 33 #include "ps/SavedGame.h" 33 34 #include "scriptinterface/ScriptInterface.h" 34 35 #include "simulation2/Simulation2.h" 35 36 37 #include<iostream> 38 #include<ctime> 39 36 40 #include <sstream> 37 41 #include <fstream> 38 42 #include <iomanip> 39 43 44 #if MSC_VERSION 45 #include <process.h> 46 #define getpid _getpid // use the non-deprecated function name 47 #endif 48 40 49 static const int DEFAULT_TURN_LENGTH_MP = 500; 41 50 static const int DEFAULT_TURN_LENGTH_SP = 200; 42 51 43 52 static const int COMMAND_DELAY = 2; 44 53 … … 228 237 229 238 bool quick = !TurnNeedsFullHash(turn); 230 239 std::string hash; 231 240 ENSURE(m_Simulation2.ComputeStateHash(hash, quick)); 232 241 233 OsPath path = psLogDir()/"oos_dump.txt"; 242 std::wstringstream name; 243 name << L"oos_dump"; 244 if (g_args.Has("ooslog-unique")) 245 name << L"_" << std::time(0) << L"_" << getpid(); 246 name << L".txt"; 247 248 OsPath path = psLogDir()/name.str(); 234 249 std::ofstream file (OsString(path).c_str(), std::ofstream::out | std::ofstream::trunc); 235 250 m_Simulation2.DumpDebugState(file); 236 251 file.close(); 237 252 238 253 hash = Hexify(hash); -
source/network/NetTurnManager.h
23 23 24 24 #include <list> 25 25 #include <map> 26 26 #include <vector> 27 27 28 extern CmdLineArgs g_args; 29 28 30 class CNetServerWorker; 29 31 class CNetClient; 30 32 class CSimulationMessage; 31 33 class CSimulation2; 32 34 class IReplayLogger;