From d8b1a76b463c72036d72fc29cac50595823aeb2f Mon Sep 17 00:00:00 2001 From: k9er Date: Thu, 2 Jan 2025 00:25:24 +0000 Subject: [PATCH] Optimize bitset operations --- qcsrc/client/hud/hud_config.qc | 10 ++--- qcsrc/client/hud/panel/quickmenu.qc | 10 ++--- qcsrc/client/hud/panel/radar.qc | 4 +- qcsrc/client/hud/panel/scoreboard.qc | 8 ++-- qcsrc/client/hud/panel/strafehud.qc | 2 +- qcsrc/client/hud/panel/weapons.qc | 2 +- qcsrc/client/items/items.qc | 6 +-- qcsrc/client/main.qc | 10 ++--- qcsrc/client/mapvoting.qc | 6 +-- .../gamemode/invasion/sv_invasion.qc | 4 +- qcsrc/common/minigames/cl_minigames_hud.qc | 10 ++--- qcsrc/common/minigames/minigame/bd.qc | 4 +- qcsrc/common/minigames/minigame/c4.qc | 2 +- qcsrc/common/minigames/minigame/pp.qc | 2 +- qcsrc/common/minigames/minigame/ps.qc | 4 +- qcsrc/common/minigames/minigame/ttt.qc | 2 +- qcsrc/common/monsters/sv_monsters.qc | 8 ++-- .../common/mutators/mutator/buffs/sv_buffs.qh | 2 +- .../common/mutators/mutator/overkill/okrpc.qc | 4 +- .../mutator/superspec/sv_superspec.qc | 40 +++++++++---------- qcsrc/common/physics/player.qh | 2 +- qcsrc/common/weapons/weapon/arc.qc | 2 +- qcsrc/common/weapons/weapon/tuba.qc | 2 +- qcsrc/lib/intrusivelist.qh | 7 ++-- qcsrc/lib/warpzone/common.qh | 8 ++-- qcsrc/server/bot/default/havocbot/havocbot.qc | 2 +- qcsrc/server/client.qc | 10 ++--- qcsrc/server/damage.qc | 2 +- qcsrc/server/hook.qh | 2 +- qcsrc/server/items/items.qc | 4 +- qcsrc/server/portals.qc | 2 +- qcsrc/server/scores.qc | 4 +- qcsrc/server/weapons/accuracy.qc | 2 +- qcsrc/server/weapons/selection.qc | 4 +- qcsrc/server/weapons/throwing.qc | 2 +- 35 files changed, 98 insertions(+), 97 deletions(-) diff --git a/qcsrc/client/hud/hud_config.qc b/qcsrc/client/hud/hud_config.qc index 726b2e78d..2bb17dbbe 100644 --- a/qcsrc/client/hud/hud_config.qc +++ b/qcsrc/client/hud/hud_config.qc @@ -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) diff --git a/qcsrc/client/hud/panel/quickmenu.qc b/qcsrc/client/hud/panel/quickmenu.qc index 710245445..21fa2253d 100644 --- a/qcsrc/client/hud/panel/quickmenu.qc +++ b/qcsrc/client/hud/panel/quickmenu.qc @@ -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) diff --git a/qcsrc/client/hud/panel/radar.qc b/qcsrc/client/hud/panel/radar.qc index a5b17d75e..14cb1ae2d 100644 --- a/qcsrc/client/hud/panel/radar.qc +++ b/qcsrc/client/hud/panel/radar.qc @@ -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) { diff --git a/qcsrc/client/hud/panel/scoreboard.qc b/qcsrc/client/hud/panel/scoreboard.qc index af56134c2..810473aaf 100644 --- a/qcsrc/client/hud/panel/scoreboard.qc +++ b/qcsrc/client/hud/panel/scoreboard.qc @@ -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) diff --git a/qcsrc/client/hud/panel/strafehud.qc b/qcsrc/client/hud/panel/strafehud.qc index da198d934..15ccac0dc 100644 --- a/qcsrc/client/hud/panel/strafehud.qc +++ b/qcsrc/client/hud/panel/strafehud.qc @@ -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; diff --git a/qcsrc/client/hud/panel/weapons.qc b/qcsrc/client/hud/panel/weapons.qc index ff0753f34..0ce8c34b0 100644 --- a/qcsrc/client/hud/panel/weapons.qc +++ b/qcsrc/client/hud/panel/weapons.qc @@ -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; diff --git a/qcsrc/client/items/items.qc b/qcsrc/client/items/items.qc index b72269a9e..d65ea3dd6 100644 --- a/qcsrc/client/items/items.qc +++ b/qcsrc/client/items/items.qc @@ -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 diff --git a/qcsrc/client/main.qc b/qcsrc/client/main.qc index b426840ed..93ca902d8 100644 --- a/qcsrc/client/main.qc +++ b/qcsrc/client/main.qc @@ -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) diff --git a/qcsrc/client/mapvoting.qc b/qcsrc/client/mapvoting.qc index 7c3d80352..7be652385 100644 --- a/qcsrc/client/mapvoting.qc +++ b/qcsrc/client/mapvoting.qc @@ -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; diff --git a/qcsrc/common/gamemodes/gamemode/invasion/sv_invasion.qc b/qcsrc/common/gamemodes/gamemode/invasion/sv_invasion.qc index a28b71409..ceb6cf829 100644 --- a/qcsrc/common/gamemodes/gamemode/invasion/sv_invasion.qc +++ b/qcsrc/common/gamemodes/gamemode/invasion/sv_invasion.qc @@ -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; diff --git a/qcsrc/common/minigames/cl_minigames_hud.qc b/qcsrc/common/minigames/cl_minigames_hud.qc index 174bec63a..d427af4c2 100644 --- a/qcsrc/common/minigames/cl_minigames_hud.qc +++ b/qcsrc/common/minigames/cl_minigames_hud.qc @@ -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 diff --git a/qcsrc/common/minigames/minigame/bd.qc b/qcsrc/common/minigames/minigame/bd.qc index 2150af5e8..86f4ab098 100644 --- a/qcsrc/common/minigames/minigame/bd.qc +++ b/qcsrc/common/minigames/minigame/bd.qc @@ -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) ) { diff --git a/qcsrc/common/minigames/minigame/c4.qc b/qcsrc/common/minigames/minigame/c4.qc index bcf0d01da..1833b8490 100644 --- a/qcsrc/common/minigames/minigame/c4.qc +++ b/qcsrc/common/minigames/minigame/c4.qc @@ -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) ) { diff --git a/qcsrc/common/minigames/minigame/pp.qc b/qcsrc/common/minigames/minigame/pp.qc index 0811ba28e..4107196af 100644 --- a/qcsrc/common/minigames/minigame/pp.qc +++ b/qcsrc/common/minigames/minigame/pp.qc @@ -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) ) { diff --git a/qcsrc/common/minigames/minigame/ps.qc b/qcsrc/common/minigames/minigame/ps.qc index 058b935ec..3985aa731 100644 --- a/qcsrc/common/minigames/minigame/ps.qc +++ b/qcsrc/common/minigames/minigame/ps.qc @@ -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) ) { diff --git a/qcsrc/common/minigames/minigame/ttt.qc b/qcsrc/common/minigames/minigame/ttt.qc index d67aa15ea..c5e3d2ab4 100644 --- a/qcsrc/common/minigames/minigame/ttt.qc +++ b/qcsrc/common/minigames/minigame/ttt.qc @@ -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) ) { diff --git a/qcsrc/common/monsters/sv_monsters.qc b/qcsrc/common/monsters/sv_monsters.qc index b71e1054d..862bc6a9b 100644 --- a/qcsrc/common/monsters/sv_monsters.qc +++ b/qcsrc/common/monsters/sv_monsters.qc @@ -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; } diff --git a/qcsrc/common/mutators/mutator/buffs/sv_buffs.qh b/qcsrc/common/mutators/mutator/buffs/sv_buffs.qh index 838ac668e..decef9d40 100644 --- a/qcsrc/common/mutators/mutator/buffs/sv_buffs.qh +++ b/qcsrc/common/mutators/mutator/buffs/sv_buffs.qh @@ -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; diff --git a/qcsrc/common/mutators/mutator/overkill/okrpc.qc b/qcsrc/common/mutators/mutator/overkill/okrpc.qc index 46a783ce5..734c1d25b 100644 --- a/qcsrc/common/mutators/mutator/overkill/okrpc.qc +++ b/qcsrc/common/mutators/mutator/overkill/okrpc.qc @@ -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; diff --git a/qcsrc/common/mutators/mutator/superspec/sv_superspec.qc b/qcsrc/common/mutators/mutator/superspec/sv_superspec.qc index 71bb9c8fc..fe57eaa44 100644 --- a/qcsrc/common/mutators/mutator/superspec/sv_superspec.qc +++ b/qcsrc/common/mutators/mutator/superspec/sv_superspec.qc @@ -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); diff --git a/qcsrc/common/physics/player.qh b/qcsrc/common/physics/player.qh index ea827f4fe..976bef7c1 100644 --- a/qcsrc/common/physics/player.qh +++ b/qcsrc/common/physics/player.qh @@ -53,7 +53,7 @@ bool autocvar_g_footsteps; .float gravity; .float swamp_slowdown; -.float lastflags; +.int lastflags; .float lastground; .bool wasFlying; diff --git a/qcsrc/common/weapons/weapon/arc.qc b/qcsrc/common/weapons/weapon/arc.qc index c97860003..489a1f43f 100644 --- a/qcsrc/common/weapons/weapon/arc.qc +++ b/qcsrc/common/weapons/weapon/arc.qc @@ -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 ) diff --git a/qcsrc/common/weapons/weapon/tuba.qc b/qcsrc/common/weapons/weapon/tuba.qc index 28608a221..53e481851 100644 --- a/qcsrc/common/weapons/weapon/tuba.qc +++ b/qcsrc/common/weapons/weapon/tuba.qc @@ -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); } diff --git a/qcsrc/lib/intrusivelist.qh b/qcsrc/lib/intrusivelist.qh index 0abc35835..452c99fb4 100644 --- a/qcsrc/lib/intrusivelist.qh +++ b/qcsrc/lib/intrusivelist.qh @@ -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; diff --git a/qcsrc/lib/warpzone/common.qh b/qcsrc/lib/warpzone/common.qh index f80b5a638..07dc265db 100644 --- a/qcsrc/lib/warpzone/common.qh +++ b/qcsrc/lib/warpzone/common.qh @@ -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) diff --git a/qcsrc/server/bot/default/havocbot/havocbot.qc b/qcsrc/server/bot/default/havocbot/havocbot.qc index 0445fef01..d597272b7 100644 --- a/qcsrc/server/bot/default/havocbot/havocbot.qc +++ b/qcsrc/server/bot/default/havocbot/havocbot.qc @@ -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); diff --git a/qcsrc/server/client.qc b/qcsrc/server/client.qc index 8d0db75da..5c8c85380 100644 --- a/qcsrc/server/client.qc +++ b/qcsrc/server/client.qc @@ -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); } diff --git a/qcsrc/server/damage.qc b/qcsrc/server/damage.qc index 63ee5fda1..9e00293d3 100644 --- a/qcsrc/server/damage.qc +++ b/qcsrc/server/damage.qc @@ -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') diff --git a/qcsrc/server/hook.qh b/qcsrc/server/hook.qh index 545a01ced..34d1cd04e 100644 --- a/qcsrc/server/hook.qh +++ b/qcsrc/server/hook.qh @@ -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]; diff --git a/qcsrc/server/items/items.qc b/qcsrc/server/items/items.qc index 6adc4f9b4..83022b2bd 100644 --- a/qcsrc/server/items/items.qc +++ b/qcsrc/server/items/items.qc @@ -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; diff --git a/qcsrc/server/portals.qc b/qcsrc/server/portals.qc index 405d179ca..8f24e15ec 100644 --- a/qcsrc/server/portals.qc +++ b/qcsrc/server/portals.qc @@ -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) diff --git a/qcsrc/server/scores.qc b/qcsrc/server/scores.qc index 40bbec644..5fecde38c 100644 --- a/qcsrc/server/scores.qc +++ b/qcsrc/server/scores.qc @@ -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) diff --git a/qcsrc/server/weapons/accuracy.qc b/qcsrc/server/weapons/accuracy.qc index a09719f25..7916a76e0 100644 --- a/qcsrc/server/weapons/accuracy.qc +++ b/qcsrc/server/weapons/accuracy.qc @@ -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; }); } diff --git a/qcsrc/server/weapons/selection.qc b/qcsrc/server/weapons/selection.qc index 1af0881c3..c32f67c96 100644 --- a/qcsrc/server/weapons/selection.qc +++ b/qcsrc/server/weapons/selection.qc @@ -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; }); diff --git a/qcsrc/server/weapons/throwing.qc b/qcsrc/server/weapons/throwing.qc index 782ee3aa3..38d0f97a3 100644 --- a/qcsrc/server/weapons/throwing.qc +++ b/qcsrc/server/weapons/throwing.qc @@ -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) { -- 2.39.5