]> de.git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
patch from div0 to fix ping report parsing where the first player slots are empty
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Sun, 27 Aug 2006 10:13:24 +0000 (10:13 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Sun, 27 Aug 2006 10:13:24 +0000 (10:13 +0000)
fixed bug in negative ping parser (it was not skipping the - when it was negative)

git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@6574 d7cf8633-e32d-0410-b094-e92efae38249

cl_parse.c

index b5c8be165070646be70d3790c65b0f5944ce5c95..68734df6031dc2dccd164cd3f7a01f305ecbb53e 100644 (file)
@@ -2052,7 +2052,14 @@ qboolean CL_ExaminePrintString(const char *text)
        if (!strcmp(text, "Client ping times:\n"))
        {
                cl.parsingtextmode = CL_PARSETEXTMODE_PING;
-               cl.parsingtextplayerindex = 0;
+               for(cl.parsingtextplayerindex = 0; cl.parsingtextplayerindex < cl.maxclients && !cl.scores[cl.parsingtextplayerindex].name[0]; cl.parsingtextplayerindex++)
+                       ;
+               if (cl.parsingtextplayerindex >= cl.maxclients) // should never happen, since the client itself should be in cl.scores
+               {
+                       Con_Printf("ping reply but empty scoreboard?!?\n");
+                       cl.parsingtextmode = CL_PARSETEXTMODE_NONE;
+                       cl.parsingtextexpectingpingforscores = false;
+               }
                return !cl.parsingtextexpectingpingforscores;
        }
        if (!strncmp(text, "host:    ", 9))
@@ -2071,10 +2078,10 @@ qboolean CL_ExaminePrintString(const char *text)
                t = text;
                while (*t == ' ')
                        t++;
-               if (*t >= '0' && *t <= '9')
+               if ((*t >= '0' && *t <= '9') || *t == '-')
                {
                        int ping = atoi(t);
-                       while (*t >= '0' && *t <= '9')
+                       while ((*t >= '0' && *t <= '9') || *t == '-')
                                t++;
                        if (*t == ' ')
                        {
@@ -2095,6 +2102,15 @@ qboolean CL_ExaminePrintString(const char *text)
                                        }
                                        return !expected;
                                }
+                               else if (!strncmp(t, "unconnected\n", 12))
+                               {
+                                       // just ignore
+                                       cl.parsingtextmode = CL_PARSETEXTMODE_PING;
+                                       cl.parsingtextexpectingpingforscores = expected;
+                                       return !expected;
+                               }
+                               else
+                                       Con_Printf("player names '%s' and '%s' didn't match\n", cl.scores[cl.parsingtextplayerindex].name, t);
                        }
                }
        }