Refactored menu sending to a separate function
This commit is contained in:
parent
d87a26dbe1
commit
c2c14d107b
@ -53,12 +53,6 @@ struct AcceptData {
|
|||||||
*/
|
*/
|
||||||
GSList *clients = NULL;
|
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;
|
static GRegex *email_regex = NULL;
|
||||||
|
|
||||||
void wmud_client_interpret_newplayer_email(wmudClient *client);
|
void wmud_client_interpret_newplayer_email(wmudClient *client);
|
||||||
@ -99,13 +93,6 @@ wmud_client_close(wmudClient *client, gboolean send_goodbye)
|
|||||||
g_free(client);
|
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:
|
* wmud_client_callback:
|
||||||
* @client: the socket of the client on which the data arrived
|
* @client: the socket of the client on which the data arrived
|
||||||
@ -504,13 +491,7 @@ state_passwait(wmudClient *client)
|
|||||||
/* TODO: send MOTD */
|
/* TODO: send MOTD */
|
||||||
|
|
||||||
wmud_text_send_to_client("motd", client);
|
wmud_text_send_to_client("motd", client);
|
||||||
|
wmud_menu_present(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 */
|
|
||||||
} else {
|
} else {
|
||||||
wmud_client_send(client, "%c%c%cThis password doesn't"
|
wmud_client_send(client, "%c%c%cThis password doesn't"
|
||||||
" seem to be valid. Let's try it again..."
|
" seem to be valid. Let's try it again..."
|
||||||
|
23
wmud/menu.c
23
wmud/menu.c
@ -36,6 +36,12 @@
|
|||||||
|
|
||||||
GHashTable *mcmd_table = NULL;
|
GHashTable *mcmd_table = NULL;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* game_menu:
|
||||||
|
* The list of menu items to display after a successful login
|
||||||
|
*/
|
||||||
|
GSList *game_menu = NULL;
|
||||||
|
|
||||||
GQuark
|
GQuark
|
||||||
wmud_menu_error_quark()
|
wmud_menu_error_quark()
|
||||||
{
|
{
|
||||||
@ -279,3 +285,20 @@ wmud_menu_execute_command(wmudClient *client, gchar *command)
|
|||||||
else
|
else
|
||||||
func(client);
|
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 */
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -58,6 +58,8 @@ typedef void (*wmudMenuCommandFunc)(wmudClient *client);
|
|||||||
*/
|
*/
|
||||||
#define WMUD_MENU_COMMAND(name) void wmud_mcmd_ ## name(wmudClient *client)
|
#define WMUD_MENU_COMMAND(name) void wmud_mcmd_ ## name(wmudClient *client)
|
||||||
|
|
||||||
|
GSList *game_menu;
|
||||||
|
|
||||||
#define WMUD_MENU_ERROR wmud_menu_error_quark()
|
#define WMUD_MENU_ERROR wmud_menu_error_quark()
|
||||||
GQuark wmud_menu_error_quark();
|
GQuark wmud_menu_error_quark();
|
||||||
gboolean wmud_menu_init(GSList **menu);
|
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);
|
void wmud_menu_items_free(GSList **menu_items);
|
||||||
gchar *wmud_menu_get_command_by_menuchar(gchar menuchar, GSList *game_menu);
|
gchar *wmud_menu_get_command_by_menuchar(gchar menuchar, GSList *game_menu);
|
||||||
void wmud_menu_execute_command(wmudClient *client, gchar *command);
|
void wmud_menu_execute_command(wmudClient *client, gchar *command);
|
||||||
|
void wmud_menu_present(wmudClient *client);
|
||||||
|
|
||||||
#endif /* __WMUD_MENU_H__ */
|
#endif /* __WMUD_MENU_H__ */
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user