Finish uncrustifying

This commit is contained in:
Gergely Polonkai 2016-06-22 18:26:02 +02:00
parent bdf518f37f
commit 9bded1b722
13 changed files with 186 additions and 142 deletions

View File

@ -55,18 +55,19 @@ typedef enum {
* @smtp_sender: the sender address who sends the outgoing mails * @smtp_sender: the sender address who sends the outgoing mails
*/ */
typedef struct _ConfigData { typedef struct _ConfigData {
guint port; guint port;
gchar *database_dsn; gchar *database_dsn;
gchar *admin_email; gchar *admin_email;
gchar *smtp_server; gchar *smtp_server;
gboolean smtp_tls; gboolean smtp_tls;
gchar *smtp_username; gchar *smtp_username;
gchar *smtp_password; gchar *smtp_password;
gchar *smtp_sender; gchar *smtp_sender;
} ConfigData; } ConfigData;
extern ConfigData *active_config; extern ConfigData *active_config;
gboolean wmud_config_init(ConfigData **config_data, GError **err); gboolean wmud_config_init(ConfigData **config_data,
GError **err);
#endif /* __WMUD_CONFIGURATION_H__ */ #endif /* __WMUD_CONFIGURATION_H__ */

View File

@ -35,24 +35,34 @@ GQuark wmud_db_error_quark();
* Error codes returned by database handling functions. * Error codes returned by database handling functions.
*/ */
typedef enum { typedef enum {
WMUD_DB_ERROR_CANTOPEN, WMUD_DB_ERROR_CANTOPEN,
WMUD_DB_ERROR_NOINIT, WMUD_DB_ERROR_NOINIT,
WMUD_DB_ERROR_BADQUERY, WMUD_DB_ERROR_BADQUERY,
WMUD_DB_ERROR_SELECT_ERROR WMUD_DB_ERROR_SELECT_ERROR
} wmudDbError; } wmudDbError;
gboolean wmud_db_init(GError **err); gboolean wmud_db_init(GError **err);
gboolean wmud_db_load_players(GError **err); gboolean wmud_db_load_players(GError **err);
gboolean wmud_db_save_player(WmudPlayer *player, GError **err); gboolean wmud_db_save_player(WmudPlayer *player,
gboolean wmud_db_load_planes(GSList **planes, GError **err); GError **err);
gboolean wmud_db_load_planets(GSList **planets, GError **err); gboolean wmud_db_load_planes(GSList **planes,
gboolean wmud_db_load_directions(GSList **directions, GError **err); GError **err);
gboolean wmud_db_load_areas(GSList **areas, GError **err); gboolean wmud_db_load_planets(GSList **planets,
gboolean wmud_db_load_rooms(GSList **rooms, GError **err); GError **err);
gboolean wmud_db_load_exits(GSList **exits, GError **err); gboolean wmud_db_load_directions(GSList **directions,
gboolean wmud_db_load_planet_planes(GSList **planet_planes, GError **err); GError **err);
gboolean wmud_db_load_menu(GSList **menu_items, GError **err); gboolean wmud_db_load_areas(GSList **areas,
gboolean wmud_db_update_player_password(WmudPlayer *player, gchar *crypted_password, GError **err); GError **err);
gboolean wmud_db_load_rooms(GSList **rooms,
GError **err);
gboolean wmud_db_load_exits(GSList **exits,
GError **err);
gboolean wmud_db_load_planet_planes(GSList **planet_planes,
GError **err);
gboolean wmud_db_load_menu(GSList **menu_items,
GError **err);
gboolean wmud_db_update_player_password(WmudPlayer *player,
gchar *crypted_password,
GError **err);
#endif /* __WMUD__DB_H__ */ #endif /* __WMUD__DB_H__ */

View File

@ -62,8 +62,13 @@
extern GSList *clients; extern GSList *clients;
gboolean wmud_networking_init(guint port_number, GMainContext *game_context, GSList *menu_items, GError **err); gboolean wmud_networking_init(guint port_number,
void wmud_client_quitanswer(WmudClient *client, gboolean answer); GMainContext *game_context,
void wmud_client_newchar_answer(WmudClient *client, gboolean answer); GSList *menu_items,
GError **err);
void wmud_client_quitanswer(WmudClient *client,
gboolean answer);
void wmud_client_newchar_answer(WmudClient *client,
gboolean answer);
#endif #endif

View File

@ -19,7 +19,7 @@
#ifndef __WMUD_GAME_H__ #ifndef __WMUD_GAME_H__
#define __WMUD_GAME_H__ #define __WMUD_GAME_H__
gboolean wmud_game_init(GThread **game_thread, GMainContext **game_context); gboolean wmud_game_init(GThread **game_thread,
GMainContext **game_context);
#endif /* __WMUD_GAME_H__ */ #endif /* __WMUD_GAME_H__ */

View File

@ -47,19 +47,19 @@ typedef void (*wmudCommandFunc)(WmudClient *client, gchar *command, GSList *toke
* This structure holds the different properties of the in-game commands. * This structure holds the different properties of the in-game commands.
*/ */
typedef struct _wmudCommand { typedef struct _wmudCommand {
gchar *command; gchar *command;
wmudCommandFunc commandFunc; wmudCommandFunc commandFunc;
} wmudCommand; } wmudCommand;
#define WMUD_INTERPRETER_ERROR wmud_interpreter_error_quark() #define WMUD_INTERPRETER_ERROR wmud_interpreter_error_quark()
GQuark wmud_interpreter_error_quark(); GQuark wmud_interpreter_error_quark();
typedef enum { typedef enum {
WMUD_INTERPRETER_ERROR_DUPCMD WMUD_INTERPRETER_ERROR_DUPCMD
} wmudInterpreterError; } wmudInterpreterError;
gboolean wmud_interpreter_check_directions(GSList *directions, GError **err); gboolean wmud_interpreter_check_directions(GSList *directions,
GError **err);
void wmud_interpret_game_command(WmudClient *client); void wmud_interpret_game_command(WmudClient *client);
#endif /* __WMUD_INTERPRETER_H__ */ #endif /* __WMUD_INTERPRETER_H__ */

View File

@ -22,7 +22,7 @@
# include <glib.h> # include <glib.h>
extern GMainContext *game_context; extern GMainContext *game_context;
extern guint32 elapsed_seconds; extern guint32 elapsed_seconds;
/** /**
* random_number: * random_number:

View File

@ -39,14 +39,14 @@
* @func: the menu item's function. See menu.c for the list of possible values. * @func: the menu item's function. See menu.c for the list of possible values.
*/ */
typedef struct _wmudMenu { typedef struct _wmudMenu {
guint id; guint id;
gchar menuchar; gchar menuchar;
gboolean need_active_char; gboolean need_active_char;
guint placement; guint placement;
gchar *text; gchar *text;
gchar *display_text; gchar *display_text;
gchar *display_text_ansi; gchar *display_text_ansi;
gchar *func; gchar *func;
} wmudMenu; } wmudMenu;
typedef void (*wmudMenuCommandFunc)(WmudClient *client); typedef void (*wmudMenuCommandFunc)(WmudClient *client);
@ -63,10 +63,13 @@ GSList *game_menu;
#define WMUD_MENU_ERROR wmud_menu_error_quark() #define WMUD_MENU_ERROR wmud_menu_error_quark()
GQuark wmud_menu_error_quark(); GQuark wmud_menu_error_quark();
gboolean wmud_menu_init(GSList **menu); gboolean wmud_menu_init(GSList **menu);
gboolean wmud_menu_items_check(GSList *menu_items, GError **err); gboolean wmud_menu_items_check(GSList *menu_items,
GError **err);
void wmud_menu_items_free(GSList **menu_items); void wmud_menu_items_free(GSList **menu_items);
gchar *wmud_menu_get_command_by_menuchar(gchar menuchar, GSList *game_menu); gchar *wmud_menu_get_command_by_menuchar(gchar menuchar,
void wmud_menu_execute_command(WmudClient *client, gchar *command); GSList *game_menu);
void wmud_menu_execute_command(WmudClient *client,
gchar *command);
void wmud_menu_present(WmudClient *client); void wmud_menu_present(WmudClient *client);
#endif /* __WMUD_MENU_H__ */ #endif /* __WMUD_MENU_H__ */

View File

@ -22,6 +22,7 @@
#include "wmudclient.h" #include "wmudclient.h"
void wmud_texts_init(void); void wmud_texts_init(void);
void wmud_text_send_to_client(gchar *text, WmudClient *client); void wmud_text_send_to_client(gchar *text,
WmudClient *client);
#endif /* __WMUD_TEXTS_H__ */ #endif /* __WMUD_TEXTS_H__ */

View File

@ -37,8 +37,8 @@
* *
* A connected game client * A connected game client
*/ */
typedef struct _WmudClient WmudClient; typedef struct _WmudClient WmudClient;
typedef struct _WmudClientClass WmudClientClass; typedef struct _WmudClientClass WmudClientClass;
typedef struct _WmudClientPrivate WmudClientPrivate; typedef struct _WmudClientPrivate WmudClientPrivate;
/** /**
@ -50,39 +50,47 @@ typedef struct _WmudClientPrivate WmudClientPrivate;
*/ */
typedef void (*WmudClientYesnoCallback)(WmudClient *client, gboolean answer); typedef void (*WmudClientYesnoCallback)(WmudClient *client, gboolean answer);
struct _WmudClient struct _WmudClient {
{ /*< private >*/
/*< private >*/ GObject parent_instance;
GObject parent_instance; WmudClientPrivate *priv;
WmudClientPrivate *priv;
}; };
struct _WmudClientClass struct _WmudClientClass {
{ GObjectClass parent_class;
GObjectClass parent_class;
}; };
GType wmud_client_get_type(void); GType wmud_client_get_type(void);
WmudClient *wmud_client_new(void); WmudClient *wmud_client_new(void);
void wmud_client_set_socket(WmudClient *client, GSocket *socket); void wmud_client_set_socket(WmudClient *client,
GSocket *socket);
GSocket *wmud_client_get_socket(WmudClient *client); GSocket *wmud_client_get_socket(WmudClient *client);
GSource *wmud_client_get_socket_source(WmudClient *client); GSource *wmud_client_get_socket_source(WmudClient *client);
void wmud_client_send(WmudClient *client, const gchar *fmt, ...); void wmud_client_send(WmudClient *client,
void wmud_client_close(WmudClient *self, gboolean send_goodbye); const gchar *fmt,
...);
void wmud_client_close(WmudClient *self,
gboolean send_goodbye);
GString *wmud_client_get_buffer(WmudClient *client); GString *wmud_client_get_buffer(WmudClient *client);
gsize wmud_client_get_buffer_length(WmudClient *client); gsize wmud_client_get_buffer_length(WmudClient *client);
void wmud_client_set_state(WmudClient *client, WmudClientState state); void wmud_client_set_state(WmudClient *client,
WmudClientState state);
WmudClientState wmud_client_get_state(WmudClient *client); WmudClientState wmud_client_get_state(WmudClient *client);
void wmud_client_set_player(WmudClient *client, WmudPlayer *player); void wmud_client_set_player(WmudClient *client,
WmudPlayer *player);
WmudPlayer *wmud_client_get_player(WmudClient *client); WmudPlayer *wmud_client_get_player(WmudClient *client);
void wmud_client_set_yesno_callback(WmudClient *client, WmudClientYesnoCallback yesno_callback); void wmud_client_set_yesno_callback(WmudClient *client,
WmudClientYesnoCallback yesno_callback);
WmudClientYesnoCallback wmud_client_get_yesno_callback(WmudClient *client); WmudClientYesnoCallback wmud_client_get_yesno_callback(WmudClient *client);
void wmud_client_set_authenticated(WmudClient *client, gboolean authenticated); void wmud_client_set_authenticated(WmudClient *client,
gboolean authenticated);
void wmud_client_increase_login_fail_count(WmudClient *client); void wmud_client_increase_login_fail_count(WmudClient *client);
gint wmud_client_get_login_fail_count(WmudClient *client); gint wmud_client_get_login_fail_count(WmudClient *client);
void wmud_client_set_bademail(WmudClient *client, gboolean bademail); void wmud_client_set_bademail(WmudClient *client,
gboolean bademail);
gboolean wmud_client_get_bademail(WmudClient *client); gboolean wmud_client_get_bademail(WmudClient *client);
guint32 wmud_client_get_last_recv_age(WmudClient *client); guint32 wmud_client_get_last_recv_age(WmudClient *client);
void wmud_client_set_context(WmudClient *client, GMainContext *context); void wmud_client_set_context(WmudClient *client,
GMainContext *context);
#endif /* __WMUD_WMUDCLIENT_H__ */ #endif /* __WMUD_WMUDCLIENT_H__ */

View File

@ -27,14 +27,13 @@
* Game client states. * Game client states.
*/ */
typedef enum { typedef enum {
WMUD_CLIENT_STATE_FRESH, WMUD_CLIENT_STATE_FRESH,
WMUD_CLIENT_STATE_PASSWAIT, WMUD_CLIENT_STATE_PASSWAIT,
WMUD_CLIENT_STATE_MENU, WMUD_CLIENT_STATE_MENU,
WMUD_CLIENT_STATE_INGAME, WMUD_CLIENT_STATE_INGAME,
WMUD_CLIENT_STATE_YESNO, WMUD_CLIENT_STATE_YESNO,
WMUD_CLIENT_STATE_REGISTERING, WMUD_CLIENT_STATE_REGISTERING,
WMUD_CLIENT_STATE_REGEMAIL_CONFIRM WMUD_CLIENT_STATE_REGEMAIL_CONFIRM
} WmudClientState; } WmudClientState;
#endif /* __WMUD_CLIENT_STATE_H__ */ #endif /* __WMUD_CLIENT_STATE_H__ */

View File

@ -30,41 +30,44 @@
#define WMUD_IS_PLAYER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), WMUD_TYPE_PLAYER)) #define WMUD_IS_PLAYER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), WMUD_TYPE_PLAYER))
#define WMUD_PLAYER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), WMUT_TYPE_PLAYER, WmudPlayerClass)) #define WMUD_PLAYER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), WMUT_TYPE_PLAYER, WmudPlayerClass))
typedef struct _WmudPlayer WmudPlayer; typedef struct _WmudPlayer WmudPlayer;
typedef struct _WmudPlayerClass WmudPlayerClass; typedef struct _WmudPlayerClass WmudPlayerClass;
typedef struct _WmudPlayerPrivate WmudPlayerPrivate; typedef struct _WmudPlayerPrivate WmudPlayerPrivate;
struct _WmudPlayer struct _WmudPlayer {
{ /*< private >*/
/*< private >*/ GObject parent_instance;
GObject parent_instance;
/*< private >*/ /*< private >*/
WmudPlayerPrivate *priv; WmudPlayerPrivate *priv;
}; };
struct _WmudPlayerClass struct _WmudPlayerClass {
{ GObjectClass parent_class;
GObjectClass parent_class;
}; };
GType wmud_player_get_type(void); GType wmud_player_get_type(void);
WmudPlayer *wmud_player_new(void); WmudPlayer *wmud_player_new(void);
void wmud_player_set_cpassword(WmudPlayer *player, const gchar *cpassword); void wmud_player_set_cpassword(WmudPlayer *player,
const gchar *cpassword);
gchar *wmud_player_get_cpassword(WmudPlayer *player); gchar *wmud_player_get_cpassword(WmudPlayer *player);
void wmud_player_set_registered(WmudPlayer *player, gboolean registered); void wmud_player_set_registered(WmudPlayer *player,
gboolean registered);
gboolean wmud_player_get_registered(WmudPlayer *player); gboolean wmud_player_get_registered(WmudPlayer *player);
void wmud_player_set_player_name(WmudPlayer *player, const gchar *name); void wmud_player_set_player_name(WmudPlayer *player,
const gchar *name);
gchar *wmud_player_get_player_name(WmudPlayer *player); gchar *wmud_player_get_player_name(WmudPlayer *player);
gint wmud_player_get_fail_count(WmudPlayer *player); gint wmud_player_get_fail_count(WmudPlayer *player);
void wmud_player_increase_fail_count(WmudPlayer *player); void wmud_player_increase_fail_count(WmudPlayer *player);
void wmud_player_reset_fail_count(WmudPlayer *player); void wmud_player_reset_fail_count(WmudPlayer *player);
void wmud_player_set_email(WmudPlayer *player, const gchar *email); void wmud_player_set_email(WmudPlayer *player,
const gchar *email);
gchar *wmud_player_get_email(WmudPlayer *player); gchar *wmud_player_get_email(WmudPlayer *player);
void wmud_player_set_id(WmudPlayer *player, guint32 id); void wmud_player_set_id(WmudPlayer *player,
guint32 id);
guint32 wmud_player_get_id(WmudPlayer *player); guint32 wmud_player_get_id(WmudPlayer *player);
WmudPlayer *wmud_player_dup(WmudPlayer *player); WmudPlayer *wmud_player_dup(WmudPlayer *player);
gboolean wmud_player_password_valid(WmudPlayer *player, const gchar *password); gboolean wmud_player_password_valid(WmudPlayer *player,
const gchar *password);
#endif /* __WMUD_WMUDPLAYER_H__ */ #endif /* __WMUD_WMUDPLAYER_H__ */

View File

@ -35,20 +35,18 @@
* *
* An online wMUD world * An online wMUD world
*/ */
typedef struct _WmudWorld WmudWorld; typedef struct _WmudWorld WmudWorld;
typedef struct _WmudWorldClass WmudWorldClass; typedef struct _WmudWorldClass WmudWorldClass;
typedef struct _WmudWorldPrivate WmudWorldPrivate; typedef struct _WmudWorldPrivate WmudWorldPrivate;
struct _WmudWorld struct _WmudWorld {
{ /*<private>*/
/*<private>*/ GObject parent_instance;
GObject parent_instance; WmudWorldPrivate *priv;
WmudWorldPrivate *priv;
}; };
struct _WmudWorldClass struct _WmudWorldClass {
{ GObjectClass parent_class;
GObjectClass parent_class;
}; };
WmudWorld *wmud_world_new(void); WmudWorld *wmud_world_new(void);

View File

@ -25,12 +25,12 @@
GQuark wmud_world_error_quark(); GQuark wmud_world_error_quark();
typedef enum { typedef enum {
WMUD_WORLD_ERROR_DUPPLANE, WMUD_WORLD_ERROR_DUPPLANE,
WMUD_WORLD_ERROR_DUPPLANET, WMUD_WORLD_ERROR_DUPPLANET,
WMUD_WORLD_ERROR_DUPAREA, WMUD_WORLD_ERROR_DUPAREA,
WMUD_WORLD_ERROR_DUPROOM, WMUD_WORLD_ERROR_DUPROOM,
WMUD_WORLD_ERROR_BADASSOC, WMUD_WORLD_ERROR_BADASSOC,
WMUD_WORLD_ERROR_BADPLANET WMUD_WORLD_ERROR_BADPLANET
} wmudWorldError; } wmudWorldError;
/** /**
@ -39,8 +39,8 @@ typedef enum {
* @name: The name of the plane * @name: The name of the plane
*/ */
typedef struct _wmudPlane { typedef struct _wmudPlane {
guint id; guint id;
gchar *name; gchar *name;
} wmudPlane; } wmudPlane;
/** /**
@ -52,9 +52,9 @@ typedef struct _wmudPlane {
* g_slist_free() * g_slist_free()
*/ */
typedef struct _wmudPlanet { typedef struct _wmudPlanet {
guint id; guint id;
gchar *name; gchar *name;
GSList *planes; GSList *planes;
} wmudPlanet; } wmudPlanet;
/** /**
@ -64,9 +64,9 @@ typedef struct _wmudPlanet {
* @rooms: a #GSList of rooms in this area * @rooms: a #GSList of rooms in this area
*/ */
typedef struct _wmudArea { typedef struct _wmudArea {
guint id; guint id;
gchar *name; gchar *name;
GSList *rooms; GSList *rooms;
} wmudArea; } wmudArea;
/** /**
@ -80,13 +80,13 @@ typedef struct _wmudArea {
* when standing in it * when standing in it
*/ */
typedef struct _wmudRoom { typedef struct _wmudRoom {
guint id; guint id;
guint area_id; guint area_id;
gchar *name; gchar *name;
gchar *distant_description; gchar *distant_description;
gchar *close_description; gchar *close_description;
GSList *planes; GSList *planes;
GSList *exits; GSList *exits;
} wmudRoom; } wmudRoom;
/** /**
@ -96,9 +96,9 @@ typedef struct _wmudRoom {
* @name: The normal name of the direction's command * @name: The normal name of the direction's command
*/ */
typedef struct _wmudDirection { typedef struct _wmudDirection {
guint id; guint id;
gchar *short_name; gchar *short_name;
gchar *name; gchar *name;
} wmudDirection; } wmudDirection;
/** /**
@ -109,9 +109,9 @@ typedef struct _wmudDirection {
* opens * opens
*/ */
typedef struct _wmudExit { typedef struct _wmudExit {
guint source_room_id; guint source_room_id;
guint direction_id; guint direction_id;
guint destination_room_id; guint destination_room_id;
} wmudExit; } wmudExit;
/** /**
@ -120,8 +120,8 @@ typedef struct _wmudExit {
* @other_side: the room to which this exit leads to * @other_side: the room to which this exit leads to
*/ */
typedef struct _wmudRoomExit { typedef struct _wmudRoomExit {
wmudDirection *direction; wmudDirection *direction;
wmudRoom *other_side; wmudRoom *other_side;
} wmudRoomExit; } wmudRoomExit;
/** /**
@ -130,22 +130,38 @@ typedef struct _wmudRoomExit {
* @plane_id: The database ID of the plane @planet is on * @plane_id: The database ID of the plane @planet is on
*/ */
typedef struct _wmudPlanetPlaneAssoc { typedef struct _wmudPlanetPlaneAssoc {
guint planet_id; guint planet_id;
guint plane_id; guint plane_id;
} wmudPlanetPlaneAssoc; } wmudPlanetPlaneAssoc;
gboolean wmud_world_check_planes(GSList *planes, GError **err); gboolean wmud_world_check_planes(GSList *planes,
gboolean wmud_world_check_planets(GSList *planets, GError **err); GError **err);
gboolean wmud_world_check_areas(GSList *areas, GError **err); gboolean wmud_world_check_planets(GSList *planets,
gboolean wmud_world_check_rooms(GSList *rooms, GError **err); GError **err);
gboolean wmud_world_check_exits(GSList *exits, GSList *directions, GSList *rooms, GError **err); gboolean wmud_world_check_areas(GSList *areas,
GError **err);
gboolean wmud_world_check_rooms(GSList *rooms,
GError **err);
gboolean wmud_world_check_exits(GSList *exits,
GSList *directions,
GSList *rooms,
GError **err);
gboolean wmud_world_assoc_planets_planes(GSList *planets, GSList *planes, GSList *planet_planes, GError **err); gboolean wmud_world_assoc_planets_planes(GSList *planets,
gboolean wmud_world_assoc_rooms_areas(GSList *rooms, GSList *areas, GError **err); GSList *planes,
gboolean wmud_world_assoc_rooms_planets(GSList *rooms, GSList *planets, GError **err); GSList *planet_planes,
void wmud_world_assoc_exits_rooms(GSList *exits, GSList *directions, GSList *rooms, GError **err); GError **err);
gboolean wmud_world_assoc_rooms_areas(GSList *rooms,
GSList *areas,
GError **err);
gboolean wmud_world_assoc_rooms_planets(GSList *rooms,
GSList *planets,
GError **err);
void wmud_world_assoc_exits_rooms(GSList *exits,
GSList *directions,
GSList *rooms,
GError **err);
gboolean wmud_world_load(GError **err); gboolean wmud_world_load(GError **err);
#endif /* __WMUD_WORLD_H__ */ #endif /* __WMUD_WORLD_H__ */