]> de.git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
don't send svc_statubyte or any stat index over 32 to old clients
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Sat, 19 May 2007 19:24:19 +0000 (19:24 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Sat, 19 May 2007 19:24:19 +0000 (19:24 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@7320 d7cf8633-e32d-0410-b094-e92efae38249

protocol.c
sv_main.c

index 31594647006d39720303d3842d8a3a63368ace67..2bebb4866ae23ac543a595f8edfc95b4915f57b5 100644 (file)
@@ -393,7 +393,11 @@ void Protocol_WriteStatsReliable(void)
        if (!host_client->netconnection)
                return;
        // detect changes in stats and write reliable messages
-       for (i = 0;i < MAX_CL_STATS;i++)
+       // this only deals with 32 stats because the older protocols which use
+       // 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++)
        {
                // quickly skip zero bytes
                if (!host_client->statsdeltabits[i >> 3])
@@ -406,14 +410,25 @@ void Protocol_WriteStatsReliable(void)
                {
                        host_client->statsdeltabits[i >> 3] -= (1 << (i & 7));
                        // send the stat as a byte if possible
-                       if (host_client->stats[i] >= 0 && host_client->stats[i] < 256)
+                       if (sv.protocol == PROTOCOL_QUAKEWORLD)
                        {
-                               MSG_WriteByte(&host_client->netconnection->message, svc_updatestatubyte);
-                               MSG_WriteByte(&host_client->netconnection->message, i);
-                               MSG_WriteByte(&host_client->netconnection->message, host_client->stats[i]);
+                               if (host_client->stats[i] >= 0 && host_client->stats[i] < 256)
+                               {
+                                       MSG_WriteByte(&host_client->netconnection->message, qw_svc_updatestat);
+                                       MSG_WriteByte(&host_client->netconnection->message, i);
+                                       MSG_WriteByte(&host_client->netconnection->message, host_client->stats[i]);
+                               }
+                               else
+                               {
+                                       MSG_WriteByte(&host_client->netconnection->message, qw_svc_updatestatlong);
+                                       MSG_WriteByte(&host_client->netconnection->message, i);
+                                       MSG_WriteLong(&host_client->netconnection->message, host_client->stats[i]);
+                               }
                        }
                        else
                        {
+                               // this could make use of svc_updatestatubyte in DP6 and later
+                               // protocols but those protocols do not use this function
                                MSG_WriteByte(&host_client->netconnection->message, svc_updatestat);
                                MSG_WriteByte(&host_client->netconnection->message, i);
                                MSG_WriteLong(&host_client->netconnection->message, host_client->stats[i]);
@@ -503,6 +518,8 @@ void EntityFrameQuake_WriteFrame(sizebuf_t *msg, int numstates, const entity_sta
                        bits |= U_GLOWSIZE;
                if (baseline.glowcolor != s->glowcolor)
                        bits |= U_GLOWCOLOR;
+               if (!VectorCompare(baseline.colormod, s->colormod))
+                       bits |= U_COLORMOD;
 
                // if extensions are disabled, clear the relevant update flags
                if (sv.protocol == PROTOCOL_QUAKE || sv.protocol == PROTOCOL_NEHAHRAMOVIE)
index 917189630cc00382ab71b10ed645533fff52f6de..e24170ab436e319a84e730dac25f878b1dcd3e0c 100644 (file)
--- a/sv_main.c
+++ b/sv_main.c
@@ -1364,6 +1364,7 @@ void SV_WriteClientdataToMessage (client_t *client, prvm_edict_t *ent, sizebuf_t
        //stats[STAT_MONSTERS] = prog->globals.server->killed_monsters;
 
        // movement settings for prediction
+       // note: these are not sent in protocols with lower MAX_CL_STATS limits
        statsf[STAT_MOVEVARS_TICRATE] = sys_ticrate.value;
        statsf[STAT_MOVEVARS_TIMESCALE] = slowmo.value;
        statsf[STAT_MOVEVARS_GRAVITY] = sv_gravity.value;