From a88dab379119d15516514e553cac8766cbb54223 Mon Sep 17 00:00:00 2001 From: Mischa POSLAWSKY Date: Sun, 4 Mar 2007 13:36:38 +0100 Subject: [PATCH] quit and pause commands Replace direct actions by key. --- client.c | 40 +++++++++++++++++++++++----------------- 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/client.c b/client.c index 0974c22..9c228d8 100644 --- 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; -- 2.30.0