]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Minigames: don't let the player interact with minigame menu via keyboard while waitin...
authorterencehill <piuntn@gmail.com>
Tue, 29 Dec 2020 15:38:14 +0000 (16:38 +0100)
committerterencehill <piuntn@gmail.com>
Tue, 29 Dec 2020 15:38:14 +0000 (16:38 +0100)
qcsrc/common/minigames/minigame/bd.qc
qcsrc/common/minigames/minigame/c4.qc
qcsrc/common/minigames/minigame/nmm.qc
qcsrc/common/minigames/minigame/pong.qc
qcsrc/common/minigames/minigame/pp.qc
qcsrc/common/minigames/minigame/ps.qc
qcsrc/common/minigames/minigame/ttt.qc

index 253dd612e396fa3a0762afe65e82b28881d51e26..0744c0b379cbe8d0a483b47c10976af51aefebb8 100644 (file)
@@ -1251,31 +1251,33 @@ int bd_client_event(entity minigame, string event, ...)
                case "key_pressed":
                case "key_released":
                {
-                       if(minigame.minigame_flags & BD_TURN_MOVE)
+                       bool event_blocked = ((event == "key_released")
+                               || !(minigame.minigame_flags & BD_TURN_MOVE));
+                       if (!(minigame.minigame_flags & BD_TURN_WIN) && !(minigame.minigame_flags & BD_TURN_LOSS))
                        {
                                switch ( ...(0,int) )
                                {
                                        case K_RIGHTARROW:
                                        case K_KP_RIGHTARROW:
-                                               if (event == "key_released")
+                                               if (event_blocked)
                                                        return true;
                                                bd_make_move(minigame, "r");
                                                return true;
                                        case K_LEFTARROW:
                                        case K_KP_LEFTARROW:
-                                               if (event == "key_released")
+                                               if (event_blocked)
                                                        return true;
                                                bd_make_move(minigame, "l");
                                                return true;
                                        case K_UPARROW:
                                        case K_KP_UPARROW:
-                                               if (event == "key_released")
+                                               if (event_blocked)
                                                        return true;
                                                bd_make_move(minigame, "u");
                                                return true;
                                        case K_DOWNARROW:
                                        case K_KP_DOWNARROW:
-                                               if (event == "key_released")
+                                               if (event_blocked)
                                                        return true;
                                                bd_make_move(minigame, "d");
                                                return true;
@@ -1288,7 +1290,7 @@ int bd_client_event(entity minigame, string event, ...)
                                {
                                        case K_RIGHTARROW:
                                        case K_KP_RIGHTARROW:
-                                               if (event == "key_released")
+                                               if (event_blocked)
                                                        return true;
                                                if ( ! bd_curr_pos )
                                                        bd_set_curr_pos("a3");
@@ -1297,7 +1299,7 @@ int bd_client_event(entity minigame, string event, ...)
                                                return true;
                                        case K_LEFTARROW:
                                        case K_KP_LEFTARROW:
-                                               if (event == "key_released")
+                                               if (event_blocked)
                                                        return true;
                                                if ( ! bd_curr_pos )
                                                        bd_set_curr_pos("c3");
@@ -1306,7 +1308,7 @@ int bd_client_event(entity minigame, string event, ...)
                                                return true;
                                        case K_UPARROW:
                                        case K_KP_UPARROW:
-                                               if (event == "key_released")
+                                               if (event_blocked)
                                                        return true;
                                                if ( ! bd_curr_pos )
                                                        bd_set_curr_pos("a1");
@@ -1315,7 +1317,7 @@ int bd_client_event(entity minigame, string event, ...)
                                                return true;
                                        case K_DOWNARROW:
                                        case K_KP_DOWNARROW:
-                                               if (event == "key_released")
+                                               if (event_blocked)
                                                        return true;
                                                if ( ! bd_curr_pos )
                                                        bd_set_curr_pos("a3");
@@ -1324,12 +1326,12 @@ int bd_client_event(entity minigame, string event, ...)
                                                return true;
                                        case K_ENTER:
                                        case K_KP_ENTER:
-                                               if (event == "key_released")
+                                               if (event_blocked)
                                                        return true;
                                                bd_editor_make_move(minigame, "");
                                                return true;
                                        case K_SPACE:
-                                               if (event == "key_released")
+                                               if (event_blocked)
                                                        return true;
                                                if(bd_change_dozer_angle(minigame))
                                                        return true;
index 8c12f8dfb1a7cefa1b626f963265368cf8d39ec1..665f72f9c39ffaef4e18d71be9c69357f923a7b7 100644 (file)
@@ -424,13 +424,15 @@ int c4_client_event(entity minigame, string event, ...)
                case "key_pressed":
                case "key_released":
                {
-                       if((minigame.minigame_flags & C4_TURN_TEAM) == minigame_self.team)
+                       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))
                        {
                                switch ( ...(0,int) )
                                {
                                        case K_RIGHTARROW:
                                        case K_KP_RIGHTARROW:
-                                               if (event == "key_released")
+                                               if (event_blocked)
                                                        return true;
                                                if ( ! c4_curr_pos )
                                                        c4_set_curr_pos(c4_get_lowest_tile(minigame, "a3"));
@@ -439,7 +441,7 @@ int c4_client_event(entity minigame, string event, ...)
                                                return true;
                                        case K_LEFTARROW:
                                        case K_KP_LEFTARROW:
-                                               if (event == "key_released")
+                                               if (event_blocked)
                                                        return true;
                                                if ( ! c4_curr_pos )
                                                        c4_set_curr_pos(c4_get_lowest_tile(minigame, "c3"));
@@ -453,7 +455,7 @@ int c4_client_event(entity minigame, string event, ...)
                                                return true;
                                        /*case K_UPARROW:
                                        case K_KP_UPARROW:
-                                               if (event == "key_released")
+                                               if (event_blocked)
                                                        return true;
                                                if ( ! c4_curr_pos )
                                                        c4_set_curr_pos("a1");
@@ -462,7 +464,7 @@ int c4_client_event(entity minigame, string event, ...)
                                                return true;
                                        case K_DOWNARROW:
                                        case K_KP_DOWNARROW:
-                                               if (event == "key_released")
+                                               if (event_blocked)
                                                        return true;
                                                if ( ! c4_curr_pos )
                                                        c4_set_curr_pos("a3");
@@ -472,7 +474,7 @@ int c4_client_event(entity minigame, string event, ...)
                                        case K_ENTER:
                                        case K_KP_ENTER:
                                        case K_SPACE:
-                                               if (event == "key_released")
+                                               if (event_blocked)
                                                        return true;
                                                c4_make_move(minigame);
                                                return true;
index bc049ca8e148d9c28800a251feddd30c6244dad2..18ed02009b8c95a6dfa516f0f7f2a3d7b30c3e21 100644 (file)
@@ -632,85 +632,90 @@ int nmm_client_event(entity minigame, string event, ...)
                nmm_kill_tiles(minigame);
                strfree(minigame.message);
        }
-       else if ( (event == "key_pressed" || event == "key_released") && (minigame.minigame_flags&NMM_TURN_TEAM) == minigame_self.team )
+       else if ( (event == "key_pressed" || event == "key_released") )
        {
-               switch ( ...(0,int) )
+               bool event_blocked = ((event == "key_released")
+                       || ((minigame.minigame_flags & NMM_TURN_TEAM) != minigame_self.team));
+               if (!(minigame.minigame_flags & NMM_TURN_WIN))
                {
-                       case K_RIGHTARROW:
-                       case K_KP_RIGHTARROW:
-                               if (event == "key_released")
-                                       return true;
-                               if ( ! nmm_currtile )
-                                       nmm_currtile = nmm_find_tile(active_minigame,"a7");
-                               else
-                               {
-                                       string tileid = nmm_currtile.netname;
-                                       nmm_currtile = NULL;
-                                       while ( !nmm_currtile )
+                       switch ( ...(0,int) )
+                       {
+                               case K_RIGHTARROW:
+                               case K_KP_RIGHTARROW:
+                                       if (event_blocked)
+                                               return true;
+                                       if ( ! nmm_currtile )
+                                               nmm_currtile = nmm_find_tile(active_minigame,"a7");
+                                       else
                                        {
-                                               tileid = minigame_relative_tile(tileid,1,0,7,7);
-                                               nmm_currtile = nmm_find_tile(active_minigame,tileid);
+                                               string tileid = nmm_currtile.netname;
+                                               nmm_currtile = NULL;
+                                               while ( !nmm_currtile )
+                                               {
+                                                       tileid = minigame_relative_tile(tileid,1,0,7,7);
+                                                       nmm_currtile = nmm_find_tile(active_minigame,tileid);
+                                               }
                                        }
-                               }
-                               return 1;
-                       case K_LEFTARROW:
-                       case K_KP_LEFTARROW:
-                               if (event == "key_released")
-                                       return true;
-                               if ( ! nmm_currtile )
-                                       nmm_currtile = nmm_find_tile(active_minigame,"g7");
-                               else
-                               {
-                                       string tileid = nmm_currtile.netname;
-                                       nmm_currtile = NULL;
-                                       while ( !nmm_currtile )
+                                       return 1;
+                               case K_LEFTARROW:
+                               case K_KP_LEFTARROW:
+                                       if (event_blocked)
+                                               return true;
+                                       if ( ! nmm_currtile )
+                                               nmm_currtile = nmm_find_tile(active_minigame,"g7");
+                                       else
                                        {
-                                               tileid = minigame_relative_tile(tileid,-1,0,7,7);
-                                               nmm_currtile = nmm_find_tile(active_minigame,tileid);
+                                               string tileid = nmm_currtile.netname;
+                                               nmm_currtile = NULL;
+                                               while ( !nmm_currtile )
+                                               {
+                                                       tileid = minigame_relative_tile(tileid,-1,0,7,7);
+                                                       nmm_currtile = nmm_find_tile(active_minigame,tileid);
+                                               }
                                        }
-                               }
-                               return 1;
-                       case K_UPARROW:
-                       case K_KP_UPARROW:
-                               if (event == "key_released")
-                                       return true;
-                               if ( ! nmm_currtile )
-                                       nmm_currtile = nmm_find_tile(active_minigame,"a1");
-                               else
-                               {
-                                       string tileid = nmm_currtile.netname;
-                                       nmm_currtile = NULL;
-                                       while ( !nmm_currtile )
+                                       return 1;
+                               case K_UPARROW:
+                               case K_KP_UPARROW:
+                                       if (event_blocked)
+                                               return true;
+                                       if ( ! nmm_currtile )
+                                               nmm_currtile = nmm_find_tile(active_minigame,"a1");
+                                       else
                                        {
-                                               tileid = minigame_relative_tile(tileid,0,1,7,7);
-                                               nmm_currtile = nmm_find_tile(active_minigame,tileid);
+                                               string tileid = nmm_currtile.netname;
+                                               nmm_currtile = NULL;
+                                               while ( !nmm_currtile )
+                                               {
+                                                       tileid = minigame_relative_tile(tileid,0,1,7,7);
+                                                       nmm_currtile = nmm_find_tile(active_minigame,tileid);
+                                               }
                                        }
-                               }
-                               return 1;
-                       case K_DOWNARROW:
-                       case K_KP_DOWNARROW:
-                               if (event == "key_released")
-                                       return true;
-                               if ( ! nmm_currtile )
-                                       nmm_currtile = nmm_find_tile(active_minigame,"a7");
-                               else
-                               {
-                                       string tileid = nmm_currtile.netname;
-                                       nmm_currtile = NULL;
-                                       while ( !nmm_currtile )
+                                       return 1;
+                               case K_DOWNARROW:
+                               case K_KP_DOWNARROW:
+                                       if (event_blocked)
+                                               return true;
+                                       if ( ! nmm_currtile )
+                                               nmm_currtile = nmm_find_tile(active_minigame,"a7");
+                                       else
                                        {
-                                               tileid = minigame_relative_tile(tileid,0,-1,7,7);
-                                               nmm_currtile = nmm_find_tile(active_minigame,tileid);
+                                               string tileid = nmm_currtile.netname;
+                                               nmm_currtile = NULL;
+                                               while ( !nmm_currtile )
+                                               {
+                                                       tileid = minigame_relative_tile(tileid,0,-1,7,7);
+                                                       nmm_currtile = nmm_find_tile(active_minigame,tileid);
+                                               }
                                        }
-                               }
-                               return 1;
-                       case K_ENTER:
-                       case K_KP_ENTER:
-                       case K_SPACE:
-                               if (event == "key_released")
-                                       return true;
-                               nmm_make_move(minigame);
-                               return 1;
+                                       return 1;
+                               case K_ENTER:
+                               case K_KP_ENTER:
+                               case K_SPACE:
+                                       if (event_blocked)
+                                               return true;
+                                       nmm_make_move(minigame);
+                                       return 1;
+                       }
                }
                return 0;
        }
index 5ae108660a0db11df34c67ebc9ee0a2345fa797a..30bdd80665ff739f8e97daa4f6c640db8efc233a 100644 (file)
@@ -621,39 +621,40 @@ int pong_client_event(entity minigame, string event, ...)
                }
                case "key_pressed":
                case "key_released":
-                       switch ( ...(0,int) )
-                       {
-                               case K_UPARROW:
-                               case K_KP_UPARROW:
-                               case K_LEFTARROW:
-                               case K_KP_LEFTARROW:
-                                       if (event == "key_pressed")
-                                       {
-                                               //minigame_cmd("+moved");
-                                               pong_keys_pressed |= PONG_KEY_DECREASE;
-                                       }
-                                       else
-                                       {
-                                               //minigame_cmd("-moved");
-                                               pong_keys_pressed &= ~PONG_KEY_DECREASE;
-                                       }
-                                       return true;
-                               case K_DOWNARROW:
-                               case K_KP_DOWNARROW:
-                               case K_RIGHTARROW:
-                               case K_KP_RIGHTARROW:
-                                       if (event == "key_pressed")
-                                       {
-                                               //minigame_cmd("+movei");
-                                               pong_keys_pressed |= PONG_KEY_INCREASE;
-                                       }
-                                       else
-                                       {
-                                               //minigame_cmd("-movei");
-                                               pong_keys_pressed &= ~PONG_KEY_INCREASE;
-                                       }
-                                       return true;
-                       }
+                       if ((minigame.minigame_flags & PONG_STATUS_PLAY))
+                               switch ( ...(0,int) )
+                               {
+                                       case K_UPARROW:
+                                       case K_KP_UPARROW:
+                                       case K_LEFTARROW:
+                                       case K_KP_LEFTARROW:
+                                               if (event == "key_pressed")
+                                               {
+                                                       //minigame_cmd("+moved");
+                                                       pong_keys_pressed |= PONG_KEY_DECREASE;
+                                               }
+                                               else
+                                               {
+                                                       //minigame_cmd("-moved");
+                                                       pong_keys_pressed &= ~PONG_KEY_DECREASE;
+                                               }
+                                               return true;
+                                       case K_DOWNARROW:
+                                       case K_KP_DOWNARROW:
+                                       case K_RIGHTARROW:
+                                       case K_KP_RIGHTARROW:
+                                               if (event == "key_pressed")
+                                               {
+                                                       //minigame_cmd("+movei");
+                                                       pong_keys_pressed |= PONG_KEY_INCREASE;
+                                               }
+                                               else
+                                               {
+                                                       //minigame_cmd("-movei");
+                                                       pong_keys_pressed &= ~PONG_KEY_INCREASE;
+                                               }
+                                               return true;
+                               }
                        return false;
                case "network_receive":
                {
index 91b4142f4ccf9e653bff449d8174fe7594db4d6f..7204ddf8df0a06ce60dd5dcdae946e053cb65bce 100644 (file)
@@ -497,13 +497,15 @@ int pp_client_event(entity minigame, string event, ...)
                case "key_pressed":
                case "key_released":
                {
-                       if((minigame.minigame_flags & PP_TURN_TEAM) == minigame_self.team)
+                       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))
                        {
                                switch ( ...(0,int) )
                                {
                                        case K_RIGHTARROW:
                                        case K_KP_RIGHTARROW:
-                                               if (event == "key_released")
+                                               if (event_blocked)
                                                        return true;
                                                if ( ! pp_curr_pos )
                                                        pp_set_curr_pos("a3");
@@ -512,7 +514,7 @@ int pp_client_event(entity minigame, string event, ...)
                                                return true;
                                        case K_LEFTARROW:
                                        case K_KP_LEFTARROW:
-                                               if (event == "key_released")
+                                               if (event_blocked)
                                                        return true;
                                                if ( ! pp_curr_pos )
                                                        pp_set_curr_pos("c3");
@@ -521,7 +523,7 @@ int pp_client_event(entity minigame, string event, ...)
                                                return true;
                                        case K_UPARROW:
                                        case K_KP_UPARROW:
-                                               if (event == "key_released")
+                                               if (event_blocked)
                                                        return true;
                                                if ( ! pp_curr_pos )
                                                        pp_set_curr_pos("a1");
@@ -530,7 +532,7 @@ int pp_client_event(entity minigame, string event, ...)
                                                return true;
                                        case K_DOWNARROW:
                                        case K_KP_DOWNARROW:
-                                               if (event == "key_released")
+                                               if (event_blocked)
                                                        return true;
                                                if ( ! pp_curr_pos )
                                                        pp_set_curr_pos("a3");
@@ -540,7 +542,7 @@ int pp_client_event(entity minigame, string event, ...)
                                        case K_ENTER:
                                        case K_KP_ENTER:
                                        case K_SPACE:
-                                               if (event == "key_released")
+                                               if (event_blocked)
                                                        return true;
                                                pp_make_move(minigame);
                                                return true;
index 7dc19ee63021a5b3849ba514af6c466a739483c0..b60a6a7fc0bfcdf6ad9970a5d2e1398ac2f425e1 100644 (file)
@@ -543,13 +543,14 @@ int ps_client_event(entity minigame, string event, ...)
                case "key_pressed":
                case "key_released":
                {
-                       //if((minigame.minigame_flags & PS_TURN_TEAM) == minigame_self.team)
+                       bool event_blocked = (event == "key_released");
+                       if (!(minigame.minigame_flags & PS_TURN_WIN) && !(minigame.minigame_flags & PS_TURN_DRAW))
                        {
                                switch ( ...(0,int) )
                                {
                                        case K_RIGHTARROW:
                                        case K_KP_RIGHTARROW:
-                                               if (event == "key_released")
+                                               if (event_blocked)
                                                        return true;
                                                if ( ! ps_curr_pos )
                                                        ps_set_curr_pos("a3");
@@ -558,7 +559,7 @@ int ps_client_event(entity minigame, string event, ...)
                                                return true;
                                        case K_LEFTARROW:
                                        case K_KP_LEFTARROW:
-                                               if (event == "key_released")
+                                               if (event_blocked)
                                                        return true;
                                                if ( ! ps_curr_pos )
                                                        ps_set_curr_pos("c3");
@@ -567,7 +568,7 @@ int ps_client_event(entity minigame, string event, ...)
                                                return true;
                                        case K_UPARROW:
                                        case K_KP_UPARROW:
-                                               if (event == "key_released")
+                                               if (event_blocked)
                                                        return true;
                                                if ( ! ps_curr_pos )
                                                        ps_set_curr_pos("a1");
@@ -576,7 +577,7 @@ int ps_client_event(entity minigame, string event, ...)
                                                return true;
                                        case K_DOWNARROW:
                                        case K_KP_DOWNARROW:
-                                               if (event == "key_released")
+                                               if (event_blocked)
                                                        return true;
                                                if ( ! ps_curr_pos )
                                                        ps_set_curr_pos("a3");
@@ -586,7 +587,7 @@ int ps_client_event(entity minigame, string event, ...)
                                        case K_ENTER:
                                        case K_KP_ENTER:
                                        case K_SPACE:
-                                               if (event == "key_released")
+                                               if (event_blocked)
                                                        return true;
                                                ps_make_move(minigame);
                                                return true;
index 42e844bd36562dcb0ce9bb07a2ea6f79cb1d715d..d578aa9615ae8b53b95b8fd7f6b88ca9c2c5fc17 100644 (file)
@@ -567,13 +567,15 @@ int ttt_client_event(entity minigame, string event, ...)
                case "key_pressed":
                case "key_released":
                {
-                       if((minigame.minigame_flags & TTT_TURN_TEAM) == minigame_self.team)
+                       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))
                        {
                                switch ( ...(0,int) )
                                {
                                        case K_RIGHTARROW:
                                        case K_KP_RIGHTARROW:
-                                               if (event == "key_released")
+                                               if (event_blocked)
                                                        return true;
                                                if ( ! ttt_curr_pos )
                                                        ttt_set_curr_pos("a3");
@@ -582,7 +584,7 @@ int ttt_client_event(entity minigame, string event, ...)
                                                return true;
                                        case K_LEFTARROW:
                                        case K_KP_LEFTARROW:
-                                               if (event == "key_released")
+                                               if (event_blocked)
                                                        return true;
                                                if ( ! ttt_curr_pos )
                                                        ttt_set_curr_pos("c3");
@@ -591,7 +593,7 @@ int ttt_client_event(entity minigame, string event, ...)
                                                return true;
                                        case K_UPARROW:
                                        case K_KP_UPARROW:
-                                               if (event == "key_released")
+                                               if (event_blocked)
                                                        return true;
                                                if ( ! ttt_curr_pos )
                                                        ttt_set_curr_pos("a1");
@@ -600,7 +602,7 @@ int ttt_client_event(entity minigame, string event, ...)
                                                return true;
                                        case K_DOWNARROW:
                                        case K_KP_DOWNARROW:
-                                               if (event == "key_released")
+                                               if (event_blocked)
                                                        return true;
                                                if ( ! ttt_curr_pos )
                                                        ttt_set_curr_pos("a3");
@@ -610,7 +612,7 @@ int ttt_client_event(entity minigame, string event, ...)
                                        case K_ENTER:
                                        case K_KP_ENTER:
                                        case K_SPACE:
-                                               if (event == "key_released")
+                                               if (event_blocked)
                                                        return true;
                                                ttt_make_move(minigame);
                                                return true;