summaryrefslogtreecommitdiff
path: root/src/net
diff options
context:
space:
mode:
Diffstat (limited to 'src/net')
-rw-r--r--src/net/charserverhandler.cpp2
-rw-r--r--src/net/loginhandler.cpp34
-rw-r--r--src/net/protocol.h7
3 files changed, 41 insertions, 2 deletions
diff --git a/src/net/charserverhandler.cpp b/src/net/charserverhandler.cpp
index 932a6fbc..36a17acf 100644
--- a/src/net/charserverhandler.cpp
+++ b/src/net/charserverhandler.cpp
@@ -159,8 +159,6 @@ void CharServerHandler::handleMessage(MessageIn *msg)
LocalPlayer* CharServerHandler::readPlayerData(MessageIn *msg, int &slot)
{
LocalPlayer *tempPlayer = new LocalPlayer(mLoginData->account_ID, 0, NULL);
- tempPlayer->setSex(1 - mLoginData->sex);
-
tempPlayer->mCharId = msg->readLong();
tempPlayer->mTotalWeight = 0;
tempPlayer->mMaxWeight = 0;
diff --git a/src/net/loginhandler.cpp b/src/net/loginhandler.cpp
index 5b8fbd1f..ebc8f535 100644
--- a/src/net/loginhandler.cpp
+++ b/src/net/loginhandler.cpp
@@ -36,6 +36,7 @@ LoginHandler::LoginHandler()
{
static const Uint16 _messages[] = {
APMSG_LOGIN_RESPONSE,
+ APMSG_REGISTER_RESPONSE,
0
};
handledMessages = _messages;
@@ -46,6 +47,7 @@ void LoginHandler::handleMessage(MessageIn *msg)
switch (msg->getId())
{
case APMSG_LOGIN_RESPONSE:
+ {
int errMsg = msg->readByte();
// Successful login
if (errMsg == ERRMSG_OK)
@@ -90,6 +92,38 @@ void LoginHandler::handleMessage(MessageIn *msg)
}
state = ERROR_STATE;
}
+ }
+ break;
+ case APMSG_REGISTER_RESPONSE:
+ {
+ int errMsg = msg->readByte();
+ // Successful registration
+ if (errMsg == ERRMSG_OK)
+ {
+ state = ACCOUNT_STATE;
+ }
+ // Registration failed
+ else {
+ switch (errMsg) {
+ case REGISTER_INVALID_VERSION:
+ errorMessage = "Client has an insufficient version number to login.";
+ break;
+ case ERRMSG_INVALID_ARGUMENT:
+ errorMessage = "Wrong username, password or email address";
+ break;
+ case REGISTER_EXISTS_USERNAME:
+ errorMessage = "Username already exists";
+ break;
+ case REGISTER_EXISTS_EMAIL:
+ errorMessage = "Email address already exists";
+ break;
+ default:
+ errorMessage = "Unknown error";
+ break;
+ }
+ state = ERROR_STATE;
+ }
+ }
break;
}
}
diff --git a/src/net/protocol.h b/src/net/protocol.h
index 6a13bbd9..6db3762e 100644
--- a/src/net/protocol.h
+++ b/src/net/protocol.h
@@ -200,6 +200,13 @@ enum {
LOGIN_SERVER_FULL // the server is overloaded
};
+// Account register specific return values
+enum {
+ REGISTER_INVALID_VERSION = 0x40, // the user is using an incompatible protocol
+ REGISTER_EXISTS_USERNAME, // there already is an account with this username
+ REGISTER_EXISTS_EMAIL // there already is an account with this email address
+};
+
/** Encodes coords and direction in 3 bytes data */
void set_coordinates(char *data, unsigned short x, unsigned short y, unsigned char direction);