check for game in pause command itself
[netris.git] / client.c
index 9c228d857d4a756c4944689ca7b7fd420be88a51..47916fc27cdf9d5a14259da20115c496fe7e5fa0 100644 (file)
--- a/client.c
+++ b/client.c
@@ -21,6 +21,7 @@
 #include "netris.h"
 
 #include <stdlib.h>
+#include <stdbool.h>
 #include <ctype.h>
 #include <string.h>
 #include <sys/types.h>
@@ -345,6 +346,7 @@ void OneGame(void)
                        gameStatus = 0;
                        return;
                case CT_pause:
+                       if (Players[me].alive <= 0) return;
                        Players[me].flags ^= SCF_paused;
                        if (Game.started > 1)
                                Message(Players[me].flags & SCF_paused
@@ -425,30 +427,36 @@ void OneGame(void)
                if (!(p = strchr(keyTable, tolower(key)))) return;
                key = p - keyTable;
 
-               // global actions (always possible, even if not playing)
+       bool handle_key(char key)
+       {
                switch (key) {
                case KT_redraw:
                        clear();
                        InitFields();
 //                     ScheduleFullRedraw();
                        refresh();
-                       return;
+                       return 1;
                case KT_say:
                        chatMode = 1;
                        Messagetype(key, strlen(chatText) - 1, chatText);
-                       return;
+                       return 1;
                case KT_quit:
-                       return handle_cmd(CT_quit, NULL);
+                       handle_cmd(CT_quit, NULL);
+                       return 1;
+               default:
+                       return 0;
                }
+       }
+               // global actions (always possible, even if not playing)
+               if (handle_key(key)) return;
 
-               if (Players[me].alive <= 0) return;
                // actions available while in game
                switch (key) {
                case KT_pause:
                        return handle_cmd(CT_pause, NULL);
                }
 
-               if (paused) return;
+               if (Players[me].alive <= 0 || paused) return;
                // actions only available while actually playing
                switch (key) {
                case KT_left: