Include last sync frame in desync crash log

This commit is contained in:
Jonathan G Rennison
2021-04-01 01:59:48 +01:00
parent dc8680eec5
commit 425b725eab
4 changed files with 23 additions and 0 deletions

View File

@@ -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", 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))); _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 += seprintf(buffer, last, "\n");
buffer = this->LogOpenTTDVersion(buffer, last); buffer = this->LogOpenTTDVersion(buffer, last);

View File

@@ -76,6 +76,9 @@ uint32 _sync_seed_2; ///< Second part of the seed.
#endif #endif
uint64 _sync_state_checksum; ///< State checksum to compare during sync checks. uint64 _sync_state_checksum; ///< State checksum to compare during sync checks.
uint32 _sync_frame; ///< The frame to perform the sync check. 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_first_time; ///< Whether we have finished joining or not.
bool _network_udp_server; ///< Is the UDP server started? bool _network_udp_server; ///< Is the UDP server started?
uint16 _network_udp_broadcast; ///< Timeout for the UDP broadcasts. 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_first_time = true;
_network_reconnect = 0; _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 */ /** Non blocking connection create to query servers */

View File

@@ -333,6 +333,9 @@ void ClientNetworkGameSocketHandler::ClientError(NetworkRecvStatus res)
my_client->ClientError(NETWORK_RECV_STATUS_DESYNC); my_client->ClientError(NETWORK_RECV_STATUS_DESYNC);
return false; 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 /* 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 * need to let the server know that we are ready and at the same

View File

@@ -118,6 +118,9 @@ extern uint32 _sync_seed_2;
#endif #endif
extern uint64 _sync_state_checksum; extern uint64 _sync_state_checksum;
extern uint32 _sync_frame; 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; extern bool _network_first_time;
/* Vars needed for the join-GUI */ /* Vars needed for the join-GUI */
extern NetworkJoinStatus _network_join_status; extern NetworkJoinStatus _network_join_status;