From 7fd61053aefee7ce6c081bc5d45874fd09d3a69d Mon Sep 17 00:00:00 2001 From: Polonkai Gergely Date: Thu, 17 May 2012 16:54:16 +0000 Subject: [PATCH] Added the menu function quit Signed-off-by: Gergely POLONKAI (W00d5t0ck) --- wmud/game-networking.c | 14 ++++++++++++++ wmud/game-networking.h | 1 + wmud/interpreter.c | 3 ++- wmud/menu.c | 2 ++ 4 files changed, 19 insertions(+), 1 deletion(-) diff --git a/wmud/game-networking.c b/wmud/game-networking.c index b36176d..1d83c9b 100644 --- a/wmud/game-networking.c +++ b/wmud/game-networking.c @@ -591,3 +591,17 @@ wmud_client_send(wmudClient *client, const gchar *fmt, ...) g_string_free(buf, TRUE); } +void +wmud_client_quitanswer(wmudClient *client, gboolean answer) +{ + if (answer) + { + wmud_client_send(client, "Borgo sad... :(\r\n"); + wmud_client_close(client, TRUE); + } + else + { + wmud_client_send(client, "Good boy!\r\n"); + client->state = WMUD_CLIENT_STATE_MENU; + } +} diff --git a/wmud/game-networking.h b/wmud/game-networking.h index ac35ce6..f710ae6 100644 --- a/wmud/game-networking.h +++ b/wmud/game-networking.h @@ -64,5 +64,6 @@ extern GSList *clients; gboolean wmud_networking_init(guint port_number, GMainContext *game_context, GSList *menu_items, GError **err); void wmud_client_send(wmudClient *client, const gchar *fmt, ...); +void wmud_client_quitanswer(wmudClient *client, gboolean answer); #endif diff --git a/wmud/interpreter.c b/wmud/interpreter.c index a41c6fa..55d1818 100644 --- a/wmud/interpreter.c +++ b/wmud/interpreter.c @@ -302,6 +302,7 @@ wmud_interpret_game_command(wmudClient *client) WMUD_COMMAND(quit) { wmud_client_send(client, "Are you sure you want to get back to that freaky other reality? [y/N] "); - client->state = WMUD_CLIENT_STATE_QUITWAIT; + client->state = WMUD_CLIENT_STATE_YESNO; + client->yesNoCallback = wmud_client_quitanswer; } diff --git a/wmud/menu.c b/wmud/menu.c index 5669130..72a0041 100644 --- a/wmud/menu.c +++ b/wmud/menu.c @@ -183,7 +183,9 @@ WMUD_MENU_COMMAND(change_name) WMUD_MENU_COMMAND(quit) { + client->state = WMUD_CLIENT_STATE_YESNO; wmud_client_send(client, "Are you sure you want to get back to the real world? [y/N] "); + client->yesNoCallback = wmud_client_quitanswer; } WMUD_MENU_COMMAND(redisplay_menu)