From 5e31017f49f23c5bb6c0c47cdacaf9ebdadcaea1 Mon Sep 17 00:00:00 2001 From: Jaime Moreira Date: Mon, 1 Aug 2022 14:34:49 -0400 Subject: [PATCH] Faster weapon switching with 'cycleweap' Allows to skip elements on the weapon list by tapping the same bound key --- src/g_cmds.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/g_cmds.c b/src/g_cmds.c index 1d621e7..7513b78 100644 --- a/src/g_cmds.c +++ b/src/g_cmds.c @@ -1461,6 +1461,7 @@ cycle_weapon(edict_t *ent) int i; int start; int num_weaps; + const char *weapname = NULL; if (!ent) { @@ -1477,11 +1478,20 @@ cycle_weapon(edict_t *ent) num_weaps = gi.argc(); /* find where we want to start the search for the next eligible weapon */ - if (cl->pers.weapon) + if (cl->newweapon) + { + weapname = cl->newweapon->classname; + } + else if (cl->pers.weapon) + { + weapname = cl->pers.weapon->classname; + } + + if (weapname) { for (i = 1; i < num_weaps; i++) { - if (Q_stricmp(cl->pers.weapon->classname, gi.argv(i)) == 0) + if (Q_stricmp(weapname, gi.argv(i)) == 0) { break; }