another patch from div0 to improve ping parsing behavior in the event that multiple...
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Tue, 29 Aug 2006 12:58:45 +0000 (12:58 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Tue, 29 Aug 2006 12:58:45 +0000 (12:58 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@6576 d7cf8633-e32d-0410-b094-e92efae38249

cl_main.c
cl_parse.c
client.h
sbar.c

index fae786c..f4f09c3 100644 (file)
--- 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;
index 7eaaaae..bbe2483 100644 (file)
@@ -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 == ' ')
index 0bd5eb9..ea80fec 100644 (file)
--- 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 81b5d85..809c604 100644 (file)
--- 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
                {