diff options
author | Jared Adams <jaxad0127@gmail.com> | 2009-11-03 15:03:23 -0700 |
---|---|---|
committer | Jared Adams <jaxad0127@gmail.com> | 2009-11-03 15:03:23 -0700 |
commit | d5ef936bf2d8976a32d01b4e32024c89333ca645 (patch) | |
tree | 3093ae1b7611b8dbad2aba02cba12b9e2da31e36 /src | |
parent | c416c51531e37e0be457e47b7c0e52439c543341 (diff) | |
download | mana-d5ef936bf2d8976a32d01b4e32024c89333ca645.tar.gz mana-d5ef936bf2d8976a32d01b4e32024c89333ca645.tar.bz2 mana-d5ef936bf2d8976a32d01b4e32024c89333ca645.tar.xz mana-d5ef936bf2d8976a32d01b4e32024c89333ca645.zip |
Fix switching characters under ManaServ
Diffstat (limited to 'src')
-rw-r--r-- | src/engine.cpp | 1 | ||||
-rw-r--r-- | src/net/manaserv/charhandler.cpp | 5 | ||||
-rw-r--r-- | src/net/manaserv/gamehandler.cpp | 19 | ||||
-rw-r--r-- | src/net/manaserv/gamehandler.h | 4 | ||||
-rw-r--r-- | src/net/manaserv/generalhandler.cpp | 9 | ||||
-rw-r--r-- | src/net/manaserv/loginhandler.cpp | 2 |
6 files changed, 32 insertions, 8 deletions
diff --git a/src/engine.cpp b/src/engine.cpp index d205549b..f7e1d175 100644 --- a/src/engine.cpp +++ b/src/engine.cpp @@ -54,6 +54,7 @@ Engine::Engine(): Engine::~Engine() { delete mCurrentMap; + map_path = ""; } void Engine::changeMap(const std::string &mapPath) diff --git a/src/net/manaserv/charhandler.cpp b/src/net/manaserv/charhandler.cpp index bc7ffaaa..a239e2d1 100644 --- a/src/net/manaserv/charhandler.cpp +++ b/src/net/manaserv/charhandler.cpp @@ -22,6 +22,7 @@ #include "net/manaserv/charhandler.h" #include "net/manaserv/connection.h" +#include "net/manaserv/gamehandler.h" #include "net/manaserv/messagein.h" #include "net/manaserv/messageout.h" #include "net/manaserv/protocol.h" @@ -59,6 +60,8 @@ struct CharInfo { typedef std::vector<CharInfo> CharInfos; CharInfos chars; +extern ManaServ::GameHandler *gameHandler; + namespace ManaServ { extern Connection *accountServerConnection; @@ -394,7 +397,7 @@ void CharHandler::deleteCharacter(int slot, LocalPlayer* character) void CharHandler::switchCharacter() { - // TODO + gameHandler->quit(true); } } // namespace ManaServ diff --git a/src/net/manaserv/gamehandler.cpp b/src/net/manaserv/gamehandler.cpp index 306dc5e6..c2d20233 100644 --- a/src/net/manaserv/gamehandler.cpp +++ b/src/net/manaserv/gamehandler.cpp @@ -58,7 +58,16 @@ void GameHandler::handleMessage(Net::MessageIn &msg) // Successful logout if (errMsg == ERRMSG_OK) { - // TODO: Handle logout + netToken = msg.readString(32); +\ + if (!netToken.empty()) + { + state = STATE_SWITCH_CHARACTER; + } + else + { + // TODO: Handle logout + } } // Logout failed else @@ -115,11 +124,11 @@ void GameHandler::who() // TODO } -void GameHandler::quit() +void GameHandler::quit(bool reconnectAccount) { - //MessageOut msg(PGMSG_DISCONNECT); - //msg.writeInt8((unsigned char) reconnectAccount); - //gameServerConnection->send(msg); + MessageOut msg(PGMSG_DISCONNECT); + msg.writeInt8((unsigned char) reconnectAccount); + gameServerConnection->send(msg); } void GameHandler::ping(int tick) diff --git a/src/net/manaserv/gamehandler.h b/src/net/manaserv/gamehandler.h index aad0651f..85fa7465 100644 --- a/src/net/manaserv/gamehandler.h +++ b/src/net/manaserv/gamehandler.h @@ -48,7 +48,9 @@ class GameHandler : public MessageHandler, public Net::GameHandler void who(); - void quit(); + void quit(bool reconnectAccount); + + void quit() { quit(false); } void ping(int tick); diff --git a/src/net/manaserv/generalhandler.cpp b/src/net/manaserv/generalhandler.cpp index 2f4ad4a0..66929ef6 100644 --- a/src/net/manaserv/generalhandler.cpp +++ b/src/net/manaserv/generalhandler.cpp @@ -57,6 +57,8 @@ Net::GeneralHandler *generalHandler = NULL; +extern ManaServ::LoginHandler *loginHandler; + namespace ManaServ { Connection *accountServerConnection = 0; @@ -146,6 +148,13 @@ void GeneralHandler::unload() void GeneralHandler::flushNetwork() { flush(); + + if (state == STATE_SWITCH_CHARACTER && + Net::getLoginHandler()->isConnected()) + { + loginHandler->reconnect(); + state = STATE_GET_CHARACTERS; + } } bool GeneralHandler::isNetworkConnected() diff --git a/src/net/manaserv/loginhandler.cpp b/src/net/manaserv/loginhandler.cpp index 5e8780d4..615abc51 100644 --- a/src/net/manaserv/loginhandler.cpp +++ b/src/net/manaserv/loginhandler.cpp @@ -382,7 +382,7 @@ Worlds LoginHandler::getWorlds() const return Worlds(); } -void reconnect() +void LoginHandler::reconnect() { MessageOut msg(PAMSG_RECONNECT); msg.writeString(netToken, 32); |