diff --git a/wmud/Makefile.am b/wmud/Makefile.am index 76f3325..068d9b6 100644 --- a/wmud/Makefile.am +++ b/wmud/Makefile.am @@ -1,5 +1,5 @@ bin_PROGRAMS = wmud AM_CPPFLAGS = -DWMUD_STATEDIR=\""$(localstatedir)"\" -DWMUD_CONFDIR=\""$(sysconfdir)"\" $(MEMCACHED_CFLAGS) $(GLIB_CFLAGS) $(GIO_CFLAGS) $(GTHREAD_CFLAGS) $(SQLITE3_CFLAGS) $(CURL_CFLAGS) -wmud_SOURCES = main.c game-networking.c interpreter.c db.c players.c maintenance.c game.c configuration.c world.c menu.c texts.c wmudclient.c wmudplayer.c +wmud_SOURCES = main.c game-networking.c interpreter.c db.c players.c maintenance.c game.c configuration.c world.c menu.c texts.c wmudclient.c wmudplayer.c wmudclientstate.c wmud_LDADD = $(MEMCACHED_LIBS) $(GLIB_LIBS) $(GIO_LIBS) $(GTHREAD_LIBS) $(SQLITE3_LIBS) $(CURL_LIBS) diff --git a/wmud/wmudclient.c b/wmud/wmudclient.c index 9614647..0e5fb9d 100644 --- a/wmud/wmudclient.c +++ b/wmud/wmudclient.c @@ -18,6 +18,7 @@ */ #include "wmudclient.h" +#include "wmudclientstate.h" #include "players.h" /** diff --git a/wmud/wmudclient.h b/wmud/wmudclient.h index ee22fc6..81ded4f 100644 --- a/wmud/wmudclient.h +++ b/wmud/wmudclient.h @@ -22,6 +22,7 @@ #include #include #include +#include "wmudclientstate.h" #include "wmudplayer.h" #define WMUD_TYPE_CLIENT (wmud_client_get_type()) @@ -54,39 +55,6 @@ struct _WmudClientClass GObjectClass parent_class; }; -/** - * WmudClientState: - * @WMUD_CLIENT_STATE_FRESH: Client is newly connected. Waiting for a login - * player name - * @WMUD_CLIENT_STATE_PASSWAIT: Login player name is entered, waiting for a - * login password - * @WMUD_CLIENT_STATE_MENU: Authentication was successful, player is now in the - * main game menu - * @WMUD_CLIENT_STATE_INGAME: Character login was successful, player is now - * in-game - * @WMUD_CLIENT_STATE_YESNO: Player was asked a yes/no question, and we are - * waiting for the answer. client.yesNoCallback MUST be set at this point! - * TODO: if wmudClient had a prevState field, and there would be some hooks - * that are called before and after the client enters a new state, this - * could be a three-state stuff, in which the player can enter e.g ? as - * the answer, so they would be presented with the question again. - * @WMUD_CLIENT_STATE_REGISTERING: Registering a new player. Waiting for the - * e-mail address to be given - * @WMUD_CLIENT_STATE_REGEMAIL_CONFIRM: E-mail address entered séms valid, - * waiting for confirmation - * - * Game client states. - */ -typedef enum { - WMUD_CLIENT_STATE_FRESH, - WMUD_CLIENT_STATE_PASSWAIT, - WMUD_CLIENT_STATE_MENU, - WMUD_CLIENT_STATE_INGAME, - WMUD_CLIENT_STATE_YESNO, - WMUD_CLIENT_STATE_REGISTERING, - WMUD_CLIENT_STATE_REGEMAIL_CONFIRM -} WmudClientState; - GType wmud_client_get_type(void); WmudClient *wmud_client_new(void); void wmud_client_set_socket(WmudClient *client, GSocket *socket); diff --git a/wmud/wmudclientstate.c b/wmud/wmudclientstate.c new file mode 100644 index 0000000..595dc07 --- /dev/null +++ b/wmud/wmudclientstate.c @@ -0,0 +1,25 @@ +#include "wmudclientstate.h" + +GType +wmud_client_state_get_type (void) +{ + static volatile gsize g_define_type_id__volatile = 0; + + if (g_once_init_enter(&g_define_type_id__volatile)) { + static const GEnumValue values[] = { + { WMUD_CLIENT_STATE_FRESH, "WMUD_CLIENT_STATE_FRESH", "fresh" }, + { WMUD_CLIENT_STATE_PASSWAIT, "WMUD_CLIENT_STATE_PASSWAIT", "passwait" }, + { WMUD_CLIENT_STATE_MENU, "WMUD_CLIENT_STATE_MENU", "menu" }, + { WMUD_CLIENT_STATE_INGAME, "WMUD_CLIENT_STATE_INGAME", "ingame" }, + { WMUD_CLIENT_STATE_YESNO, "WMUD_CLIENT_STATE_YESNO", "yesno" }, + { WMUD_CLIENT_STATE_REGISTERING, "WMUD_CLIENT_STATE_REGISTERING", "registering" }, + { WMUD_CLIENT_STATE_REGEMAIL_CONFIRM, "WMUD_CLIENT_STATE_REGEMAIL_CONFIRM", "regemail-confirm" }, + { 0, NULL, NULL } + }; + GType g_define_type_id = g_enum_register_static(g_intern_static_string("WmudClientState"), values); + g_once_init_leave(&g_define_type_id__volatile, g_define_type_id); + } + + return g_define_type_id__volatile; +} + diff --git a/wmud/wmudclientstate.h b/wmud/wmudclientstate.h new file mode 100644 index 0000000..1d3a804 --- /dev/null +++ b/wmud/wmudclientstate.h @@ -0,0 +1,44 @@ +#ifndef __WMUD_CLIENT_STATE_H__ +#define __WMUD_CLIENT_STATE_H__ + +#include + +/** + * WmudClientState: + * @WMUD_CLIENT_STATE_FRESH: Client is newly connected. Waiting for a login + * player name + * @WMUD_CLIENT_STATE_PASSWAIT: Login player name is entered, waiting for a + * login password + * @WMUD_CLIENT_STATE_MENU: Authentication was successful, player is now in the + * main game menu + * @WMUD_CLIENT_STATE_INGAME: Character login was successful, player is now + * in-game + * @WMUD_CLIENT_STATE_YESNO: Player was asked a yes/no question, and we are + * waiting for the answer. client.yesNoCallback MUST be set at this point! + * TODO: if wmudClient had a prevState field, and there would be some hooks + * that are called before and after the client enters a new state, this + * could be a three-state stuff, in which the player can enter e.g ? as + * the answer, so they would be presented with the question again. + * @WMUD_CLIENT_STATE_REGISTERING: Registering a new player. Waiting for the + * e-mail address to be given + * @WMUD_CLIENT_STATE_REGEMAIL_CONFIRM: E-mail address entered séms valid, + * waiting for confirmation + * + * Game client states. + */ +typedef enum { + WMUD_CLIENT_STATE_FRESH, + WMUD_CLIENT_STATE_PASSWAIT, + WMUD_CLIENT_STATE_MENU, + WMUD_CLIENT_STATE_INGAME, + WMUD_CLIENT_STATE_YESNO, + WMUD_CLIENT_STATE_REGISTERING, + WMUD_CLIENT_STATE_REGEMAIL_CONFIRM +} WmudClientState; + + +GType wmud_client_state_get_type (void) G_GNUC_CONST; +#define WMUD_TYPE_CLIENT_STATE (wmud_client_state_get_type()) + +#endif /* __WMUD_CLIENT_STATE_H__ */ +