diff options
author | Stefan Dombrowski <stefan@uni-bonn.de> | 2009-12-18 21:43:53 +0100 |
---|---|---|
committer | Freeyorp <Freeyorp101@hotmail.com> | 2009-12-19 19:12:15 +1300 |
commit | 6ad0ab8123de1ee3f27ad38300dc7ef896bab569 (patch) | |
tree | 785e9bd0f019e74329b080116d03b7c1b10d82b0 | |
parent | 7018bbb12c0807efb93acc5d90ec20d59cb3f1a9 (diff) | |
download | mana-6ad0ab8123de1ee3f27ad38300dc7ef896bab569.tar.gz mana-6ad0ab8123de1ee3f27ad38300dc7ef896bab569.tar.bz2 mana-6ad0ab8123de1ee3f27ad38300dc7ef896bab569.tar.xz mana-6ad0ab8123de1ee3f27ad38300dc7ef896bab569.zip |
Client now returns to server selection after server disconnection
This resolves http://bugs.manasource.org/view.php?id=37
-rw-r--r-- | src/game.cpp | 26 | ||||
-rw-r--r-- | src/main.cpp | 17 | ||||
-rw-r--r-- | src/main.h | 9 |
3 files changed, 20 insertions, 32 deletions
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 <guichan/exception.hpp> #include <guichan/focushandler.hpp> -#include "physfs.h" +#include <physfs.h> #include <sys/stat.h> @@ -151,23 +151,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() * @see MILLISECONDS_IN_A_TICK value @@ -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 <SDL_image.h> -#include <guichan/actionlistener.hpp> - #include <libxml/parser.h> #include <getopt.h> @@ -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; @@ -55,6 +55,8 @@ #include "net/logindata.h" +#include <guichan/actionlistener.hpp> + #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 |