summaryrefslogtreecommitdiff
path: root/src/net
diff options
context:
space:
mode:
Diffstat (limited to 'src/net')
-rw-r--r--src/net/charserverhandler.cpp50
-rw-r--r--src/net/loginhandler.cpp32
-rw-r--r--src/net/maploginhandler.cpp26
-rw-r--r--src/net/protocol.h1
4 files changed, 78 insertions, 31 deletions
diff --git a/src/net/charserverhandler.cpp b/src/net/charserverhandler.cpp
index cfa52c38..f00615d7 100644
--- a/src/net/charserverhandler.cpp
+++ b/src/net/charserverhandler.cpp
@@ -38,6 +38,7 @@ CharServerHandler::CharServerHandler():
mCharCreateDialog(0)
{
static const Uint16 _messages[] = {
+ SMSG_CONNECTION_PROBLEM,
0x006b,
0x006c,
0x006d,
@@ -45,7 +46,6 @@ CharServerHandler::CharServerHandler():
0x006f,
0x0070,
0x0071,
- 0x0081,
0
};
handledMessages = _messages;
@@ -53,13 +53,40 @@ CharServerHandler::CharServerHandler():
void CharServerHandler::handleMessage(MessageIn *msg)
{
- int slot;
+ int slot, 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:
// Skip length word and an additional mysterious 20 bytes
msg->skip(2 + 20);
@@ -154,25 +181,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 646c5f3c..c9eec9f4 100644
--- a/src/net/loginhandler.cpp
+++ b/src/net/loginhandler.cpp
@@ -35,6 +35,7 @@ extern SERVER_INFO **server_info;
LoginHandler::LoginHandler()
{
static const Uint16 _messages[] = {
+ SMSG_CONNECTION_PROBLEM,
SMSG_UPDATE_HOST,
0x0069,
0x006a,
@@ -45,9 +46,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;
@@ -91,10 +115,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 0d349a6d..68652c79 100644
--- a/src/net/maploginhandler.cpp
+++ b/src/net/maploginhandler.cpp
@@ -31,8 +31,8 @@
MapLoginHandler::MapLoginHandler()
{
static const Uint16 _messages[] = {
+ SMSG_CONNECTION_PROBLEM,
SMSG_LOGIN_SUCCESS,
- 0x0081,
0
};
handledMessages = _messages;
@@ -40,10 +40,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);
@@ -52,10 +71,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 b70834c6..3bdeb429 100644
--- a/src/net/protocol.h
+++ b/src/net/protocol.h
@@ -24,6 +24,7 @@
// Packets from server to client
#define SMSG_LOGIN_SUCCESS 0x0073 /**< Contains starting location */
+#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