]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Compact weapon flag checks
authorterencehill <piuntn@gmail.com>
Thu, 15 Aug 2019 07:24:23 +0000 (09:24 +0200)
committerterencehill <piuntn@gmail.com>
Thu, 15 Aug 2019 07:24:23 +0000 (09:24 +0200)
qcsrc/client/hud/panel/scoreboard.qc
qcsrc/client/hud/panel/weapons.qc
qcsrc/client/view.qc
qcsrc/common/t_items.qc
qcsrc/common/weapons/all.qh
qcsrc/menu/xonotic/dialog_multiplayer_create_mutators.qc
qcsrc/menu/xonotic/keybinder.qc
qcsrc/server/miscfunctions.qc

index fc61b6f25ad2ce69c45470c521c2ca8754dc8a00..e11a134558519acaa873875f8da9922b390b1786 100644 (file)
@@ -1167,7 +1167,7 @@ vector Scoreboard_AccuracyStats_Draw(vector pos, vector rgb, vector bg_size)
                }
                if (weapon_stats < 0 && !((weapons_stat & set) || (weapons_inmap & set)))
                {
-                       if (((it.spawnflags & WEP_FLAG_HIDDEN) || (it.spawnflags & WEP_FLAG_MUTATORBLOCKED) || (it.spawnflags & WEP_FLAG_SPECIALATTACK)))
+                       if (it.spawnflags & (WEP_FLAG_HIDDEN | WEP_FLAG_MUTATORBLOCKED | WEP_FLAG_SPECIALATTACK))
                                ++nHidden;
                        else
                                ++disownedcnt;
index 96cc86a060590a84a7e88c139fd606cd1a7327d9..ac32e23cb9373195df72860661d9dcce8f2d3f7b 100644 (file)
@@ -30,7 +30,7 @@ int weaponorder_cmp(int i, int j, entity pass)
        int nHidden = 0; \
        FOREACH(Weapons, it != WEP_Null, { \
                if (weapons_stat & WepSet_FromWeapon(it)) continue; \
-               if ((it.spawnflags & WEP_FLAG_HIDDEN) || (it.spawnflags & WEP_FLAG_MUTATORBLOCKED) || (it.spawnflags & WEP_FLAG_SPECIALATTACK)) nHidden += 1; \
+               if (it.spawnflags & (WEP_FLAG_HIDDEN | WEP_FLAG_MUTATORBLOCKED | WEP_FLAG_SPECIALATTACK)) nHidden += 1; \
        }); \
        vector table_size = HUD_GetTableSize_BestItemAR((Weapons_COUNT - 1) - nHidden, panel_size, aspect); \
        columns = table_size.x; \
@@ -418,8 +418,11 @@ void HUD_Weapons()
                }
                else
                {
-                       if (((it.spawnflags & WEP_FLAG_HIDDEN) || (it.spawnflags & WEP_FLAG_MUTATORBLOCKED) || (it.spawnflags & WEP_FLAG_SPECIALATTACK)) && !(weapons_stat & WepSet_FromWeapon(it)))
+                       if (it.spawnflags & (WEP_FLAG_HIDDEN | WEP_FLAG_MUTATORBLOCKED | WEP_FLAG_SPECIALATTACK)
+                               && !(weapons_stat & WepSet_FromWeapon(it)))
+                       {
                                continue;
+                       }
                }
 
                // figure out the drawing position of weapon
index 60ae3f18a2b355592671f31b29179fe8c51fa9fb..7c3c1068b1dff2a6a0d096405cdc7d531c307552 100644 (file)
@@ -601,7 +601,7 @@ float TrueAimCheck(entity wepent)
 {
        if(wepent.activeweapon.spawnflags & WEP_FLAG_NOTRUEAIM)
                return SHOTTYPE_HITWORLD;
-       
+
        float nudge = 1; // added to traceline target and subtracted from result TOOD(divVerent): do we still need this? Doesn't the engine do this now for us?
        vector vecs, trueaimpoint, w_shotorg;
        vector mi, ma, dv;
index 15415456ff0cdcb38b9c8886bbdcbe7d78572eba..eb5a30f6cac2e1c1b8493f56c251ebaccf2388e7 100644 (file)
@@ -1766,7 +1766,7 @@ float GiveItems(entity e, float beginarg, float endarg)
                                got += GiveResourceValue(e, RES_HEALTH, op, val);
                                got += GiveResourceValue(e, RES_ARMOR, op, val);
                        case "allweapons":
-                               FOREACH(Weapons, it != WEP_Null && !(it.spawnflags & WEP_FLAG_MUTATORBLOCKED) && !(it.spawnflags & WEP_FLAG_SPECIALATTACK), got += GiveWeapon(e, it.m_id, op, val));
+                               FOREACH(Weapons, it != WEP_Null && !(it.spawnflags & (WEP_FLAG_MUTATORBLOCKED | WEP_FLAG_SPECIALATTACK)), got += GiveWeapon(e, it.m_id, op, val));
                        //case "allbuffs": // all buffs makes a player god, do not want!
                                //FOREACH(Buffs, it != BUFF_Null, got += GiveBuff(e, it.m_itemid, op, val));
                        case "allammo":
index a65a788ecf4020cd83d764fdce4b8b0f42be80eb..43398e6a5de5b539b9c9cea2b2bf187e10e63fcf 100644 (file)
@@ -319,7 +319,7 @@ STATIC_INIT(register_weapons_done)
     FOREACH(Weapons, true, {
         WepSet set = it.m_wepset = _WepSet_FromWeapon(it.m_id = i);
         WEPSET_ALL |= set;
-        if ((it.spawnflags) & WEP_FLAG_SUPERWEAPON) WEPSET_SUPERWEAPONS |= set;
+        if (it.spawnflags & WEP_FLAG_SUPERWEAPON) WEPSET_SUPERWEAPONS |= set;
         if (it == WEP_Null) continue;
         int imp = WEP_IMPULSE_BEGIN + it.m_id - 1;
         if (imp <= WEP_IMPULSE_END)
index 3e9e4cbefc66f5bc41f56c8a8b84a33032482ae6..33fe3575a8bde07be1326970f232e4087667cf6d 100644 (file)
@@ -251,7 +251,7 @@ void XonoticMutatorsDialog_fill(entity me)
        for(i = WEP_FIRST, j = 0; i <= WEP_LAST; ++i)
        {
                w = Weapons_from(i);
-               if((w.spawnflags & WEP_FLAG_HIDDEN) || (w.spawnflags & WEP_FLAG_SPECIALATTACK))
+               if (w.spawnflags & (WEP_FLAG_HIDDEN | WEP_FLAG_SPECIALATTACK))
                        continue;
                if ((j % 3) == 0)
                {
index 3706aabadb7c72b8b85d83d1c0261e2630bdaa74..6e59b8b1fef3825b6267d60821f564a1efe58942 100644 (file)
@@ -68,9 +68,9 @@ void KeyBinds_Read()
        for(int imp = 1; imp <= 9; ++imp)
        {
                string w_list = "";
-               ADD_TO_W_LIST(!(it.spawnflags & WEP_FLAG_MUTATORBLOCKED) && !(it.spawnflags & WEP_FLAG_HIDDEN) && !(it.spawnflags & WEP_FLAG_SPECIALATTACK) && !(it.spawnflags & WEP_FLAG_SUPERWEAPON));
+               ADD_TO_W_LIST(!(it.spawnflags & (WEP_FLAG_MUTATORBLOCKED | WEP_FLAG_HIDDEN | WEP_FLAG_SPECIALATTACK | WEP_FLAG_SUPERWEAPON)));
                ADD_TO_W_LIST((it.spawnflags & WEP_FLAG_SUPERWEAPON) && !(it.spawnflags & WEP_FLAG_HIDDEN));
-               ADD_TO_W_LIST((it.spawnflags & WEP_FLAG_MUTATORBLOCKED) && !(it.spawnflags & WEP_FLAG_HIDDEN) && !(it.spawnflags & WEP_FLAG_SPECIALATTACK));
+               ADD_TO_W_LIST((it.spawnflags & WEP_FLAG_MUTATORBLOCKED) && !(it.spawnflags & (WEP_FLAG_HIDDEN | WEP_FLAG_SPECIALATTACK)));
                if(w_list)
                        KEYBIND_DEF(strcat("weapon_group_", itos(imp)), substring(w_list, 0, -4));
                if(imp == 0)
index 8f875ba09806722f80d76da1eac8742898aba46e..522840e763679681c641ccd3f271122db8012ea3 100644 (file)
@@ -499,7 +499,7 @@ float want_weapon(entity weaponinfo, float allguns) // WEAPONTODO: what still ne
        allow_mutatorblocked = M_ARGV(3, bool);
 
        if(allguns)
-               d = boolean((weaponinfo.spawnflags & WEP_FLAG_NORMAL) && !(weaponinfo.spawnflags & WEP_FLAG_HIDDEN) && !(weaponinfo.spawnflags & WEP_FLAG_SPECIALATTACK));
+               d = boolean((weaponinfo.spawnflags & WEP_FLAG_NORMAL) && !(weaponinfo.spawnflags & (WEP_FLAG_HIDDEN | WEP_FLAG_SPECIALATTACK)));
        else if(!mutator_returnvalue)
                d = !(!weaponinfo.weaponstart);
 
@@ -565,7 +565,7 @@ void readplayerstartcvars()
                g_weaponarena = 1;
                g_weaponarena_list = "All Weapons";
                FOREACH(Weapons, it != WEP_Null, {
-                       if(!(it.spawnflags & WEP_FLAG_MUTATORBLOCKED) && !(it.spawnflags & WEP_FLAG_SPECIALATTACK))
+                       if(!(it.spawnflags & (WEP_FLAG_MUTATORBLOCKED | WEP_FLAG_SPECIALATTACK)))
                                g_weaponarena_weapons |= (it.m_wepset);
                });
        }
@@ -583,7 +583,7 @@ void readplayerstartcvars()
                g_weaponarena = 1;
                g_weaponarena_list = "Most Weapons";
                FOREACH(Weapons, it != WEP_Null, {
-                       if(!(it.spawnflags & WEP_FLAG_MUTATORBLOCKED) && (it.spawnflags & WEP_FLAG_NORMAL) && !(it.spawnflags & WEP_FLAG_HIDDEN) && !(it.spawnflags & WEP_FLAG_SPECIALATTACK))
+                       if ((it.spawnflags & WEP_FLAG_NORMAL) && !(it.spawnflags & (WEP_FLAG_MUTATORBLOCKED | WEP_FLAG_HIDDEN | WEP_FLAG_SPECIALATTACK)))
                                g_weaponarena_weapons |= (it.m_wepset);
                });
        }