summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-11-07 01:51:49 +0300
committerAndrei Karas <akaras@inbox.ru>2014-11-07 01:51:49 +0300
commitd90e0eb2f1b54b06cd7d4d1bbee3462889f5a7d0 (patch)
tree83651271683ab1fd15610c5f8da08cbd5600ade4
parentb30129688a0e8b6e353447d7af579a6b2c2505c8 (diff)
downloadevol-hercules-d90e0eb2f1b54b06cd7d4d1bbee3462889f5a7d0.tar.gz
evol-hercules-d90e0eb2f1b54b06cd7d4d1bbee3462889f5a7d0.tar.bz2
evol-hercules-d90e0eb2f1b54b06cd7d4d1bbee3462889f5a7d0.tar.xz
evol-hercules-d90e0eb2f1b54b06cd7d4d1bbee3462889f5a7d0.zip
Impliment script command: setlang.
-rw-r--r--src/map/init.c2
-rw-r--r--src/map/script.c24
-rw-r--r--src/map/script.h1
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