summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJared Adams <jaxad0127@gmail.com>2010-07-14 09:21:17 -0600
committerJared Adams <jaxad0127@gmail.com>2010-08-13 19:30:53 -0600
commit07d6c28b6cbd83a73b0613bffe67be90a86d58ca (patch)
tree359981688402948c9a0e2af72a53fe083b69827d /src
parent8eadc834ed3e8439836f7dc87390a56a1164ec11 (diff)
downloadmana-07d6c28b6cbd83a73b0613bffe67be90a86d58ca.tar.gz
mana-07d6c28b6cbd83a73b0613bffe67be90a86d58ca.tar.bz2
mana-07d6c28b6cbd83a73b0613bffe67be90a86d58ca.tar.xz
mana-07d6c28b6cbd83a73b0613bffe67be90a86d58ca.zip
Add code to change gameservers to manaserv netcode
Reviewed-by: Freeyorp
Diffstat (limited to 'src')
-rw-r--r--src/net/manaserv/gamehandler.cpp10
-rw-r--r--src/net/manaserv/playerhandler.cpp17
2 files changed, 21 insertions, 6 deletions
diff --git a/src/net/manaserv/gamehandler.cpp b/src/net/manaserv/gamehandler.cpp
index 271fff15..5e29a896 100644
--- a/src/net/manaserv/gamehandler.cpp
+++ b/src/net/manaserv/gamehandler.cpp
@@ -94,7 +94,10 @@ void GameHandler::handleMessage(Net::MessageIn &msg)
void GameHandler::connect()
{
gameServerConnection->connect(gameServer.hostname, gameServer.port);
- chatServerConnection->connect(chatServer.hostname, chatServer.port);
+
+ // Will already be connected if we just changed gameservers
+ if (!chatServerConnection->isConnected())
+ chatServerConnection->connect(chatServer.hostname, chatServer.port);
}
bool GameHandler::isConnected()
@@ -106,7 +109,10 @@ bool GameHandler::isConnected()
void GameHandler::disconnect()
{
gameServerConnection->disconnect();
- chatHandler->disconnect();
+
+ // No need if we're just changing gameservers
+ if (Client::getState() != STATE_CHANGE_MAP)
+ chatHandler->disconnect();
}
void GameHandler::inGame()
diff --git a/src/net/manaserv/playerhandler.cpp b/src/net/manaserv/playerhandler.cpp
index 2347fee2..33367927 100644
--- a/src/net/manaserv/playerhandler.cpp
+++ b/src/net/manaserv/playerhandler.cpp
@@ -56,6 +56,10 @@ extern Net::PlayerHandler *playerHandler;
namespace ManaServ {
+extern Connection *gameServerConnection;
+extern std::string netToken;
+extern ServerInfo gameServer;
+
void RespawnRequestListener::action(const gcn::ActionEvent &event)
{
Net::getPlayerHandler()->respawn();
@@ -65,8 +69,6 @@ void RespawnRequestListener::action(const gcn::ActionEvent &event)
handler->clearDialogs();
}
-extern Connection *gameServerConnection;
-
PlayerHandler::PlayerHandler()
{
static const Uint16 _messages[] = {
@@ -94,11 +96,18 @@ void PlayerHandler::handleMessage(Net::MessageIn &msg)
break;
case GPMSG_PLAYER_SERVER_CHANGE:
- { // TODO: Implement reconnecting to another game server
- std::string token = msg.readString(32);
+ { // TODO: Fix the servers to test this
+ netToken = msg.readString(32);
std::string address = msg.readString();
int port = msg.readInt16();
logger->log("Changing server to %s:%d", address.c_str(), port);
+
+ gameServer.hostname = address;
+ gameServer.port = port;
+
+ gameServerConnection->disconnect();
+ Client::setState(STATE_CHANGE_MAP);
+ player_node->setMap(0);
} break;
case GPMSG_PLAYER_ATTRIBUTE_CHANGE: