]> git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
send less stats in old protocols, a lot of them were being duplicated
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Tue, 3 Jul 2007 00:29:14 +0000 (00:29 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Tue, 3 Jul 2007 00:29:14 +0000 (00:29 +0000)
for no reason

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

protocol.c

index 1e4ea16926d4a027ff118228eabc93801d414a14..ba64a13c92f06dac01ab6305928ff0e5d2b68f6b 100644 (file)
@@ -387,9 +387,28 @@ void Protocol_UpdateClientStats(const int *stats)
        }
 }
 
+// only a few stats are within the 32 stat limit of Quake, and most of them
+// are sent every frame in svc_clientdata messages, so we only send the
+// remaining ones here
+static const int sendquakestats[] =
+{
+// quake did not send these secrets/monsters stats in this way, but doing so
+// allows a mod to increase STAT_TOTALMONSTERS during the game, and ensures
+// that STAT_SECRETS and STAT_MONSTERS are always correct (even if a client
+// didn't receive an svc_foundsecret or svc_killedmonster), which may be most
+// valuable if randomly seeking around in a demo
+STAT_TOTALSECRETS, // never changes during game
+STAT_TOTALMONSTERS, // changes in some mods
+STAT_SECRETS, // this makes svc_foundsecret unnecessary
+STAT_MONSTERS, // this makes svc_killedmonster unnecessary
+STAT_VIEWHEIGHT, // sent just for FTEQW clients
+STAT_VIEWZOOM, // this rarely changes
+-1,
+};
+
 void Protocol_WriteStatsReliable(void)
 {
-       int i;
+       int i, j;
        if (!host_client->netconnection)
                return;
        // detect changes in stats and write reliable messages
@@ -397,14 +416,9 @@ void Protocol_WriteStatsReliable(void)
        // this function can only cope with 32 stats,
        // they also do not support svc_updatestatubyte which was introduced in
        // DP6 protocol (except for QW)
-       for (i = 0;i < 32;i++)
+       for (j = 0;sendquakestats[j] >= 0;j++)
        {
-               // quickly skip zero bytes
-               if (!host_client->statsdeltabits[i >> 3])
-               {
-                       i |= 7;
-                       continue;
-               }
+               i = sendquakestats[j];
                // check if this bit is set
                if (host_client->statsdeltabits[i >> 3] & (1 << (i & 7)))
                {