Consolidated WmudClientState into wmudclient.[ch]

Meanwhile, wmud-types.h became obsolete, so removed it.
This commit is contained in:
Gergely Polonkai 2013-01-05 21:17:43 +01:00
parent 940686111d
commit b99f9e1ea2
12 changed files with 38 additions and 81 deletions

View File

@ -23,7 +23,6 @@
#include <glib.h>
#include "wmud-types.h"
#include "configuration.h"
/**

View File

@ -22,7 +22,6 @@
#include <glib.h>
#include "wmudplayer.h"
#include "wmud-types.h"
#define WMUD_DB_ERROR wmud_db_error_quark()
GQuark wmud_db_error_quark();

View File

@ -22,7 +22,6 @@
#include <glib.h>
#include "wmudclient.h"
#include "wmud-types.h"
/**
* TELNET_IAC:

View File

@ -26,7 +26,6 @@
#include <crypt.h>
#endif
#include "wmud-types.h"
#include "main.h"
#include "game-networking.h"
#include "interpreter.h"

View File

@ -27,7 +27,6 @@
#include <curl/curl.h>
#include <string.h>
#include "wmud-types.h"
#include "maintenance.h"
#include "main.h"
#include "players.h"

View File

@ -21,7 +21,6 @@
#include <glib.h>
#include "wmud-types.h"
#include "wmudclient.h"
extern GSList *players;

View File

@ -19,7 +19,6 @@
#include <glib.h>
#include <gio/gio.h>
#include "wmud-types.h"
#include "game-networking.h"
#include "texts.h"

View File

@ -19,7 +19,6 @@
#ifndef __WMUD_TEXTS_H__
#define __WMUD_TEXTS_H__
#include "wmud-types.h"
void wmud_texts_init(void);
void wmud_text_send_to_client(gchar *text, WmudClient *client);

View File

@ -1,66 +0,0 @@
/* wMUD - Yet another MUD codebase by W00d5t0ck
* Copyright (C) 2012 - Gergely POLONKAI
*
* wmud-types.h: Common wMUD data types
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __WMUD_TYPES_H__
#define __WMUD_TYPES_H__
#include <glib.h>
#include <gio/gio.h>
/**
* SECTION:types
* @short_description: wMUD Data Types
* @title: wMUD's Data Types
*
*/
/**
* 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;
#endif /* __WMUD_TYPES_H__ */

View File

@ -27,7 +27,7 @@ struct _WmudClientPrivate
GSocket *socket;
GSource *socket_source;
GString *buffer;
wmudClientState state;
WmudClientState state;
gboolean authenticated;
WmudPlayer *player;
gboolean bademail;
@ -167,14 +167,14 @@ wmud_client_get_buffer(WmudClient *self)
return self->priv->buffer;
}
wmudClientState
WmudClientState
wmud_client_get_state(WmudClient *self)
{
return self->priv->state;
}
void
wmud_client_set_state(WmudClient *self, wmudClientState state)
wmud_client_set_state(WmudClient *self, WmudClientState state)
{
self->priv->state = state;
}

View File

@ -23,7 +23,6 @@
#include <glib.h>
#include <gio/gio.h>
#include "wmudplayer.h"
#include "wmud-types.h"
#define WMUD_TYPE_CLIENT (wmud_client_get_type())
#define WMUD_CLIENT(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), WMUD_TYPE_CLIENT, WmudClient))
@ -50,6 +49,39 @@ 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);
@ -59,8 +91,8 @@ void wmud_client_send(WmudClient *client, const gchar *fmt, ...);
void wmud_client_close(WmudClient *self, gboolean send_goodbye);
GString *wmud_client_get_buffer(WmudClient *client);
gsize wmud_client_get_buffer_length(WmudClient *client);
void wmud_client_set_state(WmudClient *client, wmudClientState state);
wmudClientState wmud_client_get_state(WmudClient *client);
void wmud_client_set_state(WmudClient *client, WmudClientState state);
WmudClientState wmud_client_get_state(WmudClient *client);
void wmud_client_set_player(WmudClient *client, WmudPlayer *player);
WmudPlayer *wmud_client_get_player(WmudClient *client);
void wmud_client_set_yesno_callback(WmudClient *client, WmudClientYesnoCallback yesno_callback);

View File

@ -22,7 +22,6 @@
#include <glib-object.h>
#include <glib.h>
#include <gio/gio.h>
#include "wmud-types.h"
#define WMUD_TYPE_PLAYER (wmud_player_get_type())
#define WMUD_PLAYER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), WMUD_TYPE_PLAYER, WmudPlayer))