From 85de624bfe17bff2af074ed97437765877903734 Mon Sep 17 00:00:00 2001 From: havoc Date: Sat, 19 May 2007 19:24:19 +0000 Subject: [PATCH] don't send svc_statubyte or any stat index over 32 to old clients git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@7320 d7cf8633-e32d-0410-b094-e92efae38249 --- protocol.c | 27 ++++++++++++++++++++++----- sv_main.c | 1 + 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/protocol.c b/protocol.c index 31594647..2bebb486 100644 --- a/protocol.c +++ b/protocol.c @@ -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) diff --git a/sv_main.c b/sv_main.c index 91718963..e24170ab 100644 --- 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; -- 2.39.2