From 980fd84300a5e62b46e2f26d867a3dae13e29ae6 Mon Sep 17 00:00:00 2001 From: Adam Olsen Date: Wed, 28 Nov 2001 21:33:41 +0000 Subject: [PATCH] - make NET_SVC_Delta_* static inline - fix handling of sv_maxrate > 10000 - make SV_ExtractFromUserInfo only update netchan.rate when the rate is changed - make SV_ExtractFromUserInfo use if (*val) instead of if (strlen(val)) --- libs/net/net_svc_qw.c | 4 ++-- qw/include/server.h | 1 + qw/source/sv_main.c | 19 ++++++++++--------- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/libs/net/net_svc_qw.c b/libs/net/net_svc_qw.c index 764de5cb4..575815073 100644 --- a/libs/net/net_svc_qw.c +++ b/libs/net/net_svc_qw.c @@ -765,7 +765,7 @@ NET_SVC_Soundlist_Parse (net_svc_soundlist_t *block, msg_t *msg) } // this is a sub-block, not a real block -void +static inline void NET_SVC_Delta_Emit (entity_state_t *es, unsigned int bits, sizebuf_t *buf) { // bytes of bits: [EXT2][EXT1][ORIG][MORE] @@ -824,7 +824,7 @@ NET_SVC_Delta_Emit (entity_state_t *es, unsigned int bits, sizebuf_t *buf) } // this is a sub-block, not a real block -static void +static inline void NET_SVC_Delta_Parse (entity_state_t *es, unsigned int bits, msg_t *msg) { // bytes of bits: [EXT2][EXT1][ORIG][MORE] diff --git a/qw/include/server.h b/qw/include/server.h index 34e29c748..d99b2934c 100644 --- a/qw/include/server.h +++ b/qw/include/server.h @@ -222,6 +222,7 @@ typedef struct client_s //===== NETWORK ============ int chokecount; + int last_rate; int delta_sequence; // -1 = no compression netchan_t netchan; int msecs, msec_cheating; diff --git a/qw/source/sv_main.c b/qw/source/sv_main.c index 08c7ae16e..044c95538 100644 --- a/qw/source/sv_main.c +++ b/qw/source/sv_main.c @@ -882,6 +882,7 @@ SVC_DirectConnect (void) newcl->edict = ent; // parse some info from the info strings + newcl->last_rate = 0; SV_ExtractFromUserinfo (newcl); // JACK: Init the floodprot stuff. @@ -2201,6 +2202,8 @@ SV_ExtractFromUserinfo (client_t *cl) client_t *client; int i; qboolean badname = false; + int newrate; + int maxrate; // name from the info string val = Info_ValueForKey (cl->userinfo, "name"); @@ -2298,20 +2301,18 @@ SV_ExtractFromUserinfo (client_t *cl) // rate command val = Info_ValueForKey (cl->userinfo, "rate"); - if (strlen (val)) { - i = atoi (val); + newrate = *val ? atoi (val) : 2500; + maxrate = sv_maxrate->int_val ?: 10000; - if ((sv_maxrate->int_val) && (i > sv_maxrate->int_val)) { - i = bound (500, i, sv_maxrate->int_val); - } else { - i = bound (500, i, 10000); - } - cl->netchan.rate = 1.0 / i; + newrate = bound (500, newrate, maxrate); + if (newrate != cl->last_rate) { + cl->last_rate = newrate; + cl->netchan.rate = 1.0 / newrate; } // msg command val = Info_ValueForKey (cl->userinfo, "msg"); - if (strlen (val)) { + if (*val) { cl->messagelevel = atoi (val); }