quit and pause commands
authorMischa POSLAWSKY <netris@shiar.org>
Sun, 4 Mar 2007 12:36:38 +0000 (13:36 +0100)
committerMischa POSLAWSKY <netris@shiar.org>
Sun, 4 Mar 2007 12:36:38 +0000 (13:36 +0100)
Replace direct actions by key.

client.c

index 0974c222aa6de2c3ed171e71093eccaf3813619a..9c228d857d4a756c4944689ca7b7fd420be88a51 100644 (file)
--- a/client.c
+++ b/client.c
@@ -65,9 +65,11 @@ _Sets Sets = {7, 0, 1, 1, 1};
 static char keyTable[KT_numKeys+1];
 
 enum {
+       CT_quit, CT_pause,
        CT_MAX
 };
 static char *cmds[] = {
+       "quit", "pause"
 };
 
 static char *hostStr;
@@ -337,6 +339,25 @@ void OneGame(void)
        void handle_cmd(char cmd, char *arg)
        {
                switch (cmd) {
+               case CT_quit:
+                       ShowPause(me);
+                       refresh();
+                       gameStatus = 0;
+                       return;
+               case CT_pause:
+                       Players[me].flags ^= SCF_paused;
+                       if (Game.started > 1)
+                               Message(Players[me].flags & SCF_paused
+                                       ? "You paused the game" : "You unpaused the game");
+                       else
+                               Message(Players[me].flags & SCF_paused
+                                       ? "You are not ready" : "You are ready");
+                       checkPaused();
+                       if (game == GT_classicTwo)
+                               SendPacket(me, NP_pause, 0, NULL);
+                       ShowPause(me);
+                       changed = 1;
+                       return;
                }
        }
 
@@ -417,29 +438,14 @@ void OneGame(void)
                        Messagetype(key, strlen(chatText) - 1, chatText);
                        return;
                case KT_quit:
-                       ShowPause(me);
-                       refresh();
-                       gameStatus = 0;
-                       return;
+                       return handle_cmd(CT_quit, NULL);
                }
 
                if (Players[me].alive <= 0) return;
                // actions available while in game
                switch (key) {
                case KT_pause:
-                       Players[me].flags ^= SCF_paused;
-                       if (Game.started > 1)
-                               Message(Players[me].flags & SCF_paused
-                                       ? "You paused the game" : "You unpaused the game");
-                       else
-                               Message(Players[me].flags & SCF_paused
-                                       ? "You are not ready" : "You are ready");
-                       checkPaused();
-                       if (game == GT_classicTwo)
-                               SendPacket(me, NP_pause, 0, NULL);
-                       ShowPause(me);
-                       changed = 1;
-                       return;
+                       return handle_cmd(CT_pause, NULL);
                }
 
                if (paused) return;