From c5bbc349b176c045dab7e9ddea12cb18eee7a176 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Fri, 14 Nov 2014 22:13:01 +0300 Subject: store character language in script variables. --- src/map/init.c | 5 +++++ src/map/pc.c | 16 ++++++++++++++++ src/map/pc.h | 2 ++ 3 files changed, 23 insertions(+) (limited to 'src') diff --git a/src/map/init.c b/src/map/init.c index cb09ae3..c0eef38 100644 --- a/src/map/init.c +++ b/src/map/init.c @@ -21,6 +21,8 @@ #include "../../../common/HPMDataCheck.h" /* should always be the last file included! (if you don't make it last, it'll intentionally break compile time) */ +extern int langScriptId; + HPExport struct hplugin_info pinfo = { "evol_map", @@ -62,6 +64,9 @@ HPExport void plugin_init (void) addPacket(0x7530, 22, map_parse_version, hpClif_Parse); addHookPre("pc->readparam", epc_readparam_pre); + addHookPre("pc->setregistry", epc_setregistry); + + langScriptId = script->add_str("Lang"); } HPExport void server_preinit (void) diff --git a/src/map/pc.c b/src/map/pc.c index d1ad03c..b07f187 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -15,6 +15,8 @@ #include "map/session.h" #include "map/sessionext.h" +int langScriptId; + int epc_readparam_pre(struct map_session_data* sd, int *type) { if (*type == Const_ClientVersion) @@ -27,3 +29,17 @@ int epc_readparam_pre(struct map_session_data* sd, int *type) } return 0; } + +int epc_setregistry(struct map_session_data *sd, int64 *reg, int *val) +{ + if (*reg == langScriptId) + { + struct SessionExt *data = session_get_bysd(sd); + if (!data) + return 0; + + data->language = *val; + } + + return 0; +} diff --git a/src/map/pc.h b/src/map/pc.h index d9867ee..2f07c92 100644 --- a/src/map/pc.h +++ b/src/map/pc.h @@ -11,4 +11,6 @@ enum VarConst int epc_readparam_pre(struct map_session_data* sd, int *type); +int epc_setregistry(struct map_session_data *sd, int64 *reg, int *val); + #endif // EVOL_MAP_PC -- cgit v1.2.3-60-g2f50