static char keyTable[KT_numKeys+1];
enum {
+ CT_quit, CT_pause,
CT_MAX
};
static char *cmds[] = {
+ "quit", "pause"
};
static char *hostStr;
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;
}
}
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;