int fs2netd_check_mission_do()
{
	if (Local_timeout == -1) {
		Local_timeout = timer_get_seconds() + 15;
	}

	// if timeout passes then bail on stats failure
	if ( timer_get_seconds() > Local_timeout ) {
		Local_timeout = -1;
		return 4;
	}

	int rescode = FS2NetD_CheckSingleMission(Chk_mission_name, Chk_mission_crc, do_full_packet);

	do_full_packet = false;

	if (rescode) {
		Local_timeout = -1;
		return rescode;
	}

	return 0;
}
void fs2netd_debrief_init()
{
	if ( !(Game_mode & GM_MULTIPLAYER) ) {
		return;
	}

	if ( !Om_tracker_flag ) {
		return;
	}

	if ( !Is_connected ) {
		return;
	}


	uint CurrentMissionChsum;
	bool mValidStatus = false;

	cf_chksum_long(Netgame.mission_name, &CurrentMissionChsum);

	mValidStatus = FS2NetD_CheckSingleMission(Netgame.mission_name, CurrentMissionChsum);

	if ( ((multi_num_players() > 1) || (Multi_num_players_at_start > 1)) && !game_hacked_data() && mValidStatus ) {
		// verify that we are logged in before doing anything else
		fs2netd_login();

		int spd_ret = FS2NetD_SendPlayerData(PXO_SID, Players[Player_num].callsign, Multi_tracker_login, &Players[Player_num]);

		switch (spd_ret) { // 0 = pilot updated, 1  = invalid pilot, 2 = invalid (expired?) sid
			case -1:
				multi_display_chat_msg( XSTR("<Did not receive response from server within timeout period>", -1), 0, 0 );
				multi_display_chat_msg( XSTR("<Your stats may not have been stored>", -1), 0, 0 );
				multi_display_chat_msg( XSTR("<This is not a critical error>", -1), 0, 0 );
				Multi_debrief_stats_accept_code = 1;
				break;

			case 0:
				multi_display_chat_msg( XSTR("<stats have been accepted>", 850), 0, 0 );
				Multi_debrief_stats_accept_code = 1;
				break;

			case 1:
				multi_display_chat_msg( XSTR("<stats have been tossed>", 850), 0, 0 );
				multi_display_chat_msg( XSTR("WARNING: Your pilot was invalid, this is a serious error, possible data corruption", -1), 0, 0 );
				Multi_debrief_stats_accept_code = 0;
				break;

			case 2:
				// we really shouldn't be here with the new code, but handle it just in case
				Int3();
			
				fs2netd_login();

				if (PXO_SID != -1) {
					if ( !FS2NetD_SendPlayerData(PXO_SID, Players[Player_num].callsign, Multi_tracker_login, &Players[Player_num]) ) {
						multi_display_chat_msg( XSTR("<stats have been accepted>", 850), 0, 0 );
						Multi_debrief_stats_accept_code = 1;
						break;
					 }
				}

				multi_display_chat_msg( XSTR("<stats have been tossed>", 851), 0, 0 );
				Multi_debrief_stats_accept_code = 0;
				break;

			default:
				multi_display_chat_msg( XSTR("Unknown Stats Store Request Reply", -1), 0, 0 );
				break;
		}
	} else {
		multi_display_chat_msg( XSTR("<stats have been tossed>", 851), 0, 0 );
		Multi_debrief_stats_accept_code = 0;
	}
}