code cleanup
authorMischa POSLAWSKY <netris@shiar.org>
Sun, 4 Mar 2007 06:35:14 +0000 (07:35 +0100)
committerMischa POSLAWSKY <netris@shiar.org>
Sun, 4 Mar 2007 06:35:14 +0000 (07:35 +0100)
Move different key classes to seperate checks directly after checking
mode conditions.

game.c

diff --git a/game.c b/game.c
index 32c85db48ab9fe912b4baf283fec8ae974d3de70..20008f29f6d4338af35714712eeb227543dccf74 100644 (file)
--- a/game.c
+++ b/game.c
@@ -349,14 +349,44 @@ void OneGame(void)
 
                // global actions (always possible, even if not playing)
                switch (key) {
+               case KT_redraw:
+                       clear();
+                       InitFields();
+//                     ScheduleFullRedraw();
+                       refresh();
+                       break;
                case KT_say:
                        chatMode = 1;
                        Messagetype(key, strlen(chatText) - 1, chatText);
                        break;
+               case KT_quit:
+                       ShowPause(me);
+                       refresh();
+                       gameStatus = 0;
+                       break;
+               }
+
+               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;
+                       break;
                }
 
-               if (Players[me].alive <= 0 && key != KT_quit) return;
-               if (paused && key < KT_pause) return;
+               if (paused) return;
+               // actions only available while actually playing
                switch (key) {
                case KT_left:
                        if (MovePiece(me, 0, -1) && spied) SendPacket(me, NP_left, 0, NULL);
@@ -396,32 +426,8 @@ void OneGame(void)
                        ShowScore(me, Players[me].score);
                        changed = 1;
                        break;
-               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;
-                       break;
-               case KT_redraw:
-                       clear();
-                       InitFields();
-//                     ScheduleFullRedraw();
-                       refresh();
-                       break;
-               case KT_quit:
-                       ShowPause(me);
-                       refresh();
-                       gameStatus = 0;
-                       break;
-               } //E_key
+               }
+
                if (dropMode && DropPiece(me) > 0) {
                        SetITimer(Game.speed, Game.speed);
                        if (spied) SendPacket(me, NP_drop, 0, NULL);