diff options
author | Andrei Karas <akaras@inbox.ru> | 2016-08-10 01:03:32 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2016-08-10 01:03:32 +0300 |
commit | cb10231838c918dbf380899a947599331818a4bc (patch) | |
tree | 7f92446dd65643a81d7ddf0419ff1c4c60be73be /src/echar | |
parent | 725fb53014ab7d48d43d69f0c1ca21354ef8619c (diff) | |
download | plugin-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/echar')
-rw-r--r-- | src/echar/char.c | 28 | ||||
-rw-r--r-- | src/echar/char.h | 4 | ||||
-rw-r--r-- | src/echar/init.c | 1 |
3 files changed, 33 insertions, 0 deletions
diff --git a/src/echar/char.c b/src/echar/char.c index e5649ad..26e6c61 100644 --- a/src/echar/char.c +++ b/src/echar/char.c @@ -14,6 +14,7 @@ #include "common/socket.h" #include "common/strlib.h" #include "common/sql.h" +#include "common/utils.h" #include "common/timer.h" #include "char/char.h" #include "char/inter.h" @@ -320,3 +321,30 @@ void echar_parse_frommap_request_stats_report_pre(int *fdPtr) RFIFOFLUSH(fd); hookStop(); } + +void echar_parse_map_serverexit(int mapFd) +{ + const int code = RFIFOW(mapFd, 2); + switch (code) + { + case 100: // all exit + case 101: // all restart + case 102: // restart char and map server + echat_send_login_serverexit(code); + HSleep(1); + core->shutdown_callback(); + break; + case 103: // restart map server + break; + default: + ShowWarning("Unknown termination code: %d\n", code); + } +} + +void echat_send_login_serverexit(const int code) +{ + WFIFOHEAD(chr->login_fd, 4); + WFIFOW(chr->login_fd, 0) = 0x5003; + WFIFOW(chr->login_fd, 2) = code; + WFIFOSET(chr->login_fd, 4); +} diff --git a/src/echar/char.h b/src/echar/char.h index 726f2c2..e05bde0 100644 --- a/src/echar/char.h +++ b/src/echar/char.h @@ -27,4 +27,8 @@ void echar_parse_char_connect_post(int fd, struct char_session_data *sd, uint32 void echar_parse_frommap_request_stats_report_pre(int *fdPtr); +void echar_parse_map_serverexit(int mapFd); + +void echat_send_login_serverexit(const int code); + #endif // EVOL_CHAR_CHAR diff --git a/src/echar/init.c b/src/echar/init.c index e876065..c8b7e0b 100644 --- a/src/echar/init.c +++ b/src/echar/init.c @@ -51,6 +51,7 @@ HPExport void plugin_init (void) { addPacket(0x0061, 50, echar_parse_change_paassword, hpParse_Char); addPacket(0x5001, 7, echar_parse_login_password_change_ack, hpParse_FromLogin); + addPacket(0x5002, 4, echar_parse_map_serverexit, hpParse_FromMap); addHookPre(chr, parse_char_create_new_char, echar_parse_char_create_new_char); addHookPre(chr, creation_failed, echar_creation_failed); |