summaryrefslogtreecommitdiff
path: root/src/game-server
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2007-02-04 21:52:17 +0000
committerBjørn Lindeijer <bjorn@lindeijer.nl>2007-02-04 21:52:17 +0000
commitcade1ba618bd1883e044999a0cbda201f1f76dd4 (patch)
tree978d8e0d97b0f5b0eec3a77a8d25e54b870ed786 /src/game-server
parent9c0421f5926d22a44c978fff683c51748a19e976 (diff)
downloadmanaserv-cade1ba618bd1883e044999a0cbda201f1f76dd4.tar.gz
manaserv-cade1ba618bd1883e044999a0cbda201f1f76dd4.tar.bz2
manaserv-cade1ba618bd1883e044999a0cbda201f1f76dd4.tar.xz
manaserv-cade1ba618bd1883e044999a0cbda201f1f76dd4.zip
Added support for switching character by reconnecting to the account server and
fixed the issue where a client is not logged in after registering (patch by Rogier Polak).
Diffstat (limited to 'src/game-server')
-rw-r--r--src/game-server/accountconnection.cpp10
-rw-r--r--src/game-server/accountconnection.hpp6
-rw-r--r--src/game-server/gamehandler.cpp28
3 files changed, 44 insertions, 0 deletions
diff --git a/src/game-server/accountconnection.cpp b/src/game-server/accountconnection.cpp
index d681cb64..a5c7bddd 100644
--- a/src/game-server/accountconnection.cpp
+++ b/src/game-server/accountconnection.cpp
@@ -98,3 +98,13 @@ void AccountConnection::processMessage(MessageIn &msg)
break;
}
}
+
+void AccountConnection::playerReconnectAccount(int id, const std::string magic_token)
+{
+ LOG_INFO("Send GAMSG_PLAYER_RECONNECT.");
+ MessageOut msg(GAMSG_PLAYER_RECONNECT);
+ msg.writeLong(id);
+ msg.writeString(magic_token);
+ send(msg);
+
+}
diff --git a/src/game-server/accountconnection.hpp b/src/game-server/accountconnection.hpp
index e418a111..5f8ae0e9 100644
--- a/src/game-server/accountconnection.hpp
+++ b/src/game-server/accountconnection.hpp
@@ -45,6 +45,12 @@ class AccountConnection: public Connection
*/
void sendPlayerData(PlayerData *);
+ /**
+ * Prepares the account server for a reconnecting player
+ */
+ void playerReconnectAccount(int id, const std::string magic_token);
+
+
protected:
/**
* Processes server messages.
diff --git a/src/game-server/gamehandler.cpp b/src/game-server/gamehandler.cpp
index 98a10938..05e4d2b0 100644
--- a/src/game-server/gamehandler.cpp
+++ b/src/game-server/gamehandler.cpp
@@ -24,6 +24,7 @@
#include <cassert>
#include <map>
+#include "game-server/accountconnection.hpp"
#include "game-server/gamehandler.hpp"
#include "game-server/inventory.hpp"
#include "game-server/item.hpp"
@@ -303,6 +304,33 @@ void GameHandler::processMessage(NetComputer *comp, MessageIn &message)
computer.character->setAction(PLAYER_ATTACK);
} break;
+ case PGMSG_DISCONNECT:
+ {
+ bool reconnectAccount = (bool) message.readByte();
+
+ result.writeShort(GPMSG_DISCONNECT_RESPONSE);
+ result.writeShort(ERRMSG_OK); // It is when control reaches here
+
+ if (reconnectAccount)
+ {
+ LOG_INFO("Making a magic_token.");
+ std::string magic_token(32, ' ');
+ for (int i = 0; i < 32; ++i) {
+ magic_token[i] =
+ 1 + (int) (127 * (rand() / (RAND_MAX + 1.0)));
+ }
+ result.writeString(magic_token, 32);
+ //No accountserver data, the client should remember that
+ accountHandler->playerReconnectAccount(
+ computer.character->getDatabaseID(),
+ magic_token);
+ }
+ // TODO: check if the character's updated info is send to the database
+ gameState->remove(computer.character);
+ delete computer.character;
+ computer.character = NULL;
+ computer.status = CLIENT_LOGIN;
+ } break;
default:
LOG_WARN("Invalid message type");
result.writeShort(XXMSG_INVALID);