X-Git-Url: http://de.git.xonotic.org/?a=blobdiff_plain;f=protocol.c;h=1493bca32893f0ed53a9036fa231b8f7c6731088;hb=d24a662a278e76b2cbcf4528dccc6c2196ab1eda;hp=848ad7c7f2357bdab1682b6e501e413c6fdef396;hpb=9e883a148a3370e139b78a19d2ee645fba8db8d1;p=xonotic%2Fdarkplaces.git diff --git a/protocol.c b/protocol.c index 848ad7c7..1493bca3 100644 --- a/protocol.c +++ b/protocol.c @@ -52,7 +52,7 @@ protocolversioninfo[] = {15, "QUAKEDP"}, {250, "NEHAHRAMOVIE"}, {15, "QUAKE"}, - {28, "QUAKEWORLD"}, + {28, "QW"}, {0, NULL} }; @@ -93,8 +93,8 @@ void Protocol_Names(char *buffer, size_t buffersize) for (i = 1;protocolversioninfo[i].name;i++) { if (i > 1) - strlcat(buffer, " ", sizeof(buffer)); - strlcat(buffer, protocolversioninfo[i].name, sizeof(buffer)); + strlcat(buffer, " ", buffersize); + strlcat(buffer, protocolversioninfo[i].name, buffersize); } } @@ -387,33 +387,62 @@ 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 - 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 (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))) { 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 +532,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) @@ -522,8 +553,11 @@ void EntityFrameQuake_WriteFrame(sizebuf_t *msg, int numstates, const entity_sta MSG_WriteByte (&buf, bits); if (bits & U_MOREBITS) MSG_WriteByte(&buf, bits>>8); - if (bits & U_EXTEND1) MSG_WriteByte(&buf, bits>>16); - if (bits & U_EXTEND2) MSG_WriteByte(&buf, bits>>24); + if (sv.protocol != PROTOCOL_NEHAHRAMOVIE) + { + if (bits & U_EXTEND1) MSG_WriteByte(&buf, bits>>16); + if (bits & U_EXTEND2) MSG_WriteByte(&buf, bits>>24); + } if (bits & U_LONGENTITY) MSG_WriteShort(&buf, s->number); else MSG_WriteByte(&buf, s->number); @@ -2180,7 +2214,7 @@ void EntityFrame5_LostFrame(entityframe5_database_t *d, int framenum) { d->deltabits[s->number] |= bits; // if it was a very important update, set priority higher - if (bits & (E5_FULLUPDATE | E5_ATTACHMENT | E5_MODEL || E5_COLORMAP)) + if (bits & (E5_FULLUPDATE | E5_ATTACHMENT | E5_MODEL | E5_COLORMAP)) d->priorities[s->number] = max(d->priorities[s->number], 4); else d->priorities[s->number] = max(d->priorities[s->number], 1);