]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Optimize bitset operations
authork9er <k9wolf@pm.me>
Thu, 2 Jan 2025 00:25:24 +0000 (00:25 +0000)
committerterencehill <piuntn@gmail.com>
Thu, 2 Jan 2025 00:25:24 +0000 (00:25 +0000)
35 files changed:
qcsrc/client/hud/hud_config.qc
qcsrc/client/hud/panel/quickmenu.qc
qcsrc/client/hud/panel/radar.qc
qcsrc/client/hud/panel/scoreboard.qc
qcsrc/client/hud/panel/strafehud.qc
qcsrc/client/hud/panel/weapons.qc
qcsrc/client/items/items.qc
qcsrc/client/main.qc
qcsrc/client/mapvoting.qc
qcsrc/common/gamemodes/gamemode/invasion/sv_invasion.qc
qcsrc/common/minigames/cl_minigames_hud.qc
qcsrc/common/minigames/minigame/bd.qc
qcsrc/common/minigames/minigame/c4.qc
qcsrc/common/minigames/minigame/pp.qc
qcsrc/common/minigames/minigame/ps.qc
qcsrc/common/minigames/minigame/ttt.qc
qcsrc/common/monsters/sv_monsters.qc
qcsrc/common/mutators/mutator/buffs/sv_buffs.qh
qcsrc/common/mutators/mutator/overkill/okrpc.qc
qcsrc/common/mutators/mutator/superspec/sv_superspec.qc
qcsrc/common/physics/player.qh
qcsrc/common/weapons/weapon/arc.qc
qcsrc/common/weapons/weapon/tuba.qc
qcsrc/lib/intrusivelist.qh
qcsrc/lib/warpzone/common.qh
qcsrc/server/bot/default/havocbot/havocbot.qc
qcsrc/server/client.qc
qcsrc/server/damage.qc
qcsrc/server/hook.qh
qcsrc/server/items/items.qc
qcsrc/server/portals.qc
qcsrc/server/scores.qc
qcsrc/server/weapons/accuracy.qc
qcsrc/server/weapons/selection.qc
qcsrc/server/weapons/throwing.qc

index 726b2e78d9565097699d67bcb5a46018d8194d33..2bb17dbbeb93d5127e66eb5c354a63937b508ad0 100644 (file)
@@ -548,11 +548,11 @@ float HUD_Panel_InputEvent(float bInputType, float nPrimary, float nSecondary)
                if(nPrimary == K_MOUSE2) mouseClicked |= S_MOUSE2;
        }
        else {
-               if(nPrimary == K_ALT) hudShiftState -= (hudShiftState & S_ALT);
-               if(nPrimary == K_CTRL) hudShiftState -= (hudShiftState & S_CTRL);
-               if(nPrimary == K_SHIFT) hudShiftState -= (hudShiftState & S_SHIFT);
-               if(nPrimary == K_MOUSE1) mouseClicked -= (mouseClicked & S_MOUSE1);
-               if(nPrimary == K_MOUSE2) mouseClicked -= (mouseClicked & S_MOUSE2);
+               if(nPrimary == K_ALT) hudShiftState &= ~S_ALT;
+               if(nPrimary == K_CTRL) hudShiftState &= ~S_CTRL;
+               if(nPrimary == K_SHIFT) hudShiftState &= ~S_SHIFT;
+               if(nPrimary == K_MOUSE1) mouseClicked &= ~S_MOUSE1;
+               if(nPrimary == K_MOUSE2) mouseClicked &= ~S_MOUSE2;
        }
 
        if(nPrimary == K_CTRL)
index 710245445046c94e1c9a6e1f3dfd6a6cc5a0e19d..21fa2253d5e77dcab2c91e5a40152ff8b17c762e 100644 (file)
@@ -513,11 +513,11 @@ bool QuickMenu_InputEvent(int bInputType, float nPrimary, float nSecondary)
        }
        else
        {
-               if(nPrimary == K_ALT) hudShiftState -= (hudShiftState & S_ALT);
-               if(nPrimary == K_CTRL) hudShiftState -= (hudShiftState & S_CTRL);
-               if(nPrimary == K_SHIFT) hudShiftState -= (hudShiftState & S_SHIFT);
-               if(nPrimary == K_MOUSE1) mouseClicked -= (mouseClicked & S_MOUSE1);
-               if(nPrimary == K_MOUSE2) mouseClicked -= (mouseClicked & S_MOUSE2);
+               if(nPrimary == K_ALT) hudShiftState &= ~S_ALT;
+               if(nPrimary == K_CTRL) hudShiftState &= ~S_CTRL;
+               if(nPrimary == K_SHIFT) hudShiftState &= ~S_SHIFT;
+               if(nPrimary == K_MOUSE1) mouseClicked &= ~S_MOUSE1;
+               if(nPrimary == K_MOUSE2) mouseClicked &= ~S_MOUSE2;
        }
 
        if(nPrimary == K_ESCAPE && key_pressed)
index a5b17d75eec767e5004252d53dc5818b293d1f93..14cb1ae2d42b6e56285cbbc0cb5d573ea3ceb7cb 100644 (file)
@@ -79,14 +79,14 @@ float HUD_Radar_InputEvent(int bInputType, float nPrimary, float nSecondary)
                if(key_pressed)
                        mouseClicked |= S_MOUSE1;
                else
-                       mouseClicked -= (mouseClicked & S_MOUSE1);
+                       mouseClicked &= ~S_MOUSE1;
        }
        else if(nPrimary == K_MOUSE2)
        {
                if(key_pressed)
                        mouseClicked |= S_MOUSE2;
                else
-                       mouseClicked -= (mouseClicked & S_MOUSE2);
+                       mouseClicked &= ~S_MOUSE2;
        }
        else if (nPrimary == K_ESCAPE && key_pressed)
        {
index af56134c2affa170ff7a142f5cb8b9c17336ee1b..810473aaff951110a2a62a8ed8fe27c506144698 100644 (file)
@@ -281,10 +281,10 @@ float HUD_Scoreboard_InputEvent(float bInputType, float nPrimary, float nSeconda
                if(nPrimary == K_TAB) hudShiftState |= S_TAB;
        }
        else {
-               if(nPrimary == K_ALT) hudShiftState -= (hudShiftState & S_ALT);
-               if(nPrimary == K_CTRL) hudShiftState -= (hudShiftState & S_CTRL);
-               if(nPrimary == K_SHIFT) hudShiftState -= (hudShiftState & S_SHIFT);
-               if(nPrimary == K_TAB) hudShiftState -= (hudShiftState & S_TAB);
+               if(nPrimary == K_ALT) hudShiftState &= ~S_ALT;
+               if(nPrimary == K_CTRL) hudShiftState &= ~S_CTRL;
+               if(nPrimary == K_SHIFT) hudShiftState &= ~S_SHIFT;
+               if(nPrimary == K_TAB) hudShiftState &= ~S_TAB;
        }
 
        if(nPrimary == K_TAB)
index da198d93415747e7a267c6628b551e98bfe1c833..15ccac0dc1c202bd5371648631ef3e3b6d4401ef 100644 (file)
@@ -345,7 +345,7 @@ void HUD_StrafeHUD()
                }
                else // alternatively calculate wishdir by querying pressed keys
                {
-                       if((keys & KEY_FORWARD) || (keys & KEY_BACKWARD))
+                       if(keys & (KEY_FORWARD | KEY_BACKWARD))
                                wishangle = 45;
                        else
                                wishangle = 90;
index ff0753f34cad7bb311023fa45933947adec08066..0ce8c34b0500b8e283d30d33b1bc199c670cd4fd 100644 (file)
@@ -184,7 +184,7 @@ void HUD_Weapons()
                {
                        int j = 0;
                        FOREACH(Weapons, it != WEP_Null && it.impulse >= 0 && (it.impulse % 3 != 0) && j < 6, {
-                               if (!(it.spawnflags & WEP_FLAG_MUTATORBLOCKED) && !(it.spawnflags & WEP_FLAG_SPECIALATTACK))
+                               if (!(it.spawnflags & (WEP_FLAG_MUTATORBLOCKED | WEP_FLAG_SPECIALATTACK)))
                                {
                                        if (!panel_switchweapon || j < 4)
                                                panel_switchweapon = it;
index b72269a9e4b36c36c1b34ee4a49d36b82da47e66..d65ea3dd68614ead433e1ce6b71003b5ac017731 100644 (file)
@@ -80,7 +80,7 @@ void ItemDraw(entity this)
                ItemSetModel(this, wantsimple);
 
        // no bobbing applied to simple items, for consistency's sake (no visual difference between ammo and weapons)
-       bool animate = (autocvar_cl_items_animate & 1) && this.item_simple <= 0 && ((this.ItemStatus & ITS_ANIMATE1) || (this.ItemStatus & ITS_ANIMATE2));
+       bool animate = (autocvar_cl_items_animate & 1) && this.item_simple <= 0 && (this.ItemStatus & (ITS_ANIMATE1 | ITS_ANIMATE2));
 
        // rotation must be set before running physics
        if(!animate)
@@ -272,7 +272,7 @@ NET_HANDLE(ENT_CLIENT_ITEM, bool isnew)
                }
        }
 
-       if(sf & ISF_SIZE || sf & ISF_SIZE2) // always true when it's spawned (in CSQC's perspective)
+       if(sf & (ISF_SIZE | ISF_SIZE2)) // always true when it's spawned (in CSQC's perspective)
        {
                if(isnew)
                {
@@ -331,7 +331,7 @@ NET_HANDLE(ENT_CLIENT_ITEM, bool isnew)
                SET_ONGROUND(this); // extra overkill
        }
 
-       if(sf & ISF_REMOVEFX && !(sf & ISF_SIZE) && !(sf & ISF_SIZE2)) // TODO !isnew isn't reliable for this... are we double sending initialisations?
+       if(sf & ISF_REMOVEFX && !(sf & (ISF_SIZE | ISF_SIZE2))) // TODO !isnew isn't reliable for this... are we double sending initialisations?
        {
                // no longer available to pick up, about to be removed
                if (this.drawmask) // this.alpha > 0
index b426840edb393a73517d82e13a72f849059aa721..93ca902d8394d3b3e24f0e8d718a9e1864f867d4 100644 (file)
@@ -517,10 +517,10 @@ float CSQC_InputEvent(int bInputType, float nPrimary, float nSecondary)
                if(nPrimary == K_TAB) hudShiftState |= S_TAB;
        }
        else {
-               if(nPrimary == K_ALT) hudShiftState -= (hudShiftState & S_ALT);
-               if(nPrimary == K_CTRL) hudShiftState -= (hudShiftState & S_CTRL);
-               if(nPrimary == K_SHIFT) hudShiftState -= (hudShiftState & S_SHIFT);
-               if(nPrimary == K_TAB) hudShiftState -= (hudShiftState & S_TAB);
+               if(nPrimary == K_ALT) hudShiftState &= ~S_ALT;
+               if(nPrimary == K_CTRL) hudShiftState &= ~S_CTRL;
+               if(nPrimary == K_SHIFT) hudShiftState &= ~S_SHIFT;
+               if(nPrimary == K_TAB) hudShiftState &= ~S_TAB;
        }
 
        // NOTE: Shift-Escape must be filtered out because it's the hardcoded console shortcut
@@ -601,7 +601,7 @@ NET_HANDLE(ENT_CLIENT_SCORES, bool isnew)
        int sf = ReadShort();
        int lf = ReadShort();
        FOREACH(Scores, true, {
-               int p = 1 << (i % 16);
+               int p = BIT(i % 16);
                if (sf & p)
                {
                        if (lf & p)
index 7c3d803527d1e41ccc1a2630a8a94249beaff8c2..7be652385300d8027167f6d2165263e0e31531f7 100644 (file)
@@ -868,9 +868,9 @@ float MapVote_InputEvent(int bInputType, float nPrimary, float nSecondary)
        }
        else
        {
-               if (nPrimary == K_ALT) hudShiftState -= (hudShiftState & S_ALT);
-               if (nPrimary == K_CTRL) hudShiftState -= (hudShiftState & S_CTRL);
-               if (nPrimary == K_SHIFT) hudShiftState -= (hudShiftState & S_SHIFT);
+               if (nPrimary == K_ALT) hudShiftState &= ~S_ALT;
+               if (nPrimary == K_CTRL) hudShiftState &= ~S_CTRL;
+               if (nPrimary == K_SHIFT) hudShiftState &= ~S_SHIFT;
 
                if (nPrimary == K_CTRL)
                        first_digit = 0;
index a28b7140929dfb9e28df5902ea6ca80c151eaac8..ceb6cf8295ad3ff4c855757160d785569de74ef2 100644 (file)
@@ -129,8 +129,8 @@ Monster invasion_PickMonster(int supermonster_count)
 
        FOREACH(Monsters, it != MON_Null,
        {
-               if((it.spawnflags & MON_FLAG_HIDDEN) || (it.spawnflags & MONSTER_TYPE_PASSIVE) || (it.spawnflags & MONSTER_TYPE_FLY) || (it.spawnflags & MONSTER_TYPE_SWIM)
-                       || (it.spawnflags & MONSTER_SIZE_QUAKE) || ((it.spawnflags & MON_FLAG_SUPERMONSTER) && supermonster_count >= 1))
+               if((it.spawnflags & (MON_FLAG_HIDDEN | MONSTER_TYPE_PASSIVE | MONSTER_TYPE_FLY | MONSTER_TYPE_SWIM | MONSTER_SIZE_QUAKE))
+               || ((it.spawnflags & MON_FLAG_SUPERMONSTER) && supermonster_count >= 1))
                        continue;
                if(autocvar_g_invasion_zombies_only && !(it.spawnflags & MONSTER_TYPE_UNDEAD))
                        continue;
index 174bec63a91a309633b80a84f759707b5bf77ec1..d427af4c26a682d05894f179ec2b0bc4c5aeaa74 100644 (file)
@@ -636,11 +636,11 @@ float HUD_Minigame_InputEvent(float bInputType, float nPrimary, float nSecondary
                if(nPrimary == K_MOUSE2) mouseClicked |= S_MOUSE2;
        }
        else {
-               if(nPrimary == K_ALT) hudShiftState -= (hudShiftState & S_ALT);
-               if(nPrimary == K_CTRL) hudShiftState -= (hudShiftState & S_CTRL);
-               if(nPrimary == K_SHIFT) hudShiftState -= (hudShiftState & S_SHIFT);
-               if(nPrimary == K_MOUSE1) mouseClicked -= (mouseClicked & S_MOUSE1);
-               if(nPrimary == K_MOUSE2) mouseClicked -= (mouseClicked & S_MOUSE2);
+               if(nPrimary == K_ALT) hudShiftState &= ~S_ALT;
+               if(nPrimary == K_CTRL) hudShiftState &= ~S_CTRL;
+               if(nPrimary == K_SHIFT) hudShiftState &= ~S_SHIFT;
+               if(nPrimary == K_MOUSE1) mouseClicked &= ~S_MOUSE1;
+               if(nPrimary == K_MOUSE2) mouseClicked &= ~S_MOUSE2;
        }
 
        // allow some binds
index 2150af5e896ee9b95fbca6f2f08e416d0146d804..86f4ab09871ceee90a8fa745d49aefc79f9fb938 100644 (file)
@@ -1101,7 +1101,7 @@ void bd_hud_board(vector pos, vector mySize)
                }
        }
 
-       if ( (active_minigame.minigame_flags & BD_TURN_LOSS) || (active_minigame.minigame_flags & BD_TURN_WIN) )
+       if(active_minigame.minigame_flags & (BD_TURN_LOSS | BD_TURN_WIN))
        {
                vector winfs = hud_fontsize*2;
                string victory_text = _("Game over!");
@@ -1277,7 +1277,7 @@ int bd_client_event(entity minigame, string event, ...)
                {
                        bool event_blocked = ((event == "key_released")
                                || !(minigame.minigame_flags & BD_TURN_MOVE) || (minigame_self.team == BD_SPECTATOR_TEAM));
-                       if (!(minigame.minigame_flags & BD_TURN_WIN) && !(minigame.minigame_flags & BD_TURN_LOSS))
+                       if (!(minigame.minigame_flags & (BD_TURN_WIN | BD_TURN_LOSS)))
                        {
                                switch ( ...(0,int) )
                                {
index bcf0d01dadbe6607d81f024f5782a98201866712..1833b8490448b493f46fb25ff7868781b3242e58 100644 (file)
@@ -439,7 +439,7 @@ int c4_client_event(entity minigame, string event, ...)
                {
                        bool event_blocked = ((event == "key_released")
                                || ((minigame.minigame_flags & C4_TURN_TEAM) != minigame_self.team));
-                       if (!(minigame.minigame_flags & C4_TURN_WIN) && !(minigame.minigame_flags & C4_TURN_DRAW))
+                       if (!(minigame.minigame_flags & (C4_TURN_WIN | C4_TURN_DRAW)))
                        {
                                switch ( ...(0,int) )
                                {
index 0811ba28e04bcf97bbb946d10db135dff15e9131..4107196af69a780cb12003bd2f54f946d72c474b 100644 (file)
@@ -513,7 +513,7 @@ int pp_client_event(entity minigame, string event, ...)
                {
                        bool event_blocked = ((event == "key_released")
                                || ((minigame.minigame_flags & PP_TURN_TEAM) != minigame_self.team));
-                       if (!(minigame.minigame_flags & PP_TURN_WIN) && !(minigame.minigame_flags & PP_TURN_DRAW))
+                       if (!(minigame.minigame_flags & (PP_TURN_WIN | PP_TURN_DRAW)))
                        {
                                switch ( ...(0,int) )
                                {
index 058b935ec6c32ce4cf8e0fbf5c4fd5d4499ca21b..3985aa7312b530efdc4b9c4364243479f031995f 100644 (file)
@@ -405,7 +405,7 @@ void ps_hud_board(vector pos, vector mySize)
                                tile_size * 0.8, '0.5 0.5 0.5', panel_fg_alpha, DRAWFLAG_NORMAL);
        }
 
-       if ( ( active_minigame.minigame_flags & PS_TURN_WIN ) || ( active_minigame.minigame_flags & PS_TURN_DRAW ) )
+       if(active_minigame.minigame_flags & (PS_TURN_WIN | PS_TURN_DRAW))
        {
                int remaining = 0;
                FOREACH_MINIGAME_ENTITY(e)
@@ -556,7 +556,7 @@ int ps_client_event(entity minigame, string event, ...)
                case "key_released":
                {
                        bool event_blocked = (event == "key_released" || minigame_self.team == PS_SPECTATOR_TEAM);
-                       if (!(minigame.minigame_flags & PS_TURN_WIN) && !(minigame.minigame_flags & PS_TURN_DRAW))
+                       if (!(minigame.minigame_flags & (PS_TURN_WIN | PS_TURN_DRAW)))
                        {
                                switch ( ...(0,int) )
                                {
index d67aa15ea772f16e3dc35522280488ab2a3f243f..c5e3d2ab41d1e72445e3b96e36375eac78e1270f 100644 (file)
@@ -584,7 +584,7 @@ int ttt_client_event(entity minigame, string event, ...)
                {
                        bool event_blocked = ((event == "key_released")
                                || ((minigame.minigame_flags & TTT_TURN_TEAM) != minigame_self.team));
-                       if (!(minigame.minigame_flags & TTT_TURN_WIN) && !(minigame.minigame_flags & TTT_TURN_DRAW))
+                       if (!(minigame.minigame_flags & (TTT_TURN_WIN | TTT_TURN_DRAW)))
                        {
                                switch ( ...(0,int) )
                                {
index b71e1054d6db5e7d49f94d13f58442635b1d1614..862bc6a9bb5e9a3ab6d2a4306b607037d8bdc059 100644 (file)
@@ -691,7 +691,7 @@ int Monster_CheckDanger(entity this, vector dst_ahead)
 {
        float s;
 
-       if((this.flags & FL_FLY) || (this.flags & FL_SWIM))
+       if(this.flags & (FL_FLY | FL_SWIM))
        {
                // Look ahead
                traceline(this.origin + this.view_ofs, dst_ahead, true, NULL);
@@ -1029,11 +1029,11 @@ void Monster_Dead(entity this, entity attacker, float gibbed)
 
        Monster_Sound(this, monstersound_death, 0, false, CH_VOICE);
 
-       if(!(this.spawnflags & MONSTERFLAG_SPAWNED) && !(this.spawnflags & MONSTERFLAG_RESPAWNED))
+       if(!(this.spawnflags & (MONSTERFLAG_SPAWNED | MONSTERFLAG_RESPAWNED)))
                monsters_killed += 1;
 
        if(IS_PLAYER(attacker))
-       if(autocvar_g_monsters_score_spawned || !((this.spawnflags & MONSTERFLAG_SPAWNED) || (this.spawnflags & MONSTERFLAG_RESPAWNED)))
+       if(autocvar_g_monsters_score_spawned || !(this.spawnflags & (MONSTERFLAG_SPAWNED | MONSTERFLAG_RESPAWNED)))
                GameRules_scoring_add(attacker, SCORE, +autocvar_g_monsters_score_kill);
 
        if(gibbed)
@@ -1506,7 +1506,7 @@ bool Monster_Spawn(entity this, bool check_appear, Monster mon)
        this.monster_face               = '0 0 0';
        this.dphitcontentsmask  = DPCONTENTS_SOLID | DPCONTENTS_BODY | DPCONTENTS_BOTCLIP | DPCONTENTS_MONSTERCLIP;
 
-       if(!this.noalign) { this.noalign = ((mon.spawnflags & MONSTER_TYPE_FLY) || (mon.spawnflags & MONSTER_TYPE_SWIM)); }
+       if(!this.noalign) { this.noalign = (mon.spawnflags & (MONSTER_TYPE_FLY | MONSTER_TYPE_SWIM)); }
        if(!this.scale) { this.scale = 1; }
        if(autocvar_g_monsters_edit) { this.grab = 1; }
        if(autocvar_g_fullbrightplayers) { this.effects |= EF_FULLBRIGHT; }
index 838ac668ee7c88ad0f23a627f2207483eb3bc7fe..decef9d40234206c74541709b72e2ea2f0f03cd5 100644 (file)
@@ -58,7 +58,7 @@ float autocvar_g_buffs_luck_chance = 0.15;
 float autocvar_g_buffs_luck_damagemultiplier = 3;
 
 // ammo
-.float buff_ammo_prev_infitems;
+.int buff_ammo_prev_infitems;
 .int buff_ammo_prev_clipload;
 // flight
 .float buff_flight_oldgravity;
index 46a783ce550220840597ca6db5697ddcb117ee01..734c1d25b5036c4ad0b6435231e80602a9cb10a4 100644 (file)
@@ -204,7 +204,7 @@ METHOD(OverkillRocketPropelledChainsaw, wr_reload, void(entity thiswep, entity a
 
 METHOD(OverkillRocketPropelledChainsaw, wr_suicidemessage, Notification(entity thiswep))
 {
-       if((w_deathtype & HITTYPE_BOUNCE) || (w_deathtype & HITTYPE_SPLASH))
+       if(w_deathtype & (HITTYPE_BOUNCE | HITTYPE_SPLASH))
                return WEAPON_OVERKILL_RPC_SUICIDE_SPLASH;
        else
                return WEAPON_OVERKILL_RPC_SUICIDE_DIRECT;
@@ -212,7 +212,7 @@ METHOD(OverkillRocketPropelledChainsaw, wr_suicidemessage, Notification(entity t
 
 METHOD(OverkillRocketPropelledChainsaw, wr_killmessage, Notification(entity thiswep))
 {
-       if((w_deathtype & HITTYPE_BOUNCE) || (w_deathtype & HITTYPE_SPLASH))
+       if(w_deathtype & (HITTYPE_BOUNCE | HITTYPE_SPLASH))
                return WEAPON_OVERKILL_RPC_MURDER_SPLASH;
        else
                return WEAPON_OVERKILL_RPC_MURDER_DIRECT;
index 71bb9c8fcc9d7974f8b4ce3ebd6a9b6aa764550a..fe57eaa44c08662366441d313d2be82cd799f75f 100644 (file)
@@ -6,22 +6,22 @@ REGISTER_MUTATOR(superspec, expr_evaluate(autocvar_g_superspectate));
 #define _SSMAGIX "SUPERSPEC_OPTIONSFILE_V1"
 #define _ISLOCAL(ent) ((edict_num(1) == (ent)) ? true : false)
 
-const float ASF_STRENGTH               = BIT(0);
-const float ASF_SHIELD                         = BIT(1);
-const float ASF_MEGA_AR                = BIT(2);
-const float ASF_MEGA_HP                = BIT(3);
-const float ASF_FLAG_GRAB              = BIT(4);
-const float ASF_OBSERVER_ONLY  = BIT(5);
-const float ASF_SHOWWHAT               = BIT(6);
-const float ASF_SSIM                   = BIT(7);
-const float ASF_FOLLOWKILLER   = BIT(8);
-const float ASF_ALL                    = 0xFFFFFF;
-.float autospec_flags;
-
-const float SSF_SILENT = 1;
-const float SSF_VERBOSE = 2;
-const float SSF_ITEMMSG = 4;
-.float superspec_flags;
+const int ASF_STRENGTH      = BIT(0);
+const int ASF_SHIELD        = BIT(1);
+const int ASF_MEGA_AR       = BIT(2);
+const int ASF_MEGA_HP       = BIT(3);
+const int ASF_FLAG_GRAB     = BIT(4);
+const int ASF_OBSERVER_ONLY = BIT(5);
+const int ASF_SHOWWHAT      = BIT(6);
+const int ASF_SSIM          = BIT(7);
+const int ASF_FOLLOWKILLER  = BIT(8);
+const int ASF_ALL           = 0xFFFFFF;
+.int autospec_flags;
+
+const int SSF_SILENT  = BIT(0);
+const int SSF_VERBOSE = BIT(1);
+const int SSF_ITEMMSG = BIT(2);
+.int superspec_flags;
 
 .string superspec_itemfilter; //"classname1 classname2 ..."
 
@@ -55,9 +55,9 @@ void superspec_save_client_conf(entity this)
        {
                fputs(fh, _SSMAGIX);
                fputs(fh, "\n");
-               fputs(fh, ftos(this.autospec_flags));
+               fputs(fh, itos(this.autospec_flags));
                fputs(fh, "\n");
-               fputs(fh, ftos(this.superspec_flags));
+               fputs(fh, itos(this.superspec_flags));
                fputs(fh, "\n");
                fputs(fh, this.superspec_itemfilter);
                fputs(fh, "\n");
@@ -429,8 +429,8 @@ MUTATOR_HOOKFUNCTION(superspec, ClientConnect)
                }
                else
                {
-                       player.autospec_flags = stof(fgets(fh));
-                       player.superspec_flags = stof(fgets(fh));
+                       player.autospec_flags = stoi(fgets(fh));
+                       player.superspec_flags = stoi(fgets(fh));
                        player.superspec_itemfilter = strzone(fgets(fh));
                }
                fclose(fh);
index ea827f4fedb168523b15691f60ece620d66a77ab..976bef7c1237a345ae7f9215e166d98b68897653 100644 (file)
@@ -53,7 +53,7 @@ bool autocvar_g_footsteps;
 
 .float gravity;
 .float swamp_slowdown;
-.float lastflags;
+.int lastflags;
 .float lastground;
 .bool wasFlying;
 
index c97860003ae3c584e3c876b209a87030cb02a67c..489a1f43f17dcde7b4e6af5e360af5a452f37559 100644 (file)
@@ -535,7 +535,7 @@ void Arc_Smoke(Weapon thiswep, entity actor, .entity weaponentity, int fire)
        {
                if ( random() < actor.(weaponentity).arc_heat_percent )
                        Send_Effect(EFFECT_ARC_SMOKE, smoke_origin, '0 0 0', 1 );
-               if ( (fire & 1) || (fire & 2) )
+               if ( fire & (1 | 2) )
                {
                        Send_Effect(EFFECT_ARC_OVERHEAT_FIRE, smoke_origin, w_shotdir, 1 );
                        if ( !actor.arc_smoke_sound )
index 28608a2212498b507b1458d002d5d2e4af34a61a..53e4818514a5ba6414e64e6d629a5c84716b44ee 100644 (file)
@@ -347,7 +347,7 @@ METHOD(Tuba, wr_think, void(Tuba this, entity actor, .entity weaponentity, int f
        }
        if (actor.(weaponentity).tuba_note)
        {
-               if (!(fire & 1) && !(fire & 2))
+               if (!(fire & (1 | 2)))
                {
                        W_Tuba_NoteOff(actor.(weaponentity).tuba_note);
                }
index 0abc358352b38958c78613ac5b56259b01f7c41b..452c99fb496c9930c5d18b76a97299443c0f760f 100644 (file)
@@ -1,5 +1,6 @@
 #pragma once
 
+#include "bits.qh"
 #include "iter.qh"
 #include "test.qh"
 
@@ -229,9 +230,9 @@ void IL_INIT(IntrusiveList this)
                        prevfld = il_links_flds[flds_idx + 1];
                        this.il_id = id;
                        int bit = IL_FLOOR(id / IL_LISTS_PER_BIT);
-                       if (bit < (1 * 24)) this.il_listmask = '1 0 0' * (1 << (bit - (0 * 24)));
-                       else if (bit < (2 * 24)) this.il_listmask = '0 1 0' * (1 << (bit - (1 * 24)));
-                       else if (bit < (3 * 24)) this.il_listmask = '0 0 1' * (1 << (bit - (2 * 24)));
+                       if (bit < (1 * 24)) this.il_listmask = '1 0 0' * BIT(bit - (0 * 24));
+                       else if (bit < (2 * 24)) this.il_listmask = '0 1 0' * BIT(bit - (1 * 24));
+                       else if (bit < (3 * 24)) this.il_listmask = '0 0 1' * BIT(bit - (2 * 24));
                        else assert(false);
                        il_links_ptr = id + 1;
                        if (il_links_ptr >= IL_MAX) il_links_ptr -= IL_MAX;
index f80b5a63873325d50fd67799ad8cb50634df92ea..07dc265db716549fb295d724871975ed23edcbf5 100644 (file)
@@ -89,22 +89,22 @@ void WarpZone_RefSys_Copy(entity me, entity from); // to.R := from.R
 entity WarpZone_RefSys_SpawnSameRefSys(entity me); // spawn().R = me.R
 
 #ifndef BITCLR
-# define BITCLR(a,b) ((a) - ((a) & (b)))
+# define BITCLR(a,b) ((a) & ~(b))
 #endif
 #ifndef BITSET
 # define BITSET(a,b) ((a) | (b))
 #endif
 #ifndef BITXOR
-# define BITXOR(a,b) (((a) | (b)) - ((a) & (b)))
+# define BITXOR(a,b) (((a) ^ (b))
 #endif
 #ifndef BITCLR_ASSIGN
-# define BITCLR_ASSIGN(a,b) ((a) = (a) - ((a) & (b)))
+# define BITCLR_ASSIGN(a,b) ((a) &= ~(b))
 #endif
 #ifndef BITSET_ASSIGN
 # define BITSET_ASSIGN(a,b) ((a) |= (b))
 #endif
 #ifndef BITXOR_ASSIGN
-# define BITXOR_ASSIGN(a,b) ((a) = ((a) | (b)) - ((a) & (b)))
+# define BITXOR_ASSIGN(a,b) ((a) ^= (b))
 #endif
 int WarpZoneLib_MoveOutOfSolid(entity e);
 #define move_out_of_solid(e) WarpZoneLib_MoveOutOfSolid(e)
index 0445fef01ab48e12a521110c48238b0aa77efdff..d597272b7f1d707798aacaab30a1be6018f51ae2 100644 (file)
@@ -406,7 +406,7 @@ int havocbot_checkdanger(entity this, vector dst_ahead)
        if (trace_fraction == 1 && !this.jumppadcount
                && !waypoint_is_hardwiredlink(this.goalcurrent_prev, this.goalcurrent)
                && !(this.goalcurrent_prev && (this.goalcurrent_prev.wpflags & WAYPOINTFLAG_JUMP)))
-       if ((IS_ONGROUND(this)) || (this.aistatus & AI_STATUS_RUNNING) || (this.aistatus & AI_STATUS_ROAMING) || PHYS_INPUT_BUTTON_JUMP(this))
+       if ((IS_ONGROUND(this)) || (this.aistatus & (AI_STATUS_RUNNING | AI_STATUS_ROAMING)) || PHYS_INPUT_BUTTON_JUMP(this))
        {
                // Look downwards
                traceline(dst_ahead , dst_down, true, NULL);
index 8d0db75dac1d04da1fa33703ecdf0a4ce30aa520..5c8c85380c3df18ee83b68624a55cfe207aa3f79 100644 (file)
@@ -1564,7 +1564,7 @@ void player_powerups(entity this)
                        if (!(STAT(WEAPONS, this) & WEPSET_SUPERWEAPONS))
                        {
                                StatusEffects_remove(STATUSEFFECT_Superweapons, this, STATUSEFFECT_REMOVE_NORMAL);
-                               this.items = this.items - (this.items & IT_SUPERWEAPON);
+                               this.items &= ~IT_SUPERWEAPON;
                                //Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_SUPERWEAPON_LOST, this.netname);
                                Send_Notification(NOTIF_ONE, this, MSG_CENTER, CENTER_SUPERWEAPON_LOST);
                        }
@@ -1577,7 +1577,7 @@ void player_powerups(entity this)
                                play_countdown(this, StatusEffects_gettime(STATUSEFFECT_Superweapons, this), SND_POWEROFF);
                                if (time >= StatusEffects_gettime(STATUSEFFECT_Superweapons, this))
                                {
-                                       this.items = this.items - (this.items & IT_SUPERWEAPON);
+                                       this.items &= ~IT_SUPERWEAPON;
                                        STAT(WEAPONS, this) &= ~WEPSET_SUPERWEAPONS;
                                        //Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_SUPERWEAPON_BROKEN, this.netname);
                                        Send_Notification(NOTIF_ONE, this, MSG_CENTER, CENTER_SUPERWEAPON_BROKEN);
@@ -1588,7 +1588,7 @@ void player_powerups(entity this)
                {
                        if (time < StatusEffects_gettime(STATUSEFFECT_Superweapons, this) || (this.items & IT_UNLIMITED_SUPERWEAPONS))
                        {
-                               this.items = this.items | IT_SUPERWEAPON;
+                               this.items |= IT_SUPERWEAPON;
                                if(!(this.items & IT_UNLIMITED_SUPERWEAPONS))
                                {
                                        if(!g_cts)
@@ -1610,10 +1610,10 @@ void player_powerups(entity this)
        }
 
        if(autocvar_g_nodepthtestplayers)
-               this.effects = this.effects | EF_NODEPTHTEST;
+               this.effects |= EF_NODEPTHTEST;
 
        if(autocvar_g_fullbrightplayers)
-               this.effects = this.effects | EF_FULLBRIGHT;
+               this.effects |= EF_FULLBRIGHT;
 
        MUTATOR_CALLHOOK(PlayerPowerups, this, items_prev);
 }
index 63ee5fda1bf6e712adf55bbbeb7e91a5c93e6ee1..9e00293d399a6f3cccf12636e1538c01081ddea5 100644 (file)
@@ -919,7 +919,7 @@ float RadiusDamageForSource (entity inflictor, vector inflictororigin, vector in
 
        total_damage_to_creatures = 0;
 
-       if(!(deathtype & HITTYPE_SOUND) && !(deathtype & HITTYPE_SPAM)) // do not send bandwidth-hogging radial spam attacks
+       if(!(deathtype & (HITTYPE_SOUND | HITTYPE_SPAM))) // do not send bandwidth-hogging radial spam attacks
        {
                force = inflictorvelocity;
                if(force == '0 0 0')
index 545a01cedef37a7b2d636bc28ce20d0d5e53582b..34d1cd04e06d63e7b01de1df0401f165c17aefae 100644 (file)
@@ -29,7 +29,7 @@ const float HOOK_REMOVING = BIT(1);
 const float HOOK_PULLING = BIT(2);
 const float HOOK_RELEASING = BIT(3);
 const float HOOK_WAITING_FOR_RELEASE = BIT(4);
-.float hook_state;
+.int hook_state;
 .int state;
 
 vector hook_shotorigin[4];
index 6adc4f9b439d88c2fbd97d20adad62d6157db77f..83022b2bd4446052cd9c64ec25bcbc06ebd0b04a 100644 (file)
@@ -71,7 +71,7 @@ bool ItemSend(entity this, entity to, int sf)
        if(sf & ISF_STATUS)
                WriteByte(MSG_ENTITY, this.ItemStatus);
 
-       if(sf & ISF_SIZE || sf & ISF_SIZE2) // always true when it's spawned (in CSQC's perspective)
+       if(sf & (ISF_SIZE | ISF_SIZE2)) // always true when it's spawned (in CSQC's perspective)
        {
                WriteShort(MSG_ENTITY, bound(0, this.fade_end, 32767));
 
@@ -591,7 +591,7 @@ bool Item_GiveTo(entity item, entity player)
                        Send_Notification(NOTIF_ONE, player, MSG_CENTER, CENTER_ITEM_JETPACK_GOT);
        }
 
-       int its = (item.items - (item.items & player.items)) & IT_PICKUPMASK;
+       int its = item.items & ~(player.items) & IT_PICKUPMASK;
        if (its)
        {
                pickedup = true;
index 405d179ca8fce7cfd81b3c51f11447e903916cd6..8f24e15ec844a1abcef11a16c66530a527dc3673 100644 (file)
@@ -331,7 +331,7 @@ void Portal_Touch(entity this, entity toucher)
        if(Portal_TeleportPlayer(this, toucher, this.aiment))
                if(toucher.classname == "porto")
                        if(toucher.effects & EF_RED)
-                               toucher.effects += EF_BLUE - EF_RED;
+                               toucher.effects = (toucher.effects & ~EF_RED) | EF_BLUE;
 }
 
 void Portal_MakeBrokenPortal(entity portal)
index 40bbec64424689f94e11551dbbc6e3c4b284c969..5fecde38c739237edb04ca3b5d0af09515ad58c1 100644 (file)
@@ -263,7 +263,7 @@ bool PlayerScore_SendEntity(entity this, entity to, float sendflags)
 
        int longflags = 0;
        FOREACH(Scores, true, {
-           int p = 1 << (i % 16);
+           int p = BIT(i % 16);
                if (this.(scores(it)) > 127 || this.(scores(it)) <= -128)
                        longflags |= p;
     });
@@ -271,7 +271,7 @@ bool PlayerScore_SendEntity(entity this, entity to, float sendflags)
        WriteShort(MSG_ENTITY, sendflags);
        WriteShort(MSG_ENTITY, longflags);
        FOREACH(Scores, true, {
-           int p = 1 << (i % 16);
+           int p = BIT(i % 16);
                if (sendflags & p)
                {
                        if(longflags & p)
index a09719f25416fad9b62461f913660bf626112ff2..7916a76e023bd55e908362533596d2b69b33bddf 100644 (file)
@@ -104,7 +104,7 @@ void accuracy_add(entity this, Weapon w, float fired, float hit)
     }
 
        if (b == accuracy_byte(a.accuracy_hit[wepid], a.accuracy_fired[wepid])) return; // no change
-       int sf = 1 << (wepid % 24);
+       int sf = BIT(wepid % 24);
        a.SendFlags |= sf;
        FOREACH_CLIENT(IS_SPEC(it) && it.enemy == this, { CS(it).accuracy.SendFlags |= sf; });
 }
index 1af0881c3400b7df6758b7e275405769a5c1669e..c32f67c96b4d389a251c08cfa33802a8f4de3e0c 100644 (file)
@@ -164,7 +164,7 @@ float W_GetCycleWeapon(entity this, string weaponorder, float dir, float imp, fl
                FOREACH(Weapons, it != WEP_Null, {
                        if(i != weaponwant)
                        if(it.impulse == imp || imp < 0)
-                       if((STAT(WEAPONS, this) & (it.m_wepset)) || (weaponsInMap & (it.m_wepset)))
+                       if((STAT(WEAPONS, this) | weaponsInMap) & it.m_wepset)
                                have_other = true;
                });
 
@@ -220,7 +220,7 @@ float W_GetCycleWeapon(entity this, string weaponorder, float dir, float imp, fl
                        FOREACH(Weapons, it != WEP_Null, {
                                if(i != weaponwant)
                                if(it.impulse == imp || imp < 0)
-                               if((STAT(WEAPONS, this) & (it.m_wepset)) || (weaponsInMap & (it.m_wepset)))
+                               if((STAT(WEAPONS, this) | weaponsInMap) & it.m_wepset)
                                        have_other = true;
                        });
 
index 782ee3aa39cc5f7c5e83cce6e0ca6bd05a48db95..38d0f97a35c99235fd4e89827bc493a995e942ef 100644 (file)
@@ -48,7 +48,7 @@ float W_ThrowNewWeapon(entity own, float wpn, float doreduce, vector org, vector
                        int superweapons = 1;
                        FOREACH(Weapons, it != WEP_Null, {
                                WepSet set = it.m_wepset;
-                               if((set & WEPSET_SUPERWEAPONS) && (STAT(WEAPONS, own) & set)) ++superweapons;
+                               if((WEPSET_SUPERWEAPONS & STAT(WEAPONS, own)) & set) ++superweapons;
                        });
                        if(superweapons <= 1)
                        {