diff options
author | Jared Adams <jaxad0127@gmail.com> | 2009-01-28 15:16:12 +0000 |
---|---|---|
committer | Ira Rice <irarice@gmail.com> | 2009-01-28 16:00:58 -0700 |
commit | 1ca8d08b7619e1958371ce8d82e201b82ae39e32 (patch) | |
tree | 9b79fab367afedd8adac26a9acc56ac923034a2c | |
parent | 487b7237a730469fc4f8a501a93f78c2bbafad51 (diff) | |
download | mana-1ca8d08b7619e1958371ce8d82e201b82ae39e32.tar.gz mana-1ca8d08b7619e1958371ce8d82e201b82ae39e32.tar.bz2 mana-1ca8d08b7619e1958371ce8d82e201b82ae39e32.tar.xz mana-1ca8d08b7619e1958371ce8d82e201b82ae39e32.zip |
Fix handling of packet 0x81
-rw-r--r-- | src/net/charserverhandler.cpp | 51 | ||||
-rw-r--r-- | src/net/loginhandler.cpp | 34 | ||||
-rw-r--r-- | src/net/maploginhandler.cpp | 26 | ||||
-rw-r--r-- | src/net/protocol.h | 1 |
4 files changed, 79 insertions, 33 deletions
diff --git a/src/net/charserverhandler.cpp b/src/net/charserverhandler.cpp index 909100e5..b91a506a 100644 --- a/src/net/charserverhandler.cpp +++ b/src/net/charserverhandler.cpp @@ -43,6 +43,7 @@ CharServerHandler::CharServerHandler(): mCharCreateDialog(0) { static const Uint16 _messages[] = { + SMSG_CONNECTION_PROBLEM, 0x006b, 0x006c, 0x006d, @@ -50,7 +51,6 @@ CharServerHandler::CharServerHandler(): 0x006f, 0x0070, 0x0071, - 0x0081, 0 }; handledMessages = _messages; @@ -58,14 +58,40 @@ CharServerHandler::CharServerHandler(): void CharServerHandler::handleMessage(MessageIn *msg) { - int slot; - int flags; + int slot, flags, code; LocalPlayer *tempPlayer; logger->log("CharServerHandler: Packet ID: %x, Length: %d", msg->getId(), msg->getLength()); switch (msg->getId()) { + case SMSG_CONNECTION_PROBLEM: + code = msg->readInt8(); + logger->log("Connection problem: %i", code); + + switch (code) { + case 0: + errorMessage = "Authentication failed"; + break; + case 1: + errorMessage = "Map server(s) offline"; + break; + case 2: + errorMessage = "This account is already logged in"; + break; + case 3: + errorMessage = "Speed hack detected"; + break; + case 8: + errorMessage = "Duplicated login"; + break; + default: + errorMessage = "Unknown connection error"; + break; + } + state = ERROR_STATE; + break; + case 0x006b: msg->skip(2); // Length word flags = msg->readInt32(); // Aethyra extensions flags @@ -165,25 +191,6 @@ void CharServerHandler::handleMessage(MessageIn *msg) mCharInfo->select(slot); state = CONNECTING_STATE; break; - - case 0x0081: - switch (msg->readInt8()) { - case 1: - errorMessage = "Map server offline"; - break; - case 3: - errorMessage = "Speed hack detected"; - break; - case 8: - errorMessage = "Duplicated login"; - break; - default: - errorMessage = "Unknown error with 0x0081"; - break; - } - mCharInfo->unlock(); - state = ERROR_STATE; - break; } } diff --git a/src/net/loginhandler.cpp b/src/net/loginhandler.cpp index f240618d..db601214 100644 --- a/src/net/loginhandler.cpp +++ b/src/net/loginhandler.cpp @@ -34,7 +34,8 @@ extern SERVER_INFO **server_info; LoginHandler::LoginHandler() { static const Uint16 _messages[] = { - 0x0063, + SMSG_CONNECTION_PROBLEM, + SMSG_UPDATE_HOST, 0x0069, 0x006a, 0 @@ -44,9 +45,32 @@ LoginHandler::LoginHandler() void LoginHandler::handleMessage(MessageIn *msg) { + int code; + switch (msg->getId()) { - case 0x0063: + case SMSG_CONNECTION_PROBLEM: + code = msg->readInt8(); + logger->log("Connection problem: %i", code); + + switch (code) { + case 0: + errorMessage = "Authentication failed"; + break; + case 1: + errorMessage = "No servers available"; + break; + case 2: + errorMessage = "This account is already logged in"; + break; + default: + errorMessage = "Unknown connection error"; + break; + } + state = ERROR_STATE; + break; + + case SMSG_UPDATE_HOST: int len; len = msg->readInt16() - 4; @@ -90,10 +114,10 @@ void LoginHandler::handleMessage(MessageIn *msg) break; case 0x006a: - int loginError = msg->readInt8(); - logger->log("Login::error code: %i", loginError); + code = msg->readInt8(); + logger->log("Login::error code: %i", code); - switch (loginError) { + switch (code) { case 0: errorMessage = "Unregistered ID"; break; diff --git a/src/net/maploginhandler.cpp b/src/net/maploginhandler.cpp index 1b0919fa..b851117e 100644 --- a/src/net/maploginhandler.cpp +++ b/src/net/maploginhandler.cpp @@ -30,8 +30,8 @@ MapLoginHandler::MapLoginHandler() { static const Uint16 _messages[] = { + SMSG_CONNECTION_PROBLEM, SMSG_LOGIN_SUCCESS, - 0x0081, 0 }; handledMessages = _messages; @@ -39,10 +39,29 @@ MapLoginHandler::MapLoginHandler() void MapLoginHandler::handleMessage(MessageIn *msg) { + int code; unsigned char direction; switch (msg->getId()) { + case SMSG_CONNECTION_PROBLEM: + code = msg->readInt8(); + logger->log("Connection problem: %i", code); + + switch (code) { + case 0: + errorMessage = "Authentication failed"; + break; + case 2: + errorMessage = "This account is already logged in"; + break; + default: + errorMessage = "Unknown connection error"; + break; + } + state = ERROR_STATE; + break; + case SMSG_LOGIN_SUCCESS: msg->readInt32(); // server tick msg->readCoordinates(player_node->mX, player_node->mY, direction); @@ -51,10 +70,5 @@ void MapLoginHandler::handleMessage(MessageIn *msg) player_node->mX, player_node->mY, direction); state = GAME_STATE; break; - - case 0x0081: - logger->log("Warning: Map server D/C"); - state = ERROR_STATE; - break; } } diff --git a/src/net/protocol.h b/src/net/protocol.h index fd08c45d..e9053451 100644 --- a/src/net/protocol.h +++ b/src/net/protocol.h @@ -27,6 +27,7 @@ *********************************/ #define SMSG_LOGIN_SUCCESS 0x0073 /**< Contains starting location */ #define SMSG_SERVER_PING 0x007f /**< Contains server tick */ +#define SMSG_CONNECTION_PROBLEM 0x0081 #define SMSG_UPDATE_HOST 0x0063 /**< Custom update host packet */ #define SMSG_PLAYER_UPDATE_1 0x01d8 #define SMSG_PLAYER_UPDATE_2 0x01d9 |