summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/map/init.c2
-rw-r--r--src/map/script.c33
-rw-r--r--src/map/script.h1
-rw-r--r--src/map/session.c1
-rw-r--r--src/map/sessionext.h1
5 files changed, 25 insertions, 13 deletions
diff --git a/src/map/init.c b/src/map/init.c
index df5e903..77b19fd 100644
--- a/src/map/init.c
+++ b/src/map/init.c
@@ -48,7 +48,7 @@ HPExport void plugin_init (void) {
addScriptCommand("shop", "s", dummy);
addScriptCommand("getitemlink", "s", dummyStr);
addScriptCommand("l", "s*", l);
- addScriptCommand("getlang", "*", dummyStr);
+ addScriptCommand("getlang", "", getLang);
addScriptCommand("setlang", "i", dummy);
addScriptCommand("requestlang", "*", dummy);
addScriptCommand("getq", "i", dummyInt);
diff --git a/src/map/script.c b/src/map/script.c
index 074e873..8499411 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -17,6 +17,20 @@
#include "map/session.h"
#include "map/sessionext.h"
+#define getData(def) \
+ if (!st->rid) \
+ { \
+ script_pushint(st, 0); \
+ return true; \
+ } \
+ TBL_PC *sd = script->rid2sd(st); \
+ if (!sd) \
+ { \
+ script_pushint(st, 0); \
+ return true; \
+ } \
+ struct SessionExt *data = session_get(sd->fd)
+
BUILDIN(l)
{
// for now not translate and not use format parameters
@@ -26,17 +40,12 @@ BUILDIN(l)
BUILDIN(getClientVersion)
{
- if (!st->rid)
- {
- script_pushint(st, 0);
- return true;
- }
- TBL_PC *sd = script->rid2sd(st);
- if (!sd)
- {
- script_pushint(st, 0);
- return true;
- }
- struct SessionExt *data = session_get(sd->fd);
+ getData(0);
script_pushint(st, data->clientVersion);
}
+
+BUILDIN(getLang)
+{
+ getData(0);
+ script_pushint(st, data->language);
+}
diff --git a/src/map/script.h b/src/map/script.h
index f38c714..0febbb4 100644
--- a/src/map/script.h
+++ b/src/map/script.h
@@ -6,5 +6,6 @@
BUILDIN(l);
BUILDIN(getClientVersion);
+BUILDIN(getLang);
#endif // EVOL_MAP_SCRIPT
diff --git a/src/map/session.c b/src/map/session.c
index d661da2..a96cbe9 100644
--- a/src/map/session.c
+++ b/src/map/session.c
@@ -33,5 +33,6 @@ struct SessionExt *session_create(void)
if (!data)
return NULL;
data->clientVersion = 0;
+ data->language = 0;
return data;
}
diff --git a/src/map/sessionext.h b/src/map/sessionext.h
index e03e276..cd94393 100644
--- a/src/map/sessionext.h
+++ b/src/map/sessionext.h
@@ -7,6 +7,7 @@
struct SessionExt
{
int clientVersion;
+ int language;
};
#endif // EVOL_MAP_SESSIONEXT