]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Wrap all status and bitflag checks with parentesis to avoid possible obscure bugs
authorLegendaryGuard <rootuser999@gmail.com>
Sat, 5 Aug 2023 09:46:58 +0000 (11:46 +0200)
committerLegendaryGuard <rootuser999@gmail.com>
Sat, 5 Aug 2023 09:47:24 +0000 (11:47 +0200)
qcsrc/common/minigames/minigame/pong.qc
qcsrc/common/minigames/minigame/pp.qc
qcsrc/common/weapons/weapon/porto.qc
qcsrc/menu/xonotic/dialog_welcome.qc
qcsrc/menu/xonotic/maplist.qc
qcsrc/server/bot/default/havocbot/havocbot.qc
qcsrc/server/bot/default/navigation.qc
qcsrc/server/bot/default/scripting.qc
qcsrc/server/bot/default/waypoints.qc
qcsrc/server/items/items.qc
qcsrc/server/items/spawning.qh

index 412273d90b9fa19e2a95fe6ddae07f4004912dd3..698ccfb555a05ce2629d6a1bc4cb5b4faee357a6 100644 (file)
@@ -703,7 +703,7 @@ int pong_client_event(entity minigame, string event, ...)
                case "menu_click":
                {
                        string cmd = ...(0,string);
-                       if( cmd == "pong_throw" && minigame.minigame_flags & PONG_STATUS_WAIT )
+                       if( cmd == "pong_throw" && ( minigame.minigame_flags & PONG_STATUS_WAIT ) )
                        {
                                minigame_cmd("throw");
                        }
index 1c755b64065de1c5e8678d4e1c6b9193f2fd1ef7..9a7e54234d7bab0aa48aa57c811123fd872b400e 100644 (file)
@@ -452,7 +452,7 @@ string pp_turn_to_string(int turnflags)
        if ( turnflags & PP_TURN_WIN )
        {
                // translator-friendly messages composed of 2 existing messages
-               if ( (turnflags&PP_TURN_TEAM) != minigame_self.team )
+               if ( (turnflags & PP_TURN_TEAM) != minigame_self.team )
                        return strcat(_("You lost the game!"), "\n", _("Select \"^1Next Match^7\" on the menu for a rematch!"));
                return strcat(_("You win!"), "\n", _("Select \"^1Next Match^7\" on the menu to start a new match!"));
        }
index 7ee4162157077a97024dc710403f51ff8e845df1..9a1f7b26b5f4a023044d863bd1afea60a8f2fe7c 100644 (file)
@@ -171,7 +171,7 @@ void W_Porto_Touch(entity this, entity toucher)
                traceline(trace_ent.origin, trace_ent.origin + '0 0 2' * PL_MIN_CONST.z, MOVE_WORLDONLY, this);
                if(trace_fraction >= 1)
                        return;
-               if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_SLICK || trace_dphitcontents & DPCONTENTS_PLAYERCLIP)
+               if((trace_dphitq3surfaceflags & Q3SURFACEFLAG_SLICK) || (trace_dphitcontents & DPCONTENTS_PLAYERCLIP))
                        return;
                if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOIMPACT)
                        return;
index 1651af5e6d4ca725e0ff29635227bbe78881d449..addafe6c08c0493ba6b2a483ba1dee0004516632 100644 (file)
@@ -93,7 +93,7 @@ void XonoticWelcomeDialog_draw(entity me)
        if (!(gamestatus & (GAME_ISSERVER | GAME_CONNECTED)))
                me.close(me);
 
-       if(me.serverinfo_MOTD == "" && gamestatus & (GAME_CONNECTED | GAME_ISSERVER))
+       if(me.serverinfo_MOTD == "" && (gamestatus & (GAME_CONNECTED | GAME_ISSERVER)))
        {
                // if serverinfo_MOTD is empty while connected it means we are connected to an old server
                // in this case show the csqc welcome message and instantly close the dialog
index 1fa065874554ce666fa883884d2347359d076bf0..81bf34e5226a3d3737939bc9a5e3e50232353227 100644 (file)
@@ -80,7 +80,7 @@ void XonoticMapList_draw(entity me)
 {
        if(me.startButton)
                me.startButton.disabled = ((me.selectedItem < 0) || (me.selectedItem >= me.nItems)
-                       || (gamestatus & (GAME_ISSERVER | GAME_CONNECTED) && cvar("g_campaign")));
+                       || ((gamestatus & (GAME_ISSERVER | GAME_CONNECTED)) && cvar("g_campaign")));
        SUPER(XonoticMapList).draw(me);
 }
 
index c8855660a041ea77d9ad16b68d436f2d10009ca6..e7bf9e5a33936337f884f2f528de6f1ae27aa8fd 100644 (file)
@@ -625,7 +625,7 @@ void havocbot_movetogoal(entity this)
                if (this.items & IT_JETPACK)
                        action_for_trigger_hurt = 1;
                else if (!this.jumppadcount && !waypoint_is_hardwiredlink(this.goalcurrent_prev, this.goalcurrent)
-                       && !(this.goalcurrent_prev && this.goalcurrent_prev.wpflags & WAYPOINTFLAG_JUMP)
+                       && !(this.goalcurrent_prev && (this.goalcurrent_prev.wpflags & WAYPOINTFLAG_JUMP))
                        && GetResource(this, RES_HEALTH) + GetResource(this, RES_ARMOR) > ROCKETJUMP_DAMAGE())
                {
                        action_for_trigger_hurt = 2;
@@ -883,7 +883,7 @@ void havocbot_movetogoal(entity this)
 
        bool bunnyhop_forbidden = false;
        vector destorg = get_closer_dest(this.goalcurrent, this.origin);
-       if (this.jumppadcount && this.goalcurrent.wpflags & WAYPOINTFLAG_TELEPORT)
+       if (this.jumppadcount && (this.goalcurrent.wpflags & WAYPOINTFLAG_TELEPORT))
        {
                // if bot used the jumppad, push towards jumppad origin until jumppad waypoint gets removed
                destorg = this.goalcurrent.origin;
index 87bb5c0cd18246bbcbd16b5678776a3364860338..98069e0abe527a2a4620f2be8e5c490d9cdc90df 100644 (file)
@@ -1738,7 +1738,7 @@ int navigation_poptouchedgoals(entity this)
 
                                navigation_poproute(this);
                                ++removed_goals;
-                               if(this.goalcurrent && this.goalcurrent.wpflags & WAYPOINTFLAG_TELEPORT)
+                               if(this.goalcurrent && (this.goalcurrent.wpflags & WAYPOINTFLAG_TELEPORT))
                                        return removed_goals;
                        }
                }
index 4ad6246e611a797a821a0fb63ae7d78900cac2f0..960ac2162866410a86ba101a9eb9fb1d04dce8f3 100644 (file)
@@ -1212,13 +1212,13 @@ float bot_execute_commands_once(entity this)
        ispressingkey = boolean(bot_presskeys(this));
 
        // Handle conditions
-       if (!(bot_cmd.bot_cmd_type==BOT_CMD_FI||bot_cmd.bot_cmd_type==BOT_CMD_ELSE))
-       if((this.bot_cmd_condition_status & CMD_CONDITION_true) && this.bot_cmd_condition_status & CMD_CONDITION_false_BLOCK)
+       if (!(bot_cmd.bot_cmd_type == BOT_CMD_FI || bot_cmd.bot_cmd_type == BOT_CMD_ELSE))
+       if((this.bot_cmd_condition_status & CMD_CONDITION_true) && (this.bot_cmd_condition_status & CMD_CONDITION_false_BLOCK))
        {
                bot_command_executed(this, true);
                return -1;
        }
-       else if((this.bot_cmd_condition_status & CMD_CONDITION_false) && this.bot_cmd_condition_status & CMD_CONDITION_true_BLOCK)
+       else if((this.bot_cmd_condition_status & CMD_CONDITION_false) && (this.bot_cmd_condition_status & CMD_CONDITION_true_BLOCK))
        {
                bot_command_executed(this, true);
                return -1;
index 88ea34de221213c563f1d503b82c6837c3046349..d6bc1e6708eefcb4459cbe9eabeeb4b405ce380c 100644 (file)
@@ -1563,9 +1563,9 @@ void waypoint_load_hardwiredlinks()
                {
                        waypoint_addlink(wp_from, wp_to);
                        waypoint_mark_hardwiredlink(wp_from, wp_to);
-               } else if (wp_from.wpflags & WPFLAGMASK_NORELINK
+               } else if ((wp_from.wpflags & WPFLAGMASK_NORELINK)
                        && ((wp_from.wpflags & (WAYPOINTFLAG_JUMP | WAYPOINTFLAG_SUPPORT))
-                               || (wp_from.wpisbox && wp_from.wpflags & WAYPOINTFLAG_TELEPORT)))
+                               || (wp_from.wpisbox && (wp_from.wpflags & WAYPOINTFLAG_TELEPORT))))
                {
                        waypoint_addlink(wp_from, wp_to);
                }
index fe677d7f190e095e5be5a1fe776d2e552c70158e..ed8ba9a52e7dbe79a801f088dec2a5a3cc2c845b 100644 (file)
@@ -578,7 +578,7 @@ bool Item_GiveTo(entity item, entity player)
        }
 
        int its;
-       if((its = (item.items - (item.items & player.items)) & IT_PICKUPMASK))
+       if((its = (item.items - ((item.items & player.items)) & IT_PICKUPMASK)))
        {
                pickedup = true;
                player.items |= its;
index 7b19292c614a99ccc1a4c75af4e9c5e02f116228..223eb57fbf500180fc5ffee3920fa38d37abcd33 100644 (file)
@@ -45,7 +45,7 @@ bool Item_Initialise(entity item);
 /// \param[in] item Item to check.
 /// \return True if item should keep its position or false if it should be
 /// dropped to the ground.
-#define ITEM_SHOULD_KEEP_POSITION(item) (item.noalign || item.spawnflags & 1)
+#define ITEM_SHOULD_KEEP_POSITION(item) (item.noalign || (item.spawnflags & 1))
 
 /// \brief Returns whether the item is expiring (i.e. its strength, shield and
 /// superweapon timers expire while it is on the ground).