]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - cl_parse.c
another patch from div0 to improve ping parsing behavior in the event that multiple...
[xonotic/darkplaces.git] / cl_parse.c
index 40288c0919215a295d852bb1c57d30e8a98a0674..bbe2483e76c36467a04d192427ad44dc048e98ec 100644 (file)
@@ -1411,6 +1411,9 @@ void CL_ParseClientdata (void)
 
        // viewzoom interpolation
        cl.mviewzoom[0] = (float) max(cl.stats[STAT_VIEWZOOM], 2) * (1.0f / 255.0f);
+
+       // force a recalculation of the player prediction
+       cl.movement_replay = true;
 }
 
 /*
@@ -2049,12 +2052,20 @@ 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 = 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;
@@ -2063,35 +2074,47 @@ 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 == ' ')
                        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 == ' ')
                        {
                                int charindex = 0;
                                t++;
-                               for (charindex = 0;cl.scores[cl.parsingtextplayerindex].name[charindex] == t[charindex];charindex++)
-                                       ;
-                               if (cl.scores[cl.parsingtextplayerindex].name[charindex] == 0 && t[charindex] == '\n')
+                               if(cl.parsingtextplayerindex < cl.maxclients)
                                {
-                                       cl.scores[cl.parsingtextplayerindex].qw_ping = bound(0, ping, 9999);
-                                       for (cl.parsingtextplayerindex++;cl.parsingtextplayerindex < cl.maxclients && !cl.scores[cl.parsingtextplayerindex].name[0];cl.parsingtextplayerindex++)
+                                       for (charindex = 0;cl.scores[cl.parsingtextplayerindex].name[charindex] == t[charindex];charindex++)
                                                ;
-                                       if (cl.parsingtextplayerindex < cl.maxclients)
+                                       if (cl.scores[cl.parsingtextplayerindex].name[charindex] == 0 && t[charindex] == '\n')
                                        {
-                                               // we parsed a valid ping entry, so expect another to follow
-                                               cl.parsingtextmode = CL_PARSETEXTMODE_PING;
-                                               cl.parsingtextexpectingpingforscores = expected;
+                                               cl.scores[cl.parsingtextplayerindex].qw_ping = bound(0, ping, 9999);
+                                               for (cl.parsingtextplayerindex++;cl.parsingtextplayerindex < cl.maxclients && !cl.scores[cl.parsingtextplayerindex].name[0];cl.parsingtextplayerindex++)
+                                                       ;
+                                               //if (cl.parsingtextplayerindex < cl.maxclients) // we could still get unconnecteds!
+                                               {
+                                                       // we parsed a valid ping entry, so expect another to follow
+                                                       cl.parsingtextmode = CL_PARSETEXTMODE_PING;
+                                                       cl.parsingtextexpectingpingforscores = expected;
+                                               }
+                                               return !expected;
                                        }
+                               }
+                               if (!strncmp(t, "unconnected\n", 12))
+                               {
+                                       // just ignore
+                                       cl.parsingtextmode = CL_PARSETEXTMODE_PING;
+                                       cl.parsingtextexpectingpingforscores = expected;
                                        return !expected;
                                }
+                               else
+                                       Con_DPrintf("player names '%s' and '%s' didn't match\n", cl.scores[cl.parsingtextplayerindex].name, t);
                        }
                }
        }
@@ -2208,6 +2231,9 @@ void CL_ParseServerMessage(void)
                if (!cls.demoplayback)
                        VectorCopy(cl.mviewangles[0], cl.mviewangles[1]);
 
+               // force a recalculation of the player prediction
+               cl.movement_replay = true;
+
                // slightly kill qw player entities each frame
                for (i = 1;i < cl.maxclients;i++)
                        cl.entities_active[i] = false;