Ticket #3255: t3255_use_timestamp_and_pid_for_oosdump_filename.patch

File t3255_use_timestamp_and_pid_for_oosdump_filename.patch, 1.3 KB (added by elexis, 9 years ago)

If you run two instances of 0ad, rejoin with one player and if there is an oos, the oos_dump.txt files will have different filenames instead of being overwritten. This way you can diff the two oos-dumps. Should be included in the final patch of this ticket as well. The file should probably be moved to the sim-log subdirectory that also contains the commands.txt file.

  • source/network/NetTurnManager.cpp

     
    3131#include "ps/Replay.h"
    3232#include "ps/SavedGame.h"
    3333#include "scriptinterface/ScriptInterface.h"
    3434#include "simulation2/Simulation2.h"
    3535
     36#include<iostream>
     37#include<ctime>
     38
    3639#include <sstream>
    3740#include <fstream>
    3841#include <iomanip>
    3942
     43#if MSC_VERSION
     44#include <process.h>
     45#define getpid _getpid // use the non-deprecated function name
     46#endif
     47
    4048static const int DEFAULT_TURN_LENGTH_MP = 500;
    4149static const int DEFAULT_TURN_LENGTH_SP = 200;
    4250
    4351static const int COMMAND_DELAY = 2;
    4452
     
    230238    bool quick = !TurnNeedsFullHash(turn);
    231239    std::string hash;
    232240    bool ok = m_Simulation2.ComputeStateHash(hash, quick);
    233241    ENSURE(ok);
    234242
    235     OsPath path = psLogDir()/"oos_dump.txt";
     243    std::wstringstream name;
     244    name << L"oos_dump_" << std::time(0) << L"_" << getpid() << L".txt";
     245
     246    OsPath path = psLogDir()/name.str();
    236247    std::ofstream file (OsString(path).c_str(), std::ofstream::out | std::ofstream::trunc);
    237248    m_Simulation2.DumpDebugState(file);
    238249    file.close();
    239250
    240251    std::stringstream msg;