Added game_menu variable. Started implementing menu-item sending.

This commit is contained in:
Polonkai Gergely 2012-04-06 08:31:08 +00:00
parent 3a1d9ff266
commit ae38341601
3 changed files with 21 additions and 5 deletions

View File

@ -31,6 +31,7 @@
#include "players.h" #include "players.h"
#include "db.h" #include "db.h"
#include "configuration.h" #include "configuration.h"
#include "menu.h"
/** /**
* SECTION:game-networking * SECTION:game-networking
@ -51,6 +52,12 @@ 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;
void wmud_client_interpret_newplayer_email(wmudClient *client); void wmud_client_interpret_newplayer_email(wmudClient *client);
void wmud_client_interpret_newplayer_mailconfirm(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); g_free(client);
} }
void
send_menu_item(wmudMenu *item, wmudClient *client)
{
wmud_client_send(client, "Item\r\n");
}
/** /**
* 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
@ -214,6 +227,7 @@ wmud_client_callback(GSocket *client_socket, GIOCondition condition, wmudClient
client->state = WMUD_CLIENT_STATE_MENU; client->state = WMUD_CLIENT_STATE_MENU;
/* TODO: send MOTD */ /* TODO: send MOTD */
/* TODO: send menu items */ /* TODO: send menu items */
//g_slist_foreach(game_menu, (GFunc)send_menu_item, client);
/* TODO: send menu prologue */ /* TODO: send menu prologue */
} }
else else
@ -419,7 +433,7 @@ game_source_callback(GSocket *socket, GIOCondition condition, struct AcceptData
* err is set accordingly (if not NULL) * err is set accordingly (if not NULL)
*/ */
gboolean 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; struct AcceptData *accept_data;
GSocketListener *game_listener; 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); g_source_attach(game_net_source4, game_context);
} }
game_menu = menu_items;
return TRUE; return TRUE;
} }

View File

@ -62,7 +62,7 @@
extern GSList *clients; 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, ...); void wmud_client_send(wmudClient *client, const gchar *fmt, ...);
#endif #endif

View File

@ -190,12 +190,12 @@ main(int argc, char **argv)
return 1; 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); 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) if (err)
{ {