From f8b3342f690816022d26038389431002e9cf3648 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Thu, 13 Aug 2015 22:53:12 +0300 Subject: Fix and restore client version in login and char server. --- src/echar/char.c | 14 ++++++++++++++ src/echar/char.h | 4 ++++ src/echar/init.c | 2 ++ src/elogin/init.c | 1 + src/elogin/parse.c | 13 +++++++++++++ src/elogin/parse.h | 1 + 6 files changed, 35 insertions(+) diff --git a/src/echar/char.c b/src/echar/char.c index 6a01e8f..409da75 100644 --- a/src/echar/char.c +++ b/src/echar/char.c @@ -88,6 +88,20 @@ void echar_parse_char_create_new_char(int *fdPtr, struct char_session_data* sd) hookStop(); } +static int tmpVersion = 0; + +void echar_parse_char_connect_pre(int *fdPtr, struct char_session_data *sd, uint32 *ipl) +{ + tmpVersion = RFIFOW(*fdPtr, 14); +} + +void echar_parse_char_connect_post(int *fdPtr, struct char_session_data *sd, uint32 *ipl) +{ + sd = (struct char_session_data*)session[*fdPtr]->session_data; + if (sd) + sd->version = tmpVersion; +} + void echar_creation_failed(int *fdPtr, int *result) { const int fd = *fdPtr; diff --git a/src/echar/char.h b/src/echar/char.h index 27994ba..1bf9923 100644 --- a/src/echar/char.h +++ b/src/echar/char.h @@ -26,4 +26,8 @@ int echar_mmo_char_send_characters(int retVal, int *fdPtr, struct char_session_d void send_additional_slots(int fd, struct char_session_data* sd); +void echar_parse_char_connect_pre(int *fdPtr, struct char_session_data *sd, uint32 *ipl); + +void echar_parse_char_connect_post(int *fdPtr, struct char_session_data *sd, uint32 *ipl); + #endif // EVOL_CHAR_CHAR diff --git a/src/echar/init.c b/src/echar/init.c index 0fa8c62..6fdd887 100644 --- a/src/echar/init.c +++ b/src/echar/init.c @@ -65,9 +65,11 @@ HPExport void plugin_init (void) addHookPre("chr->parse_char_create_new_char", echar_parse_char_create_new_char); addHookPre("chr->creation_failed", echar_creation_failed); + addHookPre("chr->parse_char_connect", echar_parse_char_connect_pre); addHookPost("chr->mmo_char_send099d", echar_mmo_char_send099d); addHookPost("chr->mmo_char_send_characters", echar_mmo_char_send_characters); + addHookPost("chr->parse_char_connect", echar_parse_char_connect_post); } HPExport void server_preinit (void) diff --git a/src/elogin/init.c b/src/elogin/init.c index e0411bd..7d112ea 100644 --- a/src/elogin/init.c +++ b/src/elogin/init.c @@ -39,6 +39,7 @@ HPExport void plugin_init (void) addHookPre("login->parse_client_login", elogin_parse_client_login_pre); addHookPre("login->check_password", elogin_check_password); addHookPre("login->parse_ping", elogin_parse_ping); + addHookPost("login->parse_client_login", elogin_parse_client_login_post); } HPExport void server_preinit (void) diff --git a/src/elogin/parse.c b/src/elogin/parse.c index 3a015d1..657ef7e 100644 --- a/src/elogin/parse.c +++ b/src/elogin/parse.c @@ -67,9 +67,22 @@ int elogin_parse_client_login_pre(int *fdPtr, return 1; } + short *ptr = RFIFOP(fd, 2); + if (*ptr == 20) + *ptr = clientVersion; return 0; } +int elogin_parse_client_login_post(int retVal, int *fdPtr, + struct login_session_data* sd, + const char *const ip __attribute__ ((unused))) +{ + sd = (struct login_session_data*)session[*fdPtr]->session_data; + if (sd) + sd->version = clientVersion; + return retVal; +} + void elogin_parse_client_login2(int fd) { char username[NAME_LENGTH]; diff --git a/src/elogin/parse.h b/src/elogin/parse.h index ad76331..400d2f4 100644 --- a/src/elogin/parse.h +++ b/src/elogin/parse.h @@ -6,6 +6,7 @@ void login_parse_version(int fd); int elogin_parse_client_login_pre(int *fd, struct login_session_data* sd, const char *const ip); +int elogin_parse_client_login_post(int retVal, int *fd, struct login_session_data* sd, const char *const ip); void elogin_parse_client_login2(int fd); void elogin_parse_ping(int *fd, struct login_session_data* sd); void elogin_parse_change_paassword(int fd); -- cgit v1.2.3-70-g09d2