summaryrefslogtreecommitdiff
path: root/src/login
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2015-04-15 12:56:09 +0300
committerAndrei Karas <akaras@inbox.ru>2015-04-15 12:56:46 +0300
commit555eb0850d0e46aa25de88c15d2f00fbe62385f5 (patch)
tree305a9ab595692591f4f1be8e633ba2861975c8cc /src/login
parent293793b7027029efc87c8b657a0c45d26e0840c5 (diff)
downloadevol-hercules-555eb0850d0e46aa25de88c15d2f00fbe62385f5.tar.gz
evol-hercules-555eb0850d0e46aa25de88c15d2f00fbe62385f5.tar.bz2
evol-hercules-555eb0850d0e46aa25de88c15d2f00fbe62385f5.tar.xz
evol-hercules-555eb0850d0e46aa25de88c15d2f00fbe62385f5.zip
Add support for change password packet.
Change server version to 6.
Diffstat (limited to 'src/login')
-rw-r--r--src/login/init.c1
-rw-r--r--src/login/parse.c35
-rw-r--r--src/login/parse.h1
-rw-r--r--src/login/send.c11
-rw-r--r--src/login/send.h1
5 files changed, 48 insertions, 1 deletions
diff --git a/src/login/init.c b/src/login/init.c
index 18ac7e0..06e747b 100644
--- a/src/login/init.c
+++ b/src/login/init.c
@@ -35,6 +35,7 @@ HPExport void plugin_init (void)
addPacket(0x7530, 22, login_parse_version, hpParse_Login);
addPacket(0x027c, 95, elogin_parse_client_login2, hpParse_Login);
+ addPacket(0x5000, 54, elogin_parse_change_paassword, hpParse_FromChar);
addHookPre("login->parse_client_login", elogin_parse_client_login_pre);
addHookPre("login->parse_request_connection", elogin_parse_request_connection);
addHookPre("login->check_password", elogin_check_password);
diff --git a/src/login/parse.c b/src/login/parse.c
index f2e2592..53fa28f 100644
--- a/src/login/parse.c
+++ b/src/login/parse.c
@@ -16,6 +16,7 @@
#include "common/ip.h"
#include "login/config.h"
+#include "login/md5calc.h"
#include "login/parse.h"
#include "login/send.h"
@@ -173,3 +174,37 @@ void elogin_parse_ping(int *fd, struct login_session_data* sd)
}
hookStop();
}
+
+void elogin_parse_change_paassword(int fd)
+{
+ char actual_pass[24], new_pass[24];
+ int status = 0;
+ struct mmo_account acc;
+ const int accountId = RFIFOL (fd, 2);
+
+ memcpy (actual_pass, RFIFOP (fd, 6), 24);
+ actual_pass[23] = '\0';
+ memcpy (new_pass, RFIFOP (fd, 30), 24);
+ new_pass[23] = '\0';
+
+ if (!login->accounts->load_num(login->accounts, &acc, accountId))
+ {
+ // account not found
+ send_char_password_change_ack(fd, accountId, 0);
+ return;
+ }
+
+ if (!strcmp(actual_pass, acc.pass) || pass_ok(actual_pass, acc.pass))
+ {
+ // changed ok
+ status = 1;
+ safestrncpy(acc.pass, new_pass, sizeof(acc.pass));
+ login->accounts->save(login->accounts, &acc);
+ }
+ else
+ {
+ // wrong password
+ status = 2;
+ }
+ send_char_password_change_ack(fd, accountId, status);
+}
diff --git a/src/login/parse.h b/src/login/parse.h
index 31d0d0c..b5c2418 100644
--- a/src/login/parse.h
+++ b/src/login/parse.h
@@ -9,5 +9,6 @@ int elogin_parse_client_login_pre(int *fd, struct login_session_data* sd, const
void elogin_parse_client_login2(int fd);
void elogin_parse_request_connection(int *fd, struct login_session_data* sd, const char *const ip);
void elogin_parse_ping(int *fd, struct login_session_data* sd);
+void elogin_parse_change_paassword(int fd);
#endif // EVOL_LOGIN_PARSE
diff --git a/src/login/send.c b/src/login/send.c
index abb85da..420028c 100644
--- a/src/login/send.c
+++ b/src/login/send.c
@@ -21,7 +21,7 @@ void send_server_version(int fd)
WFIFOW(fd, 0) = 0x7531;
WFIFOW(fd, 2) = 4 + 8;
WFIFOL(fd, 4) = 0; // unused
- WFIFOL(fd, 8) = 5; // server version
+ WFIFOL(fd, 8) = 6; // server version
WFIFOSET(fd, WFIFOW(fd,2));
}
@@ -36,3 +36,12 @@ void send_update_host(int fd)
memcpy(WFIFOP (fd, 4), update_server, sz);
WFIFOSET(fd, sz + 4);
}
+
+void send_char_password_change_ack(int fd, int accoundId, char status)
+{
+ WFIFOHEAD(fd, 7);
+ WFIFOW(fd, 0) = 0x5001;
+ WFIFOL(fd, 2) = accoundId;
+ WFIFOB(fd, 6) = status;
+ WFIFOSET(fd, 7);
+}
diff --git a/src/login/send.h b/src/login/send.h
index 1c7ec27..5fdb6c4 100644
--- a/src/login/send.h
+++ b/src/login/send.h
@@ -6,5 +6,6 @@
void send_server_version();
void send_update_host(int fd);
+void send_char_password_change_ack(int fd, int accoundId, char status);
#endif // EVOL_LOGIN_SEND