summaryrefslogtreecommitdiff
path: root/src/net/manaserv
diff options
context:
space:
mode:
Diffstat (limited to 'src/net/manaserv')
-rw-r--r--src/net/manaserv/charhandler.cpp20
-rw-r--r--src/net/manaserv/charhandler.h4
-rw-r--r--src/net/manaserv/gamehandler.cpp7
-rw-r--r--src/net/manaserv/generalhandler.cpp16
4 files changed, 37 insertions, 10 deletions
diff --git a/src/net/manaserv/charhandler.cpp b/src/net/manaserv/charhandler.cpp
index 4b574821..c070ab23 100644
--- a/src/net/manaserv/charhandler.cpp
+++ b/src/net/manaserv/charhandler.cpp
@@ -68,6 +68,11 @@ CharHandler::CharHandler()
charHandler = this;
}
+CharHandler::~CharHandler()
+{
+ clear();
+}
+
void CharHandler::handleMessage(Net::MessageIn &msg)
{
switch (msg.getId())
@@ -225,16 +230,10 @@ void CharHandler::handleCharacterSelectResponse(Net::MessageIn &msg)
logger->log("Chat server: %s:%d", chatServer.hostname.c_str(),
chatServer.port);
- gameServerConnection->connect(gameServer.hostname, gameServer.port);
- chatServerConnection->connect(chatServer.hostname, chatServer.port);
-
// Prevent the selected local player from being deleted
player_node = mSelectedCharacter->dummy;
mSelectedCharacter->dummy = 0;
- mCachedCharacterInfos.clear();
- updateCharacters();
-
Client::setState(STATE_CONNECT_GAME);
}
else if (errMsg == ERRMSG_FAILURE)
@@ -381,4 +380,13 @@ void CharHandler::updateCharacters()
updateCharSelectDialog();
}
+void CharHandler::clear()
+{
+ setCharCreateDialog(0);
+ setCharSelectDialog(0);
+
+ mCachedCharacterInfos.clear();
+ updateCharacters();
+}
+
} // namespace ManaServ
diff --git a/src/net/manaserv/charhandler.h b/src/net/manaserv/charhandler.h
index d2f50850..26a7bf4e 100644
--- a/src/net/manaserv/charhandler.h
+++ b/src/net/manaserv/charhandler.h
@@ -40,6 +40,8 @@ class CharHandler : public MessageHandler, public Net::CharHandler
public:
CharHandler();
+ ~CharHandler();
+
void handleMessage(Net::MessageIn &msg);
void setCharSelectDialog(CharSelectDialog *window);
@@ -69,6 +71,8 @@ class CharHandler : public MessageHandler, public Net::CharHandler
int maxSprite() const;
+ void clear();
+
private:
/**
* Character information needs to be cached since we receive it before
diff --git a/src/net/manaserv/gamehandler.cpp b/src/net/manaserv/gamehandler.cpp
index 4c6c8e38..271fff15 100644
--- a/src/net/manaserv/gamehandler.cpp
+++ b/src/net/manaserv/gamehandler.cpp
@@ -35,9 +35,11 @@ extern ManaServ::ChatHandler *chatHandler;
namespace ManaServ {
+extern Connection *chatServerConnection;
extern Connection *gameServerConnection;
extern std::string netToken;
extern ServerInfo gameServer;
+extern ServerInfo chatServer;
GameHandler::GameHandler()
{
@@ -60,7 +62,7 @@ void GameHandler::handleMessage(Net::MessageIn &msg)
if (errMsg == ERRMSG_OK)
{
netToken = msg.readString(32);
-\
+
if (!netToken.empty())
{
Client::setState(STATE_SWITCH_CHARACTER);
@@ -91,7 +93,8 @@ void GameHandler::handleMessage(Net::MessageIn &msg)
void GameHandler::connect()
{
- //
+ gameServerConnection->connect(gameServer.hostname, gameServer.port);
+ chatServerConnection->connect(chatServer.hostname, chatServer.port);
}
bool GameHandler::isConnected()
diff --git a/src/net/manaserv/generalhandler.cpp b/src/net/manaserv/generalhandler.cpp
index 0e030aa8..454052f7 100644
--- a/src/net/manaserv/generalhandler.cpp
+++ b/src/net/manaserv/generalhandler.cpp
@@ -122,8 +122,20 @@ void GeneralHandler::load()
void GeneralHandler::reload()
{
- static_cast<CharHandler*>(mCharHandler.get())->setCharCreateDialog(0);
- static_cast<CharHandler*>(mCharHandler.get())->setCharSelectDialog(0);
+ static_cast<CharHandler*>(Net::getCharHandler())->clear();
+
+ if (accountServerConnection)
+ accountServerConnection->disconnect();
+
+ if (gameServerConnection)
+ gameServerConnection->disconnect();
+
+ if (chatServerConnection)
+ chatServerConnection->disconnect();
+
+ netToken.clear();
+ gameServer.clear();
+ chatServer.clear();
}
void GeneralHandler::unload()