diff options
author | Eugenio Favalli <elvenprogrammer@gmail.com> | 2006-07-25 18:04:38 +0000 |
---|---|---|
committer | Eugenio Favalli <elvenprogrammer@gmail.com> | 2006-07-25 18:04:38 +0000 |
commit | c7e7b62aa94bf295ca1dc556762ad6070221e0cd (patch) | |
tree | 04f827df0df64a80e04a4115986609486d715237 /src/net/loginhandler.cpp | |
parent | c0c8775271679ac4904bc0bc02a74d28fc75efd0 (diff) | |
download | mana-c7e7b62aa94bf295ca1dc556762ad6070221e0cd.tar.gz mana-c7e7b62aa94bf295ca1dc556762ad6070221e0cd.tar.bz2 mana-c7e7b62aa94bf295ca1dc556762ad6070221e0cd.tar.xz mana-c7e7b62aa94bf295ca1dc556762ad6070221e0cd.zip |
Switched client to use enet and modified login sequence to work with the new protocol from tmwserv.
Diffstat (limited to 'src/net/loginhandler.cpp')
-rw-r--r-- | src/net/loginhandler.cpp | 94 |
1 files changed, 33 insertions, 61 deletions
diff --git a/src/net/loginhandler.cpp b/src/net/loginhandler.cpp index 195e54e9..d65f7001 100644 --- a/src/net/loginhandler.cpp +++ b/src/net/loginhandler.cpp @@ -37,8 +37,7 @@ extern SERVER_INFO **server_info; LoginHandler::LoginHandler() { static const Uint16 _messages[] = { - 0x0069, - 0x006a, + APMSG_LOGIN_RESPONSE, 0 }; handledMessages = _messages; @@ -48,68 +47,41 @@ void LoginHandler::handleMessage(MessageIn *msg) { switch (msg->getId()) { - case 0x0069: - // Skip the length word - msg->skip(2); - - n_server = (msg->getLength() - 47) / 32; - server_info = (SERVER_INFO**)malloc(sizeof(SERVER_INFO*) * n_server); - - mLoginData->session_ID1 = msg->readInt32(); - mLoginData->account_ID = msg->readInt32(); - mLoginData->session_ID2 = msg->readInt32(); - msg->skip(30); // unknown - mLoginData->sex = msg->readInt8(); - - for (int i = 0; i < n_server; i++) + case APMSG_LOGIN_RESPONSE: + int errMsg = msg->readByte(); + // Successful login + if (errMsg == ERRMSG_OK) { - server_info[i] = new SERVER_INFO; - - server_info[i]->address = msg->readInt32(); - server_info[i]->port = msg->readInt16(); - server_info[i]->name = msg->readString(20); - server_info[i]->online_users = msg->readInt32(); - msg->skip(2); // unknown - - logger->log("Network: Server: %s (%s:%d)", - server_info[i]->name.c_str(), - iptostring(server_info[i]->address), - server_info[i]->port); + unsigned char charNumber; + charNumber = msg->readByte(); + printf("Account has %i characters:\n", charNumber); + for (unsigned int i = 0; i < charNumber; i++) { + printf("%i) %s\n", i, msg->readString().c_str()); + } + state = CHAR_SERVER_STATE; } - state = CHAR_SERVER_STATE; - break; - - case 0x006a: - int loginError = msg->readInt8(); - logger->log("Login::error code: %i", loginError); - - switch (loginError) { - case 0: - errorMessage = "Unregistered ID"; - break; - case 1: - errorMessage = "Wrong password"; - break; - case 2: - errorMessage = "Account expired"; - break; - case 3: - errorMessage = "Rejected from server"; - break; - case 4: - errorMessage = "You have been blocked by the GM Team"; - break; - case 6: - errorMessage = "You have been banned for 5 minutes"; - break; - case 9: - errorMessage = "This account is already logged in"; - break; - default: - errorMessage = "Unknown error"; - break; + // Login failed + else + { + switch (errMsg) { + case LOGIN_INVALID_VERSION: + errorMessage = "Client has an insufficient version number to login."; + break; + case ERRMSG_INVALID_ARGUMENT: + errorMessage = "Wrong username or password"; + break; + case ERRMSG_FAILURE: + errorMessage = "Already logged in"; + break; + case LOGIN_SERVER_FULL: + errorMessage = "Server is full"; + break; + default: + errorMessage = "Unknown error"; + break; + } + state = ERROR_STATE; } - state = ERROR_STATE; break; } } |