diff --git a/wmud/game-networking.c b/wmud/game-networking.c index 90f6180..70c5526 100644 --- a/wmud/game-networking.c +++ b/wmud/game-networking.c @@ -53,12 +53,6 @@ struct AcceptData { */ GSList *clients = NULL; -/** - * game_menu: - * The list of menu items to display after a successful login - */ -static GSList *game_menu = NULL; - static GRegex *email_regex = NULL; void wmud_client_interpret_newplayer_email(wmudClient *client); @@ -99,13 +93,6 @@ wmud_client_close(wmudClient *client, gboolean send_goodbye) g_free(client); } -void -send_menu_item(wmudMenu *item, wmudClient *client) -{ - /* TODO: Send ANSI menu item only to ANSI players! */ - wmud_client_send(client, "%s\r\n", item->display_text_ansi); -} - /** * wmud_client_callback: * @client: the socket of the client on which the data arrived @@ -504,13 +491,7 @@ state_passwait(wmudClient *client) /* TODO: send MOTD */ wmud_text_send_to_client("motd", client); - - /* TODO: send menu items */ - - g_slist_foreach(game_menu, (GFunc)send_menu_item, client); - client->state = WMUD_CLIENT_STATE_MENU; - - /* TODO: send menu prologue */ + wmud_menu_present(client); } else { wmud_client_send(client, "%c%c%cThis password doesn't" " seem to be valid. Let's try it again..." diff --git a/wmud/menu.c b/wmud/menu.c index 0b6bdfc..07f3e28 100644 --- a/wmud/menu.c +++ b/wmud/menu.c @@ -36,6 +36,12 @@ GHashTable *mcmd_table = NULL; +/** + * game_menu: + * The list of menu items to display after a successful login + */ +GSList *game_menu = NULL; + GQuark wmud_menu_error_quark() { @@ -123,7 +129,7 @@ menu_item_prepare(wmudMenu *item, GHashTable *cmdtable) g_string_prepend_c(dsa, ' '); g_string_prepend_c(dsa, g_ascii_toupper(item->menuchar)); } - + g_string_insert_c(ds, found - item->text, '('); g_string_insert_c(ds, found - item->text + 2, ')'); @@ -279,3 +285,20 @@ wmud_menu_execute_command(wmudClient *client, gchar *command) else func(client); } + +void +send_menu_item(wmudMenu *item, wmudClient *client) +{ + /* TODO: Send ANSI menu item only to ANSI players! */ + wmud_client_send(client, "%s\r\n", item->display_text_ansi); +} + +void +wmud_menu_present(wmudClient *client) +{ + g_slist_foreach(game_menu, (GFunc)send_menu_item, client); + client->state = WMUD_CLIENT_STATE_MENU; + + /* TODO: send menu prologue */ +} + diff --git a/wmud/menu.h b/wmud/menu.h index bfcb052..47e0a7f 100644 --- a/wmud/menu.h +++ b/wmud/menu.h @@ -58,6 +58,8 @@ typedef void (*wmudMenuCommandFunc)(wmudClient *client); */ #define WMUD_MENU_COMMAND(name) void wmud_mcmd_ ## name(wmudClient *client) +GSList *game_menu; + #define WMUD_MENU_ERROR wmud_menu_error_quark() GQuark wmud_menu_error_quark(); gboolean wmud_menu_init(GSList **menu); @@ -65,6 +67,7 @@ gboolean wmud_menu_items_check(GSList *menu_items, GError **err); void wmud_menu_items_free(GSList **menu_items); gchar *wmud_menu_get_command_by_menuchar(gchar menuchar, GSList *game_menu); void wmud_menu_execute_command(wmudClient *client, gchar *command); +void wmud_menu_present(wmudClient *client); #endif /* __WMUD_MENU_H__ */