diff --git a/wmud/game-networking.c b/wmud/game-networking.c index ce609e4..6f0ca51 100644 --- a/wmud/game-networking.c +++ b/wmud/game-networking.c @@ -31,6 +31,7 @@ #include "players.h" #include "db.h" #include "configuration.h" +#include "menu.h" /** * SECTION:game-networking @@ -51,6 +52,12 @@ struct AcceptData { */ GSList *clients = NULL; +/** + * game_menu: + * The list of menu items to display after a successful login + */ +static GSList *game_menu = NULL; + void wmud_client_interpret_newplayer_email(wmudClient *client); void wmud_client_interpret_newplayer_mailconfirm(wmudClient *client); @@ -79,6 +86,12 @@ wmud_client_close(wmudClient *client, gboolean send_goodbye) g_free(client); } +void +send_menu_item(wmudMenu *item, wmudClient *client) +{ + wmud_client_send(client, "Item\r\n"); +} + /** * wmud_client_callback: * @client: the socket of the client on which the data arrived @@ -214,6 +227,7 @@ wmud_client_callback(GSocket *client_socket, GIOCondition condition, wmudClient client->state = WMUD_CLIENT_STATE_MENU; /* TODO: send MOTD */ /* TODO: send menu items */ + //g_slist_foreach(game_menu, (GFunc)send_menu_item, client); /* TODO: send menu prologue */ } else @@ -419,7 +433,7 @@ game_source_callback(GSocket *socket, GIOCondition condition, struct AcceptData * err is set accordingly (if not NULL) */ gboolean -wmud_networking_init(guint port_number, GMainContext *game_context, GError **err) +wmud_networking_init(guint port_number, GMainContext *game_context, GSList *menu_items, GError **err) { struct AcceptData *accept_data; GSocketListener *game_listener; @@ -524,6 +538,8 @@ wmud_networking_init(guint port_number, GMainContext *game_context, GError **err g_source_attach(game_net_source4, game_context); } + game_menu = menu_items; + return TRUE; } diff --git a/wmud/game-networking.h b/wmud/game-networking.h index a44b902..ac35ce6 100644 --- a/wmud/game-networking.h +++ b/wmud/game-networking.h @@ -62,7 +62,7 @@ extern GSList *clients; -gboolean wmud_networking_init(guint port_number, GMainContext *game_context, GError **err); +gboolean wmud_networking_init(guint port_number, GMainContext *game_context, GSList *menu_items, GError **err); void wmud_client_send(wmudClient *client, const gchar *fmt, ...); #endif diff --git a/wmud/main.c b/wmud/main.c index 3f1b1bd..1d4dfcc 100644 --- a/wmud/main.c +++ b/wmud/main.c @@ -190,12 +190,12 @@ main(int argc, char **argv) return 1; } - /* Initialization ends here */ + /* Non-thread initialization ends here */ - wmud_game_init(&game_thread, &game_context, game_menu); + wmud_game_init(&game_thread, &game_context); g_clear_error(&err); - if (!wmud_networking_init(active_config->port, game_context, &err)) + if (!wmud_networking_init(active_config->port, game_context, game_menu, &err)) { if (err) {