From 7b2b5dabb44ce1448f3af99fcba96eefe6d9147d Mon Sep 17 00:00:00 2001 From: Bjørn Lindeijer Date: Sun, 17 May 2009 22:43:33 +0200 Subject: Make the state variable a bit more type-safe Should be no change in behaviour. --- src/gui/serverselectdialog.cpp | 2 +- src/gui/serverselectdialog.h | 6 ++++-- src/main.cpp | 8 ++++---- src/main.h | 4 ++-- 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/gui/serverselectdialog.cpp b/src/gui/serverselectdialog.cpp index ccdf2bb6..f492ebc7 100644 --- a/src/gui/serverselectdialog.cpp +++ b/src/gui/serverselectdialog.cpp @@ -55,7 +55,7 @@ class ServerListModel : public gcn::ListModel } }; -ServerSelectDialog::ServerSelectDialog(LoginData *loginData, int nextState): +ServerSelectDialog::ServerSelectDialog(LoginData *loginData, State nextState): Window(_("Select Server")), mLoginData(loginData), mNextState(nextState) diff --git a/src/gui/serverselectdialog.h b/src/gui/serverselectdialog.h index b80ad286..fd1484af 100644 --- a/src/gui/serverselectdialog.h +++ b/src/gui/serverselectdialog.h @@ -24,6 +24,8 @@ #include "gui/widgets/window.h" +#include "main.h" + #include #include @@ -42,7 +44,7 @@ class ServerSelectDialog : public Window, public gcn::ActionListener { * * @see Window::Window */ - ServerSelectDialog(LoginData *loginData, int nextState); + ServerSelectDialog(LoginData *loginData, State nextState); /** * Destructor. @@ -59,7 +61,7 @@ class ServerSelectDialog : public Window, public gcn::ActionListener { ServerListModel *mServerListModel; gcn::ListBox *mServerList; gcn::Button *mOkButton; - int mNextState; + State mNextState; }; #endif diff --git a/src/main.cpp b/src/main.cpp index bc010d30..fb061818 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -161,7 +161,7 @@ extern Net::Connection *accountServerConnection; Graphics *graphics; Game *game = 0; -unsigned char state = STATE_NULL; +State state = STATE_NULL; std::string errorMessage; Sound sound; @@ -975,7 +975,7 @@ int main(int argc, char *argv[]) desktop->setSize(screenWidth, screenHeight); - unsigned int oldstate = !state; // We start with a status change. + State oldstate = STATE_EXIT; // We start with a status change SDL_Event event; @@ -1429,9 +1429,9 @@ int main(int argc, char *argv[]) } else { - int nextState = STATE_UPDATE; + State nextState = STATE_UPDATE; currentDialog = new ServerSelectDialog(&loginData, - nextState); + nextState); positionDialog(currentDialog, screenWidth, screenHeight); if (options.chooseDefault) diff --git a/src/main.h b/src/main.h index a3894d13..75343944 100644 --- a/src/main.h +++ b/src/main.h @@ -78,7 +78,7 @@ /* * Client different States */ -enum { +enum State { STATE_EXIT, STATE_LOADDATA, STATE_LOGIN, @@ -136,7 +136,7 @@ const short maxSlot = 2; extern std::string token; extern char n_server, n_character; -extern unsigned char state; +extern State state; extern std::string errorMessage; #endif -- cgit v1.2.3-70-g09d2