Show time and in game date of game load in desync/crash logs
This commit is contained in:
@@ -400,7 +400,12 @@ char *CrashLog::FillCrashLog(char *buffer, const char *last) const
|
||||
|
||||
YearMonthDay ymd;
|
||||
ConvertDateToYMD(_date, &ymd);
|
||||
buffer += seprintf(buffer, last, "In game date: %i-%02i-%02i (%i, %i)\n\n", _cur_date_ymd.year, _cur_date_ymd.month + 1, _cur_date_ymd.day, _date_fract, _tick_skip_counter);
|
||||
buffer += seprintf(buffer, last, "In game date: %i-%02i-%02i (%i, %i)\n", _cur_date_ymd.year, _cur_date_ymd.month + 1, _cur_date_ymd.day, _date_fract, _tick_skip_counter);
|
||||
if (_game_load_time != 0) {
|
||||
buffer += seprintf(buffer, last, "Game loaded at: %i-%02i-%02i (%i, %i), %s",
|
||||
_game_load_cur_date_ymd.year, _game_load_cur_date_ymd.month + 1, _game_load_cur_date_ymd.day, _game_load_date_fract, _game_load_tick_skip_counter, asctime(gmtime(&_game_load_time)));
|
||||
}
|
||||
buffer += seprintf(buffer, last, "\n");
|
||||
|
||||
buffer = this->LogError(buffer, last, CrashLog::message);
|
||||
|
||||
@@ -448,7 +453,12 @@ char *CrashLog::FillDesyncCrashLog(char *buffer, const char *last) const
|
||||
|
||||
YearMonthDay ymd;
|
||||
ConvertDateToYMD(_date, &ymd);
|
||||
buffer += seprintf(buffer, last, "In game date: %i-%02i-%02i (%i, %i)\n\n", _cur_date_ymd.year, _cur_date_ymd.month + 1, _cur_date_ymd.day, _date_fract, _tick_skip_counter);
|
||||
buffer += seprintf(buffer, last, "In game date: %i-%02i-%02i (%i, %i)\n", _cur_date_ymd.year, _cur_date_ymd.month + 1, _cur_date_ymd.day, _date_fract, _tick_skip_counter);
|
||||
if (_game_load_time != 0) {
|
||||
buffer += seprintf(buffer, last, "Game loaded at: %s, %i-%02i-%02i (%i, %i)\n",
|
||||
asctime(gmtime(&_game_load_time)), _game_load_cur_date_ymd.year, _game_load_cur_date_ymd.month + 1, _game_load_cur_date_ymd.day, _game_load_date_fract, _game_load_tick_skip_counter);
|
||||
}
|
||||
buffer += seprintf(buffer, last, "\n");
|
||||
|
||||
buffer = this->LogOpenTTDVersion(buffer, last);
|
||||
buffer = this->LogOSVersion(buffer, last);
|
||||
|
@@ -36,6 +36,10 @@ uint32 _scaled_tick_counter; ///< Tick counter in daylength-scaled ticks
|
||||
DateTicksScaled _scaled_date_ticks; ///< Date as ticks in daylength-scaled ticks
|
||||
uint32 _quit_after_days; ///< Quit after this many days of run time
|
||||
|
||||
YearMonthDay _game_load_cur_date_ymd;
|
||||
DateFract _game_load_date_fract;
|
||||
uint8 _game_load_tick_skip_counter;
|
||||
|
||||
/**
|
||||
* Set the date.
|
||||
* @param date New date
|
||||
|
@@ -25,6 +25,10 @@ extern uint32 _scaled_tick_counter;
|
||||
extern DateTicksScaled _scaled_date_ticks;
|
||||
extern uint32 _quit_after_days;
|
||||
|
||||
extern YearMonthDay _game_load_cur_date_ymd;
|
||||
extern DateFract _game_load_date_fract;
|
||||
extern uint8 _game_load_tick_skip_counter;
|
||||
|
||||
void SetDate(Date date, DateFract fract);
|
||||
void ConvertDateToYMD(Date date, YearMonthDay *ymd);
|
||||
Date ConvertYMDToDate(Year year, Month month, Day day);
|
||||
|
@@ -83,6 +83,10 @@ void InitializeGame(uint size_x, uint size_y, bool reset_date, bool reset_settin
|
||||
_road_layout_change_counter = 0;
|
||||
_game_events_since_load = (GameEventFlags) 0;
|
||||
_game_events_overall = (GameEventFlags) 0;
|
||||
_game_load_cur_date_ymd = { 0, 0, 0 };
|
||||
_game_load_date_fract = 0;
|
||||
_game_load_tick_skip_counter = 0;
|
||||
_game_load_time = 0;
|
||||
_loadgame_DBGL_data.clear();
|
||||
if (reset_settings) MakeNewgameSettingsLive();
|
||||
|
||||
|
@@ -100,6 +100,8 @@ extern char *_config_file;
|
||||
GameEventFlags _game_events_since_load;
|
||||
GameEventFlags _game_events_overall;
|
||||
|
||||
time_t _game_load_time;
|
||||
|
||||
/**
|
||||
* Error handling for fatal user errors.
|
||||
* @param s the string to print.
|
||||
@@ -387,6 +389,10 @@ static void ShutdownGame()
|
||||
|
||||
_game_events_since_load = (GameEventFlags) 0;
|
||||
_game_events_overall = (GameEventFlags) 0;
|
||||
_game_load_cur_date_ymd = { 0, 0, 0 };
|
||||
_game_load_date_fract = 0;
|
||||
_game_load_tick_skip_counter = 0;
|
||||
_game_load_time = 0;
|
||||
_loadgame_DBGL_data.clear();
|
||||
}
|
||||
|
||||
|
@@ -108,6 +108,8 @@ inline void RegisterGameEvents(GameEventFlags events)
|
||||
|
||||
char *DumpGameEventFlags(GameEventFlags events, char *b, const char *last);
|
||||
|
||||
extern time_t _game_load_time;
|
||||
|
||||
void AskExitGame();
|
||||
void AskExitToGameMenu();
|
||||
|
||||
|
@@ -3737,6 +3737,11 @@ bool AfterLoadGame()
|
||||
AfterLoad_LinkGraphPauseControl();
|
||||
}
|
||||
|
||||
_game_load_cur_date_ymd = _cur_date_ymd;
|
||||
_game_load_date_fract = _date_fract;
|
||||
_game_load_tick_skip_counter = _tick_skip_counter;
|
||||
_game_load_time = time(nullptr);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user