summaryrefslogtreecommitdiff
path: root/src/net/manaserv
diff options
context:
space:
mode:
Diffstat (limited to 'src/net/manaserv')
-rw-r--r--src/net/manaserv/charhandler.cpp5
-rw-r--r--src/net/manaserv/gamehandler.cpp19
-rw-r--r--src/net/manaserv/gamehandler.h4
-rw-r--r--src/net/manaserv/generalhandler.cpp9
-rw-r--r--src/net/manaserv/loginhandler.cpp2
5 files changed, 31 insertions, 8 deletions
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);