]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Prevent hidden weapons being revealed with waypoints and centreprints 1436/head
authorbones_was_here <bones_was_here@xonotic.au>
Tue, 14 Jan 2025 15:30:41 +0000 (01:30 +1000)
committerbones_was_here <bones_was_here@xonotic.au>
Tue, 14 Jan 2025 15:57:16 +0000 (01:57 +1000)
Normally this issue isn't noticeable, but with
g_balance_blaster_weaponstart 0 the secret tubas were revealed by the
weapon_group_1 bind.

If all weapons in a group are HIDDEN, nothing is displayed when the
group bind is pressed.  This seems better than the alternatives:
- "AOL CD Thrower is not available"
- "@!#%'n Tuba is not available" even though it's in the secret room
- "No weapon in the group is available" but it's a lie

qcsrc/server/weapons/selection.qc

index efef6aaa38cbf140860ee7cecc90a47624c8e37f..91066fbac09ed4ae98ef0852a3dc1ff423942c56 100644 (file)
@@ -134,7 +134,6 @@ float W_GetCycleWeapon(entity this, string weaponorder, float dir, float imp, bo
        // We cannot tokenize in this function, as GiveItems calls this
        // function. Thus we must use car/cdr.
        float weaponwant, first_valid, prev_valid, switchtonext, switchtolast;
-       WepSet wepset = '0 0 0';
        switchtonext = switchtolast = 0;
        first_valid = prev_valid = 0;
        float weaponcur;
@@ -172,7 +171,7 @@ float W_GetCycleWeapon(entity this, string weaponorder, float dir, float imp, bo
        FOREACH(Weapons, (imp >= 0 && it.impulse == imp) || (imp < 0 && (it.m_wepset & customgroup)),
        {
                if ((it.m_wepset & STAT(WEAPONS, this))
-               || (it.m_wepset & weaponsInMap))
+               || ((it.m_wepset & weaponsInMap) && !(it.spawnflags & WEP_FLAG_HIDDEN)))
                {
                        have_other = true;
                        break;
@@ -184,16 +183,20 @@ float W_GetCycleWeapon(entity this, string weaponorder, float dir, float imp, bo
        {
                weaponwant = stof(car(rest)); rest = cdr(rest);
                wep = REGISTRY_GET(Weapons, weaponwant);
-               wepset = wep.m_wepset;
                if(imp >= 0)
                if(wep.impulse != imp)
                        continue;
 
                // skip weapons we don't own that aren't normal and aren't in the map
-               if(!(STAT(WEAPONS, this) & wepset))
-               if(!(weaponsInMap & wepset))
-               if((wep.spawnflags & WEP_FLAG_MUTATORBLOCKED) || have_other)
-                       continue;
+               if(!(STAT(WEAPONS, this) & wep.m_wepset))
+               {
+                       if(wep.spawnflags & WEP_FLAG_HIDDEN)
+                               continue;
+
+                       if(!(weaponsInMap & wep.m_wepset))
+                       if((wep.spawnflags & WEP_FLAG_MUTATORBLOCKED) || have_other)
+                               continue;
+               }
 
                if(complain)
                {
@@ -232,7 +235,7 @@ float W_GetCycleWeapon(entity this, string weaponorder, float dir, float imp, bo
        }
 
        // complain (but only for one weapon on the button that has been pressed)
-       if(complain)
+       if(wepcomplain)
        {
                this.weaponcomplainindex = wepcomplainindex + 1;
                client_hasweapon(this, wepcomplain, weaponentity, true, true);