diff --git a/src/crashlog.cpp b/src/crashlog.cpp index fc6e5d6a7a..e6f3587223 100644 --- a/src/crashlog.cpp +++ b/src/crashlog.cpp @@ -497,6 +497,16 @@ char *CrashLog::FillDesyncCrashLog(char *buffer, const char *last, const DesyncE 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))); } + if (!_network_server) { + extern Date _last_sync_date; + extern DateFract _last_sync_date_fract; + extern uint8 _last_sync_tick_skip_counter; + + YearMonthDay ymd; + ConvertDateToYMD(_last_sync_date, &ymd); + buffer += seprintf(buffer, last, "Last sync at: %i-%02i-%02i (%i, %i)", + ymd.year, ymd.month + 1, ymd.day, _last_sync_date_fract, _last_sync_tick_skip_counter); + } buffer += seprintf(buffer, last, "\n"); buffer = this->LogOpenTTDVersion(buffer, last); diff --git a/src/network/network.cpp b/src/network/network.cpp index fe5d1380d9..aa26ae1857 100644 --- a/src/network/network.cpp +++ b/src/network/network.cpp @@ -76,6 +76,9 @@ uint32 _sync_seed_2; ///< Second part of the seed. #endif uint64 _sync_state_checksum; ///< State checksum to compare during sync checks. uint32 _sync_frame; ///< The frame to perform the sync check. +Date _last_sync_date; ///< The game date of the last successfully received sync frame +DateFract _last_sync_date_fract; ///< " +uint8 _last_sync_tick_skip_counter; ///< " bool _network_first_time; ///< Whether we have finished joining or not. bool _network_udp_server; ///< Is the UDP server started? uint16 _network_udp_broadcast; ///< Timeout for the UDP broadcasts. @@ -582,6 +585,10 @@ static void NetworkInitialize(bool close_admins = true) _network_first_time = true; _network_reconnect = 0; + + _last_sync_date = 0; + _last_sync_date_fract = 0; + _last_sync_tick_skip_counter = 0; } /** Non blocking connection create to query servers */ diff --git a/src/network/network_client.cpp b/src/network/network_client.cpp index ddb5734ece..c82abdfca3 100644 --- a/src/network/network_client.cpp +++ b/src/network/network_client.cpp @@ -333,6 +333,9 @@ void ClientNetworkGameSocketHandler::ClientError(NetworkRecvStatus res) my_client->ClientError(NETWORK_RECV_STATUS_DESYNC); return false; } + _last_sync_date = _date; + _last_sync_date_fract = _date_fract; + _last_sync_tick_skip_counter = _tick_skip_counter; /* If this is the first time we have a sync-frame, we * need to let the server know that we are ready and at the same diff --git a/src/network/network_internal.h b/src/network/network_internal.h index 6442d375d7..b378dddd5b 100644 --- a/src/network/network_internal.h +++ b/src/network/network_internal.h @@ -118,6 +118,9 @@ extern uint32 _sync_seed_2; #endif extern uint64 _sync_state_checksum; extern uint32 _sync_frame; +extern Date _last_sync_date; +extern DateFract _last_sync_date_fract; +extern uint8 _last_sync_tick_skip_counter; extern bool _network_first_time; /* Vars needed for the join-GUI */ extern NetworkJoinStatus _network_join_status;