From d90e0eb2f1b54b06cd7d4d1bbee3462889f5a7d0 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Fri, 7 Nov 2014 01:51:49 +0300 Subject: Impliment script command: setlang. --- src/map/init.c | 2 +- src/map/script.c | 24 +++++++++++++++++++----- src/map/script.h | 1 + 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/src/map/init.c b/src/map/init.c index 77b19fd..fe4d6d2 100644 --- a/src/map/init.c +++ b/src/map/init.c @@ -49,7 +49,7 @@ HPExport void plugin_init (void) { addScriptCommand("getitemlink", "s", dummyStr); addScriptCommand("l", "s*", l); addScriptCommand("getlang", "", getLang); - addScriptCommand("setlang", "i", dummy); + addScriptCommand("setlang", "i", setLang); addScriptCommand("requestlang", "*", dummy); addScriptCommand("getq", "i", dummyInt); addScriptCommand("setq", "ii", dummy); diff --git a/src/map/script.c b/src/map/script.c index 8499411..bbc2b52 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -17,20 +17,28 @@ #include "map/session.h" #include "map/sessionext.h" -#define getData(def) \ +#define getDataReturn(def) \ if (!st->rid) \ { \ - script_pushint(st, 0); \ + script_pushint(st, def); \ return true; \ } \ TBL_PC *sd = script->rid2sd(st); \ if (!sd) \ { \ - script_pushint(st, 0); \ + script_pushint(st, def); \ return true; \ } \ struct SessionExt *data = session_get(sd->fd) +#define getData() \ + if (!st->rid) \ + return true; \ + TBL_PC *sd = script->rid2sd(st); \ + if (!sd) \ + return true; \ + struct SessionExt *data = session_get(sd->fd) + BUILDIN(l) { // for now not translate and not use format parameters @@ -40,12 +48,18 @@ BUILDIN(l) BUILDIN(getClientVersion) { - getData(0); + getDataReturn(0); script_pushint(st, data->clientVersion); } BUILDIN(getLang) { - getData(0); + getDataReturn(0); script_pushint(st, data->language); } + +BUILDIN(setLang) +{ + getData(); + data->language = script_getint(st, 2); +} diff --git a/src/map/script.h b/src/map/script.h index 0febbb4..0d0bbda 100644 --- a/src/map/script.h +++ b/src/map/script.h @@ -7,5 +7,6 @@ BUILDIN(l); BUILDIN(getClientVersion); BUILDIN(getLang); +BUILDIN(setLang); #endif // EVOL_MAP_SCRIPT -- cgit v1.2.3-70-g09d2