From 6ad0ab8123de1ee3f27ad38300dc7ef896bab569 Mon Sep 17 00:00:00 2001 From: Stefan Dombrowski Date: Fri, 18 Dec 2009 21:43:53 +0100 Subject: Client now returns to server selection after server disconnection This resolves http://bugs.manasource.org/view.php?id=37 --- src/game.cpp | 26 +++++--------------------- src/main.cpp | 17 ++++++----------- src/main.h | 9 +++++++++ 3 files changed, 20 insertions(+), 32 deletions(-) (limited to 'src') diff --git a/src/game.cpp b/src/game.cpp index a91fdc23..b04d1990 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -85,7 +85,7 @@ #include #include -#include "physfs.h" +#include #include @@ -150,23 +150,6 @@ const int MAX_TICK_VALUE = 10000; */ const int MILLISECONDS_IN_A_TICK = 10; -/** - * Listener used for exiting handling. - */ -namespace { - class ExitListener : public gcn::ActionListener - { - public: - void action(const gcn::ActionEvent &event) - { - if (event.getId() == "yes" || event.getId() == "ok") - state = STATE_EXIT; - - disconnectedDialog = NULL; - } - } exitListener; -} - /** * Advances game logic counter. * Called every 10 milliseconds by SDL_AddTimer() @@ -302,6 +285,8 @@ Game::Game(): mLastTarget(Being::UNKNOWN), mLogicCounterId(0), mSecondsCounterId(0) { + disconnectedDialog = NULL; + createGuiWindows(); mWindowMenu = new WindowMenu; @@ -498,14 +483,13 @@ void Game::logic() { if (state != STATE_ERROR) { - errorMessage = _("The connection to the server was lost, " - "the program will now quit"); + errorMessage = _("The connection to the server was lost."); } if (!disconnectedDialog) { disconnectedDialog = new OkDialog(_("Network Error"), errorMessage); - disconnectedDialog->addActionListener(&exitListener); + disconnectedDialog->addActionListener(&errorListener); disconnectedDialog->requestMoveToTop(); } } diff --git a/src/main.cpp b/src/main.cpp index 0f070dd1..8caef783 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -82,8 +82,6 @@ #include -#include - #include #include @@ -128,6 +126,7 @@ Game *game = 0; State state = STATE_START; std::string errorMessage; +ErrorListener errorListener; Sound sound; Music *bgm; @@ -649,15 +648,6 @@ static void loadUpdates() } } -class ErrorListener : public gcn::ActionListener -{ -public: - void action(const gcn::ActionEvent &event) - { - state = STATE_CHOOSE_SERVER; - } -} errorListener; - class AccountListener : public gcn::ActionListener { public: @@ -678,6 +668,11 @@ public: } // namespace +void ErrorListener::action(const gcn::ActionEvent &event) +{ + state = STATE_CHOOSE_SERVER; +} + const std::string &getHomeDirectory() { return homeDir; diff --git a/src/main.h b/src/main.h index 765b84b8..4938e80d 100644 --- a/src/main.h +++ b/src/main.h @@ -55,6 +55,8 @@ #include "net/logindata.h" +#include + #ifdef HAVE_CONFIG_H #include "../config.h" #elif defined WIN32 @@ -131,8 +133,15 @@ enum State { STATE_FORCE_QUIT }; +class ErrorListener : public gcn::ActionListener +{ + public: + void action(const gcn::ActionEvent &event); +}; + extern State state; extern std::string errorMessage; +extern ErrorListener errorListener; extern LoginData loginData; #endif -- cgit v1.2.3-70-g09d2