Merge pull request #93 from protocultor/cycleweap_quick

Faster weapon switching with 'cycleweap'
This commit is contained in:
Yamagi 2022-08-07 18:22:14 +02:00 committed by GitHub
commit 2246a943bf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1470,6 +1470,7 @@ cycle_weapon(edict_t *ent)
int i;
int start;
int num_weaps;
const char *weapname = NULL;
if (!ent)
{
@ -1486,11 +1487,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;
}