From 60c9d05d47556d87861452ae75eb4aa4ae012e04 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Mon, 12 Dec 2011 08:57:17 +0900 Subject: [PATCH] Hipnotic/Rogue weapon mask comments and cleanup. This too has been sitting around for a while. Taken from fitzquake. --- nq/source/cl_parse.c | 1 + nq/source/sv_main.c | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/nq/source/cl_parse.c b/nq/source/cl_parse.c index 6088860ec..62f5d2536 100644 --- a/nq/source/cl_parse.c +++ b/nq/source/cl_parse.c @@ -792,6 +792,7 @@ CL_ParseClientdata (void) Sbar_Changed (); } } else { + // hipnotic/rogue weapon "bit field" (stupid idea) if (cl.stats[STAT_ACTIVEWEAPON] != (1 << i)) { cl.stats[STAT_ACTIVEWEAPON] = (1 << i); Sbar_Changed (); diff --git a/nq/source/sv_main.c b/nq/source/sv_main.c index 389c9bd1a..3943c45c5 100644 --- a/nq/source/sv_main.c +++ b/nq/source/sv_main.c @@ -747,8 +747,15 @@ SV_WriteClientdataToMessage (edict_t *ent, sizebuf_t *msg) if (standard_quake) { MSG_WriteByte (msg, SVfloat (ent, weapon)); } else { + // NOTE: this is abysmally stupid. weapon is being treated as a + // radio button style bit mask, limiting the available weapons to + // 32. Sure, that's a lot of weapons, but still... + // + // Send the index of the lowest order set bit. + unsigned weapon; + weapon = (unsigned) SVfloat (ent, weapon); for (i = 0; i < 32; i++) { - if (((int) SVfloat (ent, weapon)) & (1 << i)) { + if (weapon & (1 << i)) { MSG_WriteByte (msg, i); break; }