Refactored WmudClientState into a separate file
For GType'isation
This commit is contained in:
parent
2add2d6179
commit
e9067920da
@ -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)
|
||||
|
@ -18,6 +18,7 @@
|
||||
*/
|
||||
|
||||
#include "wmudclient.h"
|
||||
#include "wmudclientstate.h"
|
||||
#include "players.h"
|
||||
|
||||
/**
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include <glib-object.h>
|
||||
#include <glib.h>
|
||||
#include <gio/gio.h>
|
||||
#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);
|
||||
|
25
wmud/wmudclientstate.c
Normal file
25
wmud/wmudclientstate.c
Normal file
@ -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;
|
||||
}
|
||||
|
44
wmud/wmudclientstate.h
Normal file
44
wmud/wmudclientstate.h
Normal file
@ -0,0 +1,44 @@
|
||||
#ifndef __WMUD_CLIENT_STATE_H__
|
||||
#define __WMUD_CLIENT_STATE_H__
|
||||
|
||||
#include <glib-object.h>
|
||||
|
||||
/**
|
||||
* 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__ */
|
||||
|
Loading…
Reference in New Issue
Block a user