summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDennis Friis <peavey@inspircd.org>2009-05-25 05:23:40 +0200
committerDennis Friis <peavey@inspircd.org>2009-05-25 05:28:03 +0200
commitef006ed117bb602a928d33dc0fe90075efd7393f (patch)
treed82e8b7a1aedc7999c232d08bd12d0c50a343f9a /src
parent050103b8d2e3eb23e7aea188a1a269feb7c181ab (diff)
downloadmana-ef006ed117bb602a928d33dc0fe90075efd7393f.tar.gz
mana-ef006ed117bb602a928d33dc0fe90075efd7393f.tar.bz2
mana-ef006ed117bb602a928d33dc0fe90075efd7393f.tar.xz
mana-ef006ed117bb602a928d33dc0fe90075efd7393f.zip
Add athena netcode for changing account password.
Diffstat (limited to 'src')
-rw-r--r--src/main.cpp36
-rw-r--r--src/main.h2
-rw-r--r--src/net/ea/loginhandler.cpp36
-rw-r--r--src/net/ea/network.cpp2
-rw-r--r--src/net/ea/protocol.h2
5 files changed, 73 insertions, 5 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 92fdf2f2..2bf9820e 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -710,7 +710,6 @@ struct ErrorListener : public gcn::ActionListener
}
} errorListener;
-#ifdef TMWSERV_SUPPORT
struct AccountListener : public gcn::ActionListener
{
void action(const gcn::ActionEvent &event)
@@ -719,6 +718,7 @@ struct AccountListener : public gcn::ActionListener
}
} accountListener;
+#ifdef TMWSERV_SUPPORT
struct LoginListener : public gcn::ActionListener
{
void action(const gcn::ActionEvent &event)
@@ -1343,8 +1343,16 @@ int main(int argc, char *argv[])
loadUpdates();
break;
- // Those states don't cause a network disconnect
+ // Those states don't cause a network disconnect
case STATE_LOADDATA:
+ case STATE_CHANGEPASSWORD_ATTEMPT:
+ case STATE_CHANGEPASSWORD:
+ case STATE_ACCOUNTCHANGE_ERROR:
+ break;
+
+ case STATE_CHAR_SELECT:
+ if (state == STATE_CONNECTING)
+ network->disconnect();
break;
case STATE_ACCOUNT:
@@ -1539,6 +1547,30 @@ int main(int argc, char *argv[])
accountLogin(network, &loginData);
break;
+ case STATE_CHANGEPASSWORD_ATTEMPT:
+ logger->log("State: CHANGE PASSWORD ATTEMPT");
+ Net::getLoginHandler()->changePassword(loginData.username,
+ loginData.password,
+ loginData.newPassword);
+ break;
+
+ case STATE_CHANGEPASSWORD:
+ logger->log("State: CHANGE PASSWORD");
+ currentDialog = new OkDialog("Password change",
+ "Password changed successfully!");
+ currentDialog->addActionListener(&accountListener);
+ currentDialog = NULL; // OkDialog deletes itself
+ loginData.password = loginData.newPassword;
+ loginData.newPassword = "";
+ break;
+
+ case STATE_ACCOUNTCHANGE_ERROR:
+ logger->log("State: ACCOUNT CHANGE ERROR");
+ currentDialog = new OkDialog("Error ", errorMessage);
+ currentDialog->addActionListener(&accountListener);
+ currentDialog = NULL; // OkDialog deletes itself
+ break;
+
default:
state = STATE_EXIT;
break;
diff --git a/src/main.h b/src/main.h
index d33ea14d..c0d0a5bd 100644
--- a/src/main.h
+++ b/src/main.h
@@ -89,13 +89,13 @@ enum State {
STATE_UPDATE,
STATE_CHANGEPASSWORD_ATTEMPT,
STATE_CHANGEPASSWORD,
+ STATE_ACCOUNTCHANGE_ERROR,
#ifdef TMWSERV_SUPPORT
STATE_CHOOSE_SERVER,
STATE_CONNECT_ACCOUNT,
STATE_LOGIN_ATTEMPT,
STATE_LOGIN_ERROR,
STATE_REGISTER_ATTEMPT,
- STATE_ACCOUNTCHANGE_ERROR,
STATE_CHANGEEMAIL_ATTEMPT,
STATE_CHANGEEMAIL,
STATE_UNREGISTER_ATTEMPT,
diff --git a/src/net/ea/loginhandler.cpp b/src/net/ea/loginhandler.cpp
index 31d2c020..8f66343f 100644
--- a/src/net/ea/loginhandler.cpp
+++ b/src/net/ea/loginhandler.cpp
@@ -46,6 +46,7 @@ LoginHandler::LoginHandler()
SMSG_UPDATE_HOST,
SMSG_LOGIN_DATA,
SMSG_LOGIN_ERROR,
+ SMSG_CHAR_PASSWORD_RESPONSE,
0
};
handledMessages = _messages;
@@ -58,6 +59,37 @@ void LoginHandler::handleMessage(MessageIn &msg)
switch (msg.getId())
{
+ case SMSG_CHAR_PASSWORD_RESPONSE:
+ {
+ // 0: acc not found, 1: success, 2: password mismatch, 3: pass too short
+ int errMsg = msg.readInt8();
+ // Successful pass change
+ if (errMsg == 1)
+ {
+ state = STATE_CHANGEPASSWORD;
+ }
+ // pass change failed
+ else
+ {
+ switch (errMsg) {
+ case 0:
+ errorMessage = _("Account not connected. Please login first.");
+ break;
+ case 2:
+ errorMessage = _("Old password incorrect");
+ break;
+ case 3:
+ errorMessage = _("New password too short");
+ break;
+ default:
+ errorMessage = _("Unknown error");
+ break;
+ }
+ state = STATE_ACCOUNTCHANGE_ERROR;
+ }
+ }
+ break;
+
case SMSG_UPDATE_HOST:
int len;
@@ -157,7 +189,9 @@ void LoginHandler::changePassword(const std::string &username,
const std::string &oldPassword,
const std::string &newPassword)
{
- // TODO
+ MessageOut outMsg(CMSG_CHAR_PASSWORD_CHANGE);
+ outMsg.writeString(oldPassword, 24);
+ outMsg.writeString(newPassword, 24);
}
void LoginHandler::chooseServer(int server)
diff --git a/src/net/ea/network.cpp b/src/net/ea/network.cpp
index 7b731de3..956d7877 100644
--- a/src/net/ea/network.cpp
+++ b/src/net/ea/network.cpp
@@ -40,7 +40,7 @@ short packet_lengths[] = {
// #0x0040
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, -1, 55, 17, 3, 37, 46, -1, 23, -1, 3,108, 3, 2,
+ 0, 50, 3, -1, 55, 17, 3, 37, 46, -1, 23, -1, 3,108, 3, 2,
3, 28, 19, 11, 3, -1, 9, 5, 54, 53, 58, 60, 41, 2, 6, 6,
// #0x0080
7, 3, 2, 2, 2, 5, 16, 12, 10, 7, 29, 23, -1, -1, -1, 0,
diff --git a/src/net/ea/protocol.h b/src/net/ea/protocol.h
index 5362ab0c..b3759946 100644
--- a/src/net/ea/protocol.h
+++ b/src/net/ea/protocol.h
@@ -42,6 +42,7 @@ static const int STORAGE_OFFSET = 1;
#define SMSG_CHAR_DELETE_SUCCEEDED 0x006f
#define SMSG_CHAR_DELETE_FAILED 0x0070
#define SMSG_CHAR_MAP_INFO 0x0071
+#define SMSG_CHAR_PASSWORD_RESPONSE 0x0062 /**< Custom packet reply to password change request */
#define SMSG_MAP_LOGIN_SUCCESS 0x0073 /**< Contains starting location */
#define SMSG_PLAYER_UPDATE_1 0x01d8
@@ -141,6 +142,7 @@ static const int STORAGE_OFFSET = 1;
/**********************************
* Packets from client to server *
**********************************/
+#define CMSG_CHAR_PASSWORD_CHANGE 0x0061 /**< Custom change password packet */
#define CMSG_CHAR_SERVER_CONNECT 0x0065
#define CMSG_CHAR_SELECT 0x0066
#define CMSG_CHAR_CREATE 0x0067