Minor modifications and code cleaning
* Created a wmud_types.h file to hold all the basic data types used by wMUD * Redefined wmud_db_init() so error reporting will be possible
This commit is contained in:
parent
71ffb83626
commit
63c37a8791
5
src/db.c
5
src/db.c
@ -1,3 +1,4 @@
|
|||||||
|
#include <glib.h>
|
||||||
#include <sqlite3.h>
|
#include <sqlite3.h>
|
||||||
|
|
||||||
#include "db.h"
|
#include "db.h"
|
||||||
@ -5,8 +6,8 @@
|
|||||||
sqlite3 *dbh = NULL;
|
sqlite3 *dbh = NULL;
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
wmud_db_init(void)
|
wmud_db_init(GError **err)
|
||||||
{
|
{
|
||||||
sqlite3_open(
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
4
src/db.h
4
src/db.h
@ -3,7 +3,9 @@
|
|||||||
|
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
|
|
||||||
gboolean wmud_db_init(Gerror ** error);
|
#include "wmud_types.h"
|
||||||
|
|
||||||
|
gboolean wmud_db_init(GError **err);
|
||||||
gboolean wmud_load_players(GError **err);
|
gboolean wmud_load_players(GError **err);
|
||||||
gboolean wmud_save_player(wmudPlayer *player, GError **err);
|
gboolean wmud_save_player(wmudPlayer *player, GError **err);
|
||||||
|
|
||||||
|
@ -281,3 +281,9 @@ wmud_client_send(wmudClient *client, const gchar *fmt, ...)
|
|||||||
g_string_free(buf, TRUE);
|
g_string_free(buf, TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
wmud_client_start_login(wmudClient *client)
|
||||||
|
{
|
||||||
|
g_print("Trying to login with playername '%s'\n", client->buffer->str);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -2,26 +2,8 @@
|
|||||||
# define __WMUD_NETWORKING_H__
|
# define __WMUD_NETWORKING_H__
|
||||||
|
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
#include <gio/gio.h>
|
|
||||||
|
|
||||||
typedef enum {
|
#include "wmud_types.h"
|
||||||
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;
|
|
||||||
|
|
||||||
extern GSList *clients;
|
extern GSList *clients;
|
||||||
|
|
||||||
|
@ -21,13 +21,7 @@
|
|||||||
|
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
|
|
||||||
#include "networking.h"
|
#include "wmud_types.h"
|
||||||
|
|
||||||
typedef struct _wmudPlayer {
|
|
||||||
guint32 id; /* User ID */
|
|
||||||
gchar *player_name; /* Player login name */
|
|
||||||
gchar *cpassword; /* Crypted password */
|
|
||||||
} wmudPlayer;
|
|
||||||
|
|
||||||
gboolean wmud_player_auth(wmudClient *client);
|
gboolean wmud_player_auth(wmudClient *client);
|
||||||
|
|
||||||
|
33
src/wmud_types.h
Normal file
33
src/wmud_types.h
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
#ifndef __WMUD_TYPES_H__
|
||||||
|
#define __WMUD_TYPES_H__
|
||||||
|
|
||||||
|
#include <glib.h>
|
||||||
|
#include <gio/gio.h>
|
||||||
|
|
||||||
|
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__ */
|
||||||
|
|
Loading…
Reference in New Issue
Block a user