From 886dd05c5ec12e07954ebe6ceff05fac41cdfe13 Mon Sep 17 00:00:00 2001 From: havoc Date: Tue, 29 Aug 2006 12:58:45 +0000 Subject: [PATCH] another patch from div0 to improve ping parsing behavior in the event that multiple ping reports are received after a query (due to packets backlogging) git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@6576 d7cf8633-e32d-0410-b094-e92efae38249 --- cl_main.c | 2 ++ cl_parse.c | 7 ++++--- client.h | 2 +- sbar.c | 17 ++++++++++++++--- 4 files changed, 21 insertions(+), 7 deletions(-) diff --git a/cl_main.c b/cl_main.c index fae786c0..f4f09c34 100644 --- a/cl_main.c +++ b/cl_main.c @@ -324,6 +324,8 @@ void CL_Disconnect(void) // stop sounds (especially looping!) S_StopAllSounds (); + cl.parsingtextexpectingpingforscores = 0; // just in case no reply has come yet + // clear contents blends cl.cshifts[0].percent = 0; cl.cshifts[1].percent = 0; diff --git a/cl_parse.c b/cl_parse.c index 7eaaaaef..bbe2483e 100644 --- a/cl_parse.c +++ b/cl_parse.c @@ -2058,13 +2058,14 @@ qboolean CL_ExaminePrintString(const char *text) { Con_Printf("ping reply but empty scoreboard?!?\n"); cl.parsingtextmode = CL_PARSETEXTMODE_NONE; - cl.parsingtextexpectingpingforscores = false; + cl.parsingtextexpectingpingforscores = 0; } + cl.parsingtextexpectingpingforscores = cl.parsingtextexpectingpingforscores ? 2 : 0; return !cl.parsingtextexpectingpingforscores; } if (!strncmp(text, "host: ", 9)) { - cl.parsingtextexpectingpingforscores = false; + // cl.parsingtextexpectingpingforscores = false; // really? cl.parsingtextmode = CL_PARSETEXTMODE_STATUS; cl.parsingtextplayerindex = 0; return true; @@ -2073,7 +2074,7 @@ qboolean CL_ExaminePrintString(const char *text) { // if anything goes wrong, we'll assume this is not a ping report qboolean expected = cl.parsingtextexpectingpingforscores; - cl.parsingtextexpectingpingforscores = false; + cl.parsingtextexpectingpingforscores = 0; cl.parsingtextmode = CL_PARSETEXTMODE_NONE; t = text; while (*t == ' ') diff --git a/client.h b/client.h index 0bd5eb90..ea80fec1 100644 --- a/client.h +++ b/client.h @@ -793,7 +793,7 @@ typedef struct client_state_s // manually, but they would still see a ping report, just a later one // caused by the scoreboard code rather than the one they intentionally // issued) - qboolean parsingtextexpectingpingforscores; + int parsingtextexpectingpingforscores; // entity database stuff // latest received entity frame numbers diff --git a/sbar.c b/sbar.c index 81b5d85b..809c6044 100644 --- a/sbar.c +++ b/sbar.c @@ -1462,9 +1462,20 @@ void Sbar_DeathmatchOverlay (void) else if (cls.protocol == PROTOCOL_QUAKE || cls.protocol == PROTOCOL_QUAKEDP || cls.protocol == PROTOCOL_NEHAHRAMOVIE || cls.protocol == PROTOCOL_DARKPLACES1 || cls.protocol == PROTOCOL_DARKPLACES2 || cls.protocol == PROTOCOL_DARKPLACES3 || cls.protocol == PROTOCOL_DARKPLACES4 || cls.protocol == PROTOCOL_DARKPLACES5 || cls.protocol == PROTOCOL_DARKPLACES6 || cls.protocol == PROTOCOL_DARKPLACES7) { // these servers usually lack the pings command and so a less efficient "ping" command must be sent, which on modern DP servers will also reply with a pingplreport command after the ping listing - cl.parsingtextexpectingpingforscores = true; // hide the output of the next ping report - MSG_WriteByte(&cls.netcon->message, clc_stringcmd); - MSG_WriteString(&cls.netcon->message, "ping"); + static int ping_anyway_counter = 0; + if(cl.parsingtextexpectingpingforscores == 1) + { + Con_DPrintf("want to send ping, but still waiting for other reply\n"); + if(++ping_anyway_counter >= 5) + cl.parsingtextexpectingpingforscores = 0; + } + if(cl.parsingtextexpectingpingforscores != 1) + { + ping_anyway_counter = 0; + cl.parsingtextexpectingpingforscores = 1; // hide the output of the next ping report + MSG_WriteByte(&cls.netcon->message, clc_stringcmd); + MSG_WriteString(&cls.netcon->message, "ping"); + } } else { -- 2.39.2