From a80e10b7ba9771dca3fcddb3f0182a5aa1825226 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Thu, 7 Mar 2013 17:46:31 +0300 Subject: Fix server switch incorrect map loading. --- src/client.cpp | 1 + src/net/ea/gamehandler.cpp | 8 +++++++- src/net/ea/gamehandler.h | 2 ++ src/net/eathena/gamehandler.h | 2 -- src/net/gamehandler.h | 2 ++ src/net/tmwa/gamehandler.h | 2 -- 6 files changed, 12 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/client.cpp b/src/client.cpp index ef4c2fd53..9346a30b6 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -1619,6 +1619,7 @@ int Client::gameExec() Net::getLoginHandler()->disconnect(); Net::getGameHandler()->disconnect(); + Net::getGameHandler()->clear(); mState = STATE_CHOOSE_SERVER; BLOCK_END("Client::gameExec STATE_SWITCH_SERVER") diff --git a/src/net/ea/gamehandler.cpp b/src/net/ea/gamehandler.cpp index 3e9e36541..eaed1ec5d 100644 --- a/src/net/ea/gamehandler.cpp +++ b/src/net/ea/gamehandler.cpp @@ -48,7 +48,7 @@ void GameHandler::processEvent(Channels channel, { if (event.getName() == EVENT_ENGINESINITALIZED) { - if (mMap != "") + if (!mMap.empty()) Game::instance()->changeMap(mMap); } else if (event.getName() == EVENT_MAPLOADED) @@ -99,4 +99,10 @@ void GameHandler::processMapQuitResponse(Net::MessageIn &msg) new OkDialog(_("Game"), _("Request to quit denied!"), DIALOG_ERROR); } +void GameHandler::clear() +{ + mMap.clear(); + mCharID = 0; +} + } // namespace Ea diff --git a/src/net/ea/gamehandler.h b/src/net/ea/gamehandler.h index 93773e33d..c0b4286ce 100644 --- a/src/net/ea/gamehandler.h +++ b/src/net/ea/gamehandler.h @@ -62,6 +62,8 @@ class GameHandler : public Net::GameHandler, public Listener virtual void processMapQuitResponse(Net::MessageIn &msg); + virtual void clear(); + protected: std::string mMap; int mCharID; /// < Saved for map-server switching diff --git a/src/net/eathena/gamehandler.h b/src/net/eathena/gamehandler.h index d9b9d80f6..425285f91 100644 --- a/src/net/eathena/gamehandler.h +++ b/src/net/eathena/gamehandler.h @@ -52,8 +52,6 @@ class GameHandler final : public MessageHandler, public Ea::GameHandler void ping(int tick); - void clear(); - void disconnect2(); void mapLoadedEvent(); diff --git a/src/net/gamehandler.h b/src/net/gamehandler.h index 5a41bec57..5826ae09d 100644 --- a/src/net/gamehandler.h +++ b/src/net/gamehandler.h @@ -58,6 +58,8 @@ class GameHandler virtual bool canUseMagicBar() const A_WARN_UNUSED = 0; virtual bool mustPing() const A_WARN_UNUSED = 0; + + virtual void clear() = 0; }; } // namespace Net diff --git a/src/net/tmwa/gamehandler.h b/src/net/tmwa/gamehandler.h index b12876dd4..5ce70fbca 100644 --- a/src/net/tmwa/gamehandler.h +++ b/src/net/tmwa/gamehandler.h @@ -52,8 +52,6 @@ class GameHandler final : public MessageHandler, public Ea::GameHandler void ping(int tick); - void clear(); - void disconnect2(); void mapLoadedEvent(); -- cgit v1.2.3-70-g09d2