]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Remove some bInputType checks that now are redundant in HUD_Minigame_InputEvent
authorterencehill <piuntn@gmail.com>
Sun, 27 Dec 2020 23:13:22 +0000 (00:13 +0100)
committerterencehill <piuntn@gmail.com>
Sun, 27 Dec 2020 23:13:22 +0000 (00:13 +0100)
qcsrc/common/minigames/cl_minigames_hud.qc

index 861e01be3dd3255aac47840e5b5fe165df5cf514..49a73dcc44dce7229e128f4e4df96706439013fe 100644 (file)
@@ -626,14 +626,17 @@ float HUD_Minigame_InputEvent(float bInputType, float nPrimary, float nSecondary
                return false;
        }
 
-       if(bInputType == 0) {
+       // at this point bInputType can only be 0 or 1 (key pressed or released)
+       bool key_pressed = (bInputType == 0);
+
+       if(key_pressed) {
                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;
        }
-       else if(bInputType == 1) {
+       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);
@@ -651,10 +654,10 @@ float HUD_Minigame_InputEvent(float bInputType, float nPrimary, float nSecondary
                        return false;
        }
 
-       if ( active_minigame && ( bInputType == 0 || bInputType == 1 ) )
+       if ( active_minigame )
        {
                string device = "";
-               string action = bInputType == 0 ? "pressed" : "released";
+               string action = key_pressed ? "pressed" : "released";
                if ( nPrimary >= K_MOUSE1 && nPrimary <= K_MOUSE16 )
                {
                        if ( HUD_mouse_over(HUD_PANEL(MINIGAMEBOARD)) )
@@ -668,7 +671,7 @@ float HUD_Minigame_InputEvent(float bInputType, float nPrimary, float nSecondary
                        return true;
        }
 
-       if ( bInputType == 0 )
+       if ( key_pressed )
        {
                if ( nPrimary == K_MOUSE1 && HUD_MinigameMenu_activeitem &&
                        HUD_mouse_over(HUD_PANEL(MINIGAMEMENU)) )