From a64d627afaf3c2211de164cc25325323092db3cc Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Fri, 14 Nov 2014 13:13:06 +0300 Subject: Add internal variable with client version. New variable: ClientVersion --- src/Makefile.am | 2 ++ src/map/init.c | 2 ++ src/map/parse.h | 3 +++ src/map/pc.c | 29 +++++++++++++++++++++++++++++ src/map/pc.h | 14 ++++++++++++++ 5 files changed, 50 insertions(+) create mode 100644 src/map/pc.c create mode 100644 src/map/pc.h diff --git a/src/Makefile.am b/src/Makefile.am index 6099737..5c0befa 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -15,6 +15,8 @@ MAP_SRC = map/dummy.c \ map/init.c \ map/parse.c \ map/parse.h \ + map/pc.c \ + map/pc.h \ map/script.c \ map/script.h \ map/session.c \ diff --git a/src/map/init.c b/src/map/init.c index c9536e7..2381de5 100644 --- a/src/map/init.c +++ b/src/map/init.c @@ -17,6 +17,7 @@ #include "map/dummy.h" #include "map/parse.h" #include "map/script.h" +#include "map/pc.h" #include "../../../common/HPMDataCheck.h" /* should always be the last file included! (if you don't make it last, it'll intentionally break compile time) */ @@ -60,6 +61,7 @@ HPExport void plugin_init (void) addScriptCommand("misceffect2", "i*", dummy); addPacket(0x7530, 22, map_parse_version, hpClif_Parse); + addHookPre("pc->readparam", epc_readparam_pre); } HPExport void server_preinit (void) diff --git a/src/map/parse.h b/src/map/parse.h index a4413e4..ea45975 100644 --- a/src/map/parse.h +++ b/src/map/parse.h @@ -7,4 +7,7 @@ void map_parse_version(int fd); void sample_packet0f3(int fd); +int epc_parse_setparam_pre(struct map_session_data *sd, int *type, int *val); +int epc_parse_readparam_pre(struct map_session_data* sd, int *type); + #endif // EVOL_MAP_PARSE diff --git a/src/map/pc.c b/src/map/pc.c new file mode 100644 index 0000000..d1ad03c --- /dev/null +++ b/src/map/pc.c @@ -0,0 +1,29 @@ +// Copyright (c) Copyright (c) Hercules Dev Team, licensed under GNU GPL. +// Copyright (c) 2014 Evol developers + +#include +#include +#include + +#include "../../../common/HPMi.h" +#include "../../../common/malloc.h" +#include "../../../common/mmo.h" +#include "../../../common/socket.h" +#include "../../../common/strlib.h" + +#include "map/pc.h" +#include "map/session.h" +#include "map/sessionext.h" + +int epc_readparam_pre(struct map_session_data* sd, int *type) +{ + if (*type == Const_ClientVersion) + { + hookStop(); + struct SessionExt *data = session_get_bysd(sd); + if (!data) + return 0; + return data->clientVersion; + } + return 0; +} diff --git a/src/map/pc.h b/src/map/pc.h new file mode 100644 index 0000000..d9867ee --- /dev/null +++ b/src/map/pc.h @@ -0,0 +1,14 @@ +// Copyright (c) Copyright (c) Hercules Dev Team, licensed under GNU GPL. +// Copyright (c) 2014 Evol developers + +#ifndef EVOL_MAP_PC +#define EVOL_MAP_PC + +enum VarConst +{ + Const_ClientVersion = 10000 +}; + +int epc_readparam_pre(struct map_session_data* sd, int *type); + +#endif // EVOL_MAP_PC -- cgit v1.2.3-70-g09d2