Include elapsed state ticks since load in crash/failure logs
Consolidate game load date/time variables
This commit is contained in:
@@ -560,11 +560,7 @@ char *CrashLog::FillCrashLog(char *buffer, const char *last)
|
||||
buffer += UTCTime::Format(buffer, last, "Crash at: %Y-%m-%d %H:%M:%S (UTC)\n");
|
||||
|
||||
buffer += seprintf(buffer, last, "In game date: %i-%02i-%02i (%i, %i) (DL: %u)\n", _cur_date_ymd.year, _cur_date_ymd.month + 1, _cur_date_ymd.day, _date_fract, _tick_skip_counter, _settings_game.economy.day_length_factor);
|
||||
if (_game_load_time != 0) {
|
||||
buffer += seprintf(buffer, last, "Game loaded at: %i-%02i-%02i (%i, %i), ",
|
||||
_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 += UTCTime::Format(buffer, last, _game_load_time, "%Y-%m-%d %H:%M:%S");
|
||||
}
|
||||
LogGameLoadDateTimes(buffer, last);
|
||||
return buffer;
|
||||
});
|
||||
|
||||
@@ -682,12 +678,7 @@ char *CrashLog::FillDesyncCrashLog(char *buffer, const char *last, const DesyncE
|
||||
|
||||
buffer += seprintf(buffer, last, "In game date: %i-%02i-%02i (%i, %i) (DL: %u), %08X\n",
|
||||
_cur_date_ymd.year, _cur_date_ymd.month + 1, _cur_date_ymd.day, _date_fract, _tick_skip_counter, _settings_game.economy.day_length_factor, _frame_counter);
|
||||
if (_game_load_time != 0) {
|
||||
buffer += seprintf(buffer, last, "Game loaded at: %i-%02i-%02i (%i, %i), ",
|
||||
_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 += UTCTime::Format(buffer, last, _game_load_time, "%Y-%m-%d %H:%M:%S");
|
||||
buffer += seprintf(buffer, last, "\n");
|
||||
}
|
||||
LogGameLoadDateTimes(buffer, last);
|
||||
if (!_network_server) {
|
||||
extern Date _last_sync_date;
|
||||
extern DateFract _last_sync_date_fract;
|
||||
@@ -748,12 +739,7 @@ char *CrashLog::FillInconsistencyLog(char *buffer, const char *last, const Incon
|
||||
|
||||
buffer += seprintf(buffer, last, "In game date: %i-%02i-%02i (%i, %i) (DL: %u), %08X\n",
|
||||
_cur_date_ymd.year, _cur_date_ymd.month + 1, _cur_date_ymd.day, _date_fract, _tick_skip_counter, _settings_game.economy.day_length_factor, _frame_counter);
|
||||
if (_game_load_time != 0) {
|
||||
buffer += seprintf(buffer, last, "Game loaded at: %i-%02i-%02i (%i, %i), ",
|
||||
_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 += UTCTime::Format(buffer, last, _game_load_time, "%Y-%m-%d %H:%M:%S");
|
||||
buffer += seprintf(buffer, last, "\n");
|
||||
}
|
||||
LogGameLoadDateTimes(buffer, last);
|
||||
if (_networking && !_network_server) {
|
||||
extern Date _last_sync_date;
|
||||
extern DateFract _last_sync_date_fract;
|
||||
|
@@ -23,6 +23,7 @@
|
||||
#include "debug.h"
|
||||
#include "landscape.h"
|
||||
#include "widgets/statusbar_widget.h"
|
||||
#include "event_logs.h"
|
||||
|
||||
#include "safeguards.h"
|
||||
|
||||
@@ -36,10 +37,6 @@ StateTicks _state_ticks; ///< Current state tick
|
||||
StateTicksDelta _state_ticks_offset; ///< Offset to add when calculating a StateTicks value from a date/date fract/tick skip counter
|
||||
uint32_t _quit_after_days; ///< Quit after this many days of run time
|
||||
|
||||
YearMonthDay _game_load_cur_date_ymd;
|
||||
DateFract _game_load_date_fract;
|
||||
uint8_t _game_load_tick_skip_counter;
|
||||
|
||||
extern void ClearOutOfDateSignalSpeedRestrictions();
|
||||
|
||||
void CheckStateTicksWrap()
|
||||
@@ -59,6 +56,7 @@ void CheckStateTicksWrap()
|
||||
|
||||
_state_ticks_offset -= tick_adjust;
|
||||
_state_ticks -= tick_adjust;
|
||||
_game_load_state_ticks -= tick_adjust;
|
||||
|
||||
extern void AdjustAllSignalSpeedRestrictionTickValues(StateTicksDelta delta);
|
||||
AdjustAllSignalSpeedRestrictionTickValues(-tick_adjust);
|
||||
|
@@ -24,10 +24,6 @@ extern StateTicks _state_ticks;
|
||||
extern StateTicksDelta _state_ticks_offset;
|
||||
extern uint32_t _quit_after_days;
|
||||
|
||||
extern YearMonthDay _game_load_cur_date_ymd;
|
||||
extern DateFract _game_load_date_fract;
|
||||
extern uint8_t _game_load_tick_skip_counter;
|
||||
|
||||
void SetDate(Date date, DateFract fract);
|
||||
YearMonthDay ConvertDateToYMD(Date date);
|
||||
Date ConvertYMDToDate(Year year, Month month, Day day);
|
||||
|
@@ -12,6 +12,7 @@
|
||||
#include "string_func.h"
|
||||
#include "date_func.h"
|
||||
#include "company_func.h"
|
||||
#include "walltime_func.h"
|
||||
#include <array>
|
||||
#include <string>
|
||||
|
||||
@@ -21,6 +22,10 @@ GameEventFlags _game_events_since_load;
|
||||
GameEventFlags _game_events_overall;
|
||||
|
||||
time_t _game_load_time;
|
||||
YearMonthDay _game_load_cur_date_ymd;
|
||||
DateFract _game_load_date_fract;
|
||||
uint8_t _game_load_tick_skip_counter;
|
||||
StateTicks _game_load_state_ticks;
|
||||
|
||||
char *DumpGameEventFlags(GameEventFlags events, char *b, const char *last)
|
||||
{
|
||||
@@ -101,3 +106,14 @@ void ClearSpecialEventsLog()
|
||||
{
|
||||
_special_event_log.Reset();
|
||||
}
|
||||
|
||||
void LogGameLoadDateTimes(char *buffer, const char *last)
|
||||
{
|
||||
if (_game_load_time != 0) {
|
||||
buffer += seprintf(buffer, last, "Game loaded at: %i-%02i-%02i (%i, %i), (" OTTD_PRINTF64 " state ticks ago), ",
|
||||
_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, (_state_ticks - _game_load_state_ticks).base());
|
||||
buffer += UTCTime::Format(buffer, last, _game_load_time, "%Y-%m-%d %H:%M:%S");
|
||||
buffer += seprintf(buffer, last, "\n");
|
||||
}
|
||||
}
|
||||
|
@@ -11,6 +11,7 @@
|
||||
#define EVENT_LOGS_H
|
||||
|
||||
#include "core/enum_type.hpp"
|
||||
#include "date_type.h"
|
||||
#include <time.h>
|
||||
|
||||
enum GameEventFlags : uint32_t {
|
||||
@@ -29,6 +30,12 @@ DECLARE_ENUM_AS_BIT_SET(GameEventFlags)
|
||||
extern GameEventFlags _game_events_since_load;
|
||||
extern GameEventFlags _game_events_overall;
|
||||
|
||||
extern time_t _game_load_time;
|
||||
extern YearMonthDay _game_load_cur_date_ymd;
|
||||
extern DateFract _game_load_date_fract;
|
||||
extern uint8_t _game_load_tick_skip_counter;
|
||||
extern StateTicks _game_load_state_ticks;
|
||||
|
||||
inline void RegisterGameEvents(GameEventFlags events)
|
||||
{
|
||||
_game_events_since_load |= events;
|
||||
@@ -37,10 +44,10 @@ inline void RegisterGameEvents(GameEventFlags events)
|
||||
|
||||
char *DumpGameEventFlags(GameEventFlags events, char *b, const char *last);
|
||||
|
||||
extern time_t _game_load_time;
|
||||
|
||||
void AppendSpecialEventsLogEntry(std::string message);
|
||||
char *DumpSpecialEventsLog(char *buffer, const char *last);
|
||||
void ClearSpecialEventsLog();
|
||||
|
||||
void LogGameLoadDateTimes(char *buffer, const char *last);
|
||||
|
||||
#endif /* EVENT_LOGS_H */
|
||||
|
@@ -143,6 +143,7 @@ void InitializeGame(uint size_x, uint size_y, bool reset_date, bool reset_settin
|
||||
_game_load_cur_date_ymd = { 0, 0, 0 };
|
||||
_game_load_date_fract = 0;
|
||||
_game_load_tick_skip_counter = 0;
|
||||
_game_load_state_ticks = 0;
|
||||
_game_load_time = 0;
|
||||
_extra_aspects = 0;
|
||||
_aspect_cfg_hash = 0;
|
||||
|
@@ -534,6 +534,7 @@ static void ShutdownGame()
|
||||
_game_load_cur_date_ymd = { 0, 0, 0 };
|
||||
_game_load_date_fract = 0;
|
||||
_game_load_tick_skip_counter = 0;
|
||||
_game_load_state_ticks = 0;
|
||||
_game_load_time = 0;
|
||||
_extra_aspects = 0;
|
||||
_aspect_cfg_hash = 0;
|
||||
|
@@ -4420,6 +4420,7 @@ bool AfterLoadGame()
|
||||
_game_load_cur_date_ymd = _cur_date_ymd;
|
||||
_game_load_date_fract = _date_fract;
|
||||
_game_load_tick_skip_counter = _tick_skip_counter;
|
||||
_game_load_state_ticks = _state_ticks;
|
||||
_game_load_time = time(nullptr);
|
||||
|
||||
/* Start the scripts. This MUST happen after everything else except
|
||||
|
Reference in New Issue
Block a user