diff --git a/src/db.c b/src/db.c index 6bfa2db..ff181f2 100644 --- a/src/db.c +++ b/src/db.c @@ -1,3 +1,4 @@ +#include #include #include "db.h" @@ -5,8 +6,8 @@ sqlite3 *dbh = NULL; gboolean -wmud_db_init(void) +wmud_db_init(GError **err) { - sqlite3_open( + return FALSE; } diff --git a/src/db.h b/src/db.h index f380041..e11e70a 100644 --- a/src/db.h +++ b/src/db.h @@ -3,7 +3,9 @@ #include -gboolean wmud_db_init(Gerror ** error); +#include "wmud_types.h" + +gboolean wmud_db_init(GError **err); gboolean wmud_load_players(GError **err); gboolean wmud_save_player(wmudPlayer *player, GError **err); diff --git a/src/networking.c b/src/networking.c index 5c4189e..9b96355 100644 --- a/src/networking.c +++ b/src/networking.c @@ -281,3 +281,9 @@ wmud_client_send(wmudClient *client, const gchar *fmt, ...) g_string_free(buf, TRUE); } +void +wmud_client_start_login(wmudClient *client) +{ + g_print("Trying to login with playername '%s'\n", client->buffer->str); +} + diff --git a/src/networking.h b/src/networking.h index 361e6d2..7d7677b 100644 --- a/src/networking.h +++ b/src/networking.h @@ -2,26 +2,8 @@ # define __WMUD_NETWORKING_H__ #include -#include -typedef enum { - WMUD_CLIENT_STATE_FRESH, /* Newly connected clients. We are waiting for - * a player name */ - WMUD_CLIENT_STATE_PASSWAIT, /* Player name entered, waiting for password */ - WMUD_CLIENT_STATE_MENU, /* Logged in players, waiting in the main menu. - * We are waiting for a menu item to be - * chosen.*/ - WMUD_CLIENT_STATE_INGAME, /* Player is in-game */ - WMUD_CLIENT_STATE_QUITWAIT /* Waiting for answer for the quit question */ -} wmudClientState; - -typedef struct _wmudClient { - GSocket *socket; - GString *buffer; - wmudClientState state; - gboolean authenticated; - wmudPlayer *player; -} wmudClient; +#include "wmud_types.h" extern GSList *clients; diff --git a/src/players.h b/src/players.h index e844480..0ab6097 100644 --- a/src/players.h +++ b/src/players.h @@ -21,13 +21,7 @@ #include -#include "networking.h" - -typedef struct _wmudPlayer { - guint32 id; /* User ID */ - gchar *player_name; /* Player login name */ - gchar *cpassword; /* Crypted password */ -} wmudPlayer; +#include "wmud_types.h" gboolean wmud_player_auth(wmudClient *client); diff --git a/src/wmud_types.h b/src/wmud_types.h new file mode 100644 index 0000000..9f5e5a5 --- /dev/null +++ b/src/wmud_types.h @@ -0,0 +1,33 @@ +#ifndef __WMUD_TYPES_H__ +#define __WMUD_TYPES_H__ + +#include +#include + +typedef enum { + WMUD_CLIENT_STATE_FRESH, /* Newly connected clients. We are waiting for + * a player name */ + WMUD_CLIENT_STATE_PASSWAIT, /* Player name entered, waiting for password */ + WMUD_CLIENT_STATE_MENU, /* Logged in players, waiting in the main menu. + * We are waiting for a menu item to be + * chosen.*/ + WMUD_CLIENT_STATE_INGAME, /* Player is in-game */ + WMUD_CLIENT_STATE_QUITWAIT /* Waiting for answer for the quit question */ +} wmudClientState; + +typedef struct _wmudPlayer { + guint32 id; /* User ID */ + gchar *player_name; /* Player login name */ + gchar *cpassword; /* Crypted password */ +} wmudPlayer; + +typedef struct _wmudClient { + GSocket *socket; + GString *buffer; + wmudClientState state; + gboolean authenticated; + wmudPlayer *player; +} wmudClient; + +#endif /* __WMUD_TYPES_H__ */ +