summaryrefslogtreecommitdiff
path: root/src/emap
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2016-08-10 01:03:32 +0300
committerAndrei Karas <akaras@inbox.ru>2016-08-10 01:03:32 +0300
commitcb10231838c918dbf380899a947599331818a4bc (patch)
tree7f92446dd65643a81d7ddf0419ff1c4c60be73be /src/emap
parent725fb53014ab7d48d43d69f0c1ca21354ef8619c (diff)
downloadplugin-cb10231838c918dbf380899a947599331818a4bc.tar.gz
plugin-cb10231838c918dbf380899a947599331818a4bc.tar.bz2
plugin-cb10231838c918dbf380899a947599331818a4bc.tar.xz
plugin-cb10231838c918dbf380899a947599331818a4bc.zip
Add gm command for send restart events to all servers.
For now it support only one char and one map server. For support this actions need use hercules wrapper.
Diffstat (limited to 'src/emap')
-rw-r--r--src/emap/atcommand.c21
-rw-r--r--src/emap/atcommand.h1
-rw-r--r--src/emap/init.c1
-rw-r--r--src/emap/inter.c23
-rw-r--r--src/emap/inter.h9
5 files changed, 54 insertions, 1 deletions
diff --git a/src/emap/atcommand.c b/src/emap/atcommand.c
index 7c3f345..1928620 100644
--- a/src/emap/atcommand.c
+++ b/src/emap/atcommand.c
@@ -23,6 +23,7 @@
#include "emap/atcommand.h"
#include "emap/lang.h"
+#include "emap/inter.h"
const char* eatcommand_msgsd_pre(struct map_session_data **sdPtr,
int *msgPtr)
@@ -132,11 +133,29 @@ ACMD2(slide)
ACMD1(mapExit)
{
+ int code = 1;
+ if (!*message || sscanf(message, "%5d", &code) < 1)
+ code = 1;
+
+ map->retval = code;
+ map->do_shutdown();
+ return true;
+}
+
+// 100 - terminate all servers
+// 101 - restart all servers
+// 102 - restart char and map servers
+// 103 - restart map server
+ACMD1(serverExit)
+{
int code = 0;
if (!*message || sscanf(message, "%5d", &code) < 1)
- code = 0;
+ return false;
+
+ send_char_exit(code);
map->retval = code;
map->do_shutdown();
+
return true;
}
diff --git a/src/emap/atcommand.h b/src/emap/atcommand.h
index cd4cd41..95e7e75 100644
--- a/src/emap/atcommand.h
+++ b/src/emap/atcommand.h
@@ -22,5 +22,6 @@ const char* eatcommand_msgfd_pre(int *fdPtr,
ACMD2(setSkill);
ACMD2(slide);
ACMD1(mapExit);
+ACMD1(serverExit);
#endif // EVOL_MAP_ATCOMMAND
diff --git a/src/emap/init.c b/src/emap/init.c
index 33d5025..cb14450 100644
--- a/src/emap/init.c
+++ b/src/emap/init.c
@@ -94,6 +94,7 @@ HPExport void plugin_init (void)
addAtcommand("setskill", setSkill);
addAtcommand("slide", slide);
addAtcommand("mapexit", mapExit);
+ addAtcommand("serverexit", serverExit);
addScriptCommand("chatjoin", "i*", chatJoin);
addScriptCommand("setcamnpc", "*", setCamNpc);
diff --git a/src/emap/inter.c b/src/emap/inter.c
new file mode 100644
index 0000000..8f36be9
--- /dev/null
+++ b/src/emap/inter.c
@@ -0,0 +1,23 @@
+// Copyright (c) Copyright (c) Hercules Dev Team, licensed under GNU GPL.
+// Copyright (c) 2014 - 2015 Evol developers
+
+#include "common/hercules.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "common/HPMi.h"
+#include "common/memmgr.h"
+#include "common/nullpo.h"
+#include "common/socket.h"
+#include "common/strlib.h"
+#include "map/chrif.h"
+
+void send_char_exit(const int code)
+{
+ WFIFOHEAD(chrif->fd, 4);
+ WFIFOW(chrif->fd, 0) = 0x5002;
+ WFIFOW(chrif->fd, 2) = code;
+ WFIFOSET(chrif->fd, 4);
+}
diff --git a/src/emap/inter.h b/src/emap/inter.h
new file mode 100644
index 0000000..2876ee8
--- /dev/null
+++ b/src/emap/inter.h
@@ -0,0 +1,9 @@
+// Copyright (c) Copyright (c) Hercules Dev Team, licensed under GNU GPL.
+// Copyright (c) 2014 - 2015 Evol developers
+
+#ifndef EVOL_MAP_INTER
+#define EVOL_MAP_INTER
+
+void send_char_exit(const int code);
+
+#endif // EVOL_MAP_INTER