summaryrefslogtreecommitdiff
path: root/src/map
diff options
context:
space:
mode:
Diffstat (limited to 'src/map')
-rw-r--r--src/map/init.c6
-rw-r--r--src/map/parse.c26
-rw-r--r--src/map/parse.h10
-rw-r--r--src/map/script.c20
-rw-r--r--src/map/script.h1
-rw-r--r--src/map/session.c37
-rw-r--r--src/map/session.h12
-rw-r--r--src/map/sessionext.h12
8 files changed, 123 insertions, 1 deletions
diff --git a/src/map/init.c b/src/map/init.c
index 1af804a..df5e903 100644
--- a/src/map/init.c
+++ b/src/map/init.c
@@ -15,6 +15,7 @@
#include "../../../map/script.h"
#include "map/dummy.h"
+#include "map/parse.h"
#include "map/script.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) */
@@ -38,6 +39,7 @@ HPExport void plugin_init (void) {
pc = GET_SYMBOL("pc");
strlib = GET_SYMBOL("strlib");
session = GET_SYMBOL("session");
+ sockt = GET_SYMBOL("sockt");
addScriptCommand("setcamnpc", "*", dummy);
addScriptCommand("restorecam", "", dummy);
@@ -55,9 +57,11 @@ HPExport void plugin_init (void) {
addScriptCommand("setnpcdir", "*", dummy);
addScriptCommand("rif", "is*", dummyStr);
addScriptCommand("countitemcolor", "*", dummyInt);
- addScriptCommand("getclientversion", "*", dummyInt);
+ addScriptCommand("getclientversion", "", getClientVersion);
// must be replaced to misceffect
addScriptCommand("misceffect2", "i*", dummy);
+
+ addPacket(0x7530, 22, map_parse_version, hpClif_Parse);
}
HPExport void server_preinit (void) {
diff --git a/src/map/parse.c b/src/map/parse.c
new file mode 100644
index 0000000..6257a34
--- /dev/null
+++ b/src/map/parse.c
@@ -0,0 +1,26 @@
+// Copyright (c) Copyright (c) Hercules Dev Team, licensed under GNU GPL.
+// Copyright (c) 2014 Evol developers
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "../../../common/HPMi.h"
+#include "../../../common/malloc.h"
+#include "../../../common/mmo.h"
+#include "../../../common/socket.h"
+#include "../../../common/strlib.h"
+
+#include "map/parse.h"
+#include "map/session.h"
+#include "map/sessionext.h"
+
+void map_parse_version(int fd)
+{
+// struct map_session_data* sd = (struct map_session_data*)session[fd]->session_data;
+// if (!sd)
+// return;
+
+ struct SessionExt *data = session_get(fd);
+ data->clientVersion = RFIFOL(fd, 2);
+}
diff --git a/src/map/parse.h b/src/map/parse.h
new file mode 100644
index 0000000..a4413e4
--- /dev/null
+++ b/src/map/parse.h
@@ -0,0 +1,10 @@
+// Copyright (c) Copyright (c) Hercules Dev Team, licensed under GNU GPL.
+// Copyright (c) 2014 Evol developers
+
+#ifndef EVOL_MAP_PARSE
+#define EVOL_MAP_PARSE
+
+void map_parse_version(int fd);
+void sample_packet0f3(int fd);
+
+#endif // EVOL_MAP_PARSE
diff --git a/src/map/script.c b/src/map/script.c
index 9e72453..074e873 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -14,9 +14,29 @@
#include "../../../map/pc.h"
#include "../../../map/script.h"
+#include "map/session.h"
+#include "map/sessionext.h"
+
BUILDIN(l)
{
// for now not translate and not use format parameters
script_pushstr(st, aStrdup(script_getstr(st, 2)));
return true;
}
+
+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);
+ script_pushint(st, data->clientVersion);
+}
diff --git a/src/map/script.h b/src/map/script.h
index e5c0bbd..f38c714 100644
--- a/src/map/script.h
+++ b/src/map/script.h
@@ -5,5 +5,6 @@
#define EVOL_MAP_SCRIPT
BUILDIN(l);
+BUILDIN(getClientVersion);
#endif // EVOL_MAP_SCRIPT
diff --git a/src/map/session.c b/src/map/session.c
new file mode 100644
index 0000000..d661da2
--- /dev/null
+++ b/src/map/session.c
@@ -0,0 +1,37 @@
+// Copyright (c) Copyright (c) Hercules Dev Team, licensed under GNU GPL.
+// Copyright (c) 2014 Evol developers
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "../../../common/HPMi.h"
+#include "../../../common/malloc.h"
+#include "../../../common/mmo.h"
+#include "../../../common/socket.h"
+#include "../../../common/strlib.h"
+#include "../../../login/login.h"
+
+#include "map/session.h"
+#include "map/sessionext.h"
+
+struct SessionExt *session_get(int fd)
+{
+ struct SessionExt *data = getFromSession(session[fd], 0);
+ if (!data)
+ {
+ data = session_create();
+ addToSession(session[fd], data, 0, true);
+ }
+ return data;
+}
+
+struct SessionExt *session_create(void)
+{
+ struct SessionExt *data = NULL;
+ CREATE(data, struct SessionExt, 1);
+ if (!data)
+ return NULL;
+ data->clientVersion = 0;
+ return data;
+}
diff --git a/src/map/session.h b/src/map/session.h
new file mode 100644
index 0000000..24a82d3
--- /dev/null
+++ b/src/map/session.h
@@ -0,0 +1,12 @@
+// Copyright (c) Copyright (c) Hercules Dev Team, licensed under GNU GPL.
+// Copyright (c) 2014 Evol developers
+
+#ifndef EVOL_MAP_SESSION
+#define EVOL_MAP_SESSION
+
+struct SessionExt;
+
+struct SessionExt *session_get(int fd);
+struct SessionExt *session_create(void);
+
+#endif // EVOL_MAP_SESSION
diff --git a/src/map/sessionext.h b/src/map/sessionext.h
new file mode 100644
index 0000000..e03e276
--- /dev/null
+++ b/src/map/sessionext.h
@@ -0,0 +1,12 @@
+// Copyright (c) Copyright (c) Hercules Dev Team, licensed under GNU GPL.
+// Copyright (c) 2014 Evol developers
+
+#ifndef EVOL_MAP_SESSIONEXT
+#define EVOL_MAP_SESSIONEXT
+
+struct SessionExt
+{
+ int clientVersion;
+};
+
+#endif // EVOL_MAP_SESSIONEXT