diff options
author | Haru <haru@dotalux.com> | 2019-08-26 01:38:26 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-08-26 01:38:26 +0200 |
commit | 29e6bbef1b7d4c2434cc6bc8e7a0226227ec6281 (patch) | |
tree | 2a87caab4d2a26e279af63dd02871f6553021449 /src/map/pc.c | |
parent | dae5933998758c4fcf8a7dde452d34a3b8fd052c (diff) | |
parent | 0f5da8e9f5ef70c9d2e845c1e69e2b2024094ee9 (diff) | |
download | hercules-29e6bbef1b7d4c2434cc6bc8e7a0226227ec6281.tar.gz hercules-29e6bbef1b7d4c2434cc6bc8e7a0226227ec6281.tar.bz2 hercules-29e6bbef1b7d4c2434cc6bc8e7a0226227ec6281.tar.xz hercules-29e6bbef1b7d4c2434cc6bc8e7a0226227ec6281.zip |
Merge pull request #2522 from MishimaHaruna/remove-inter-roundtrips
Remove some round-trips to the inter-server
Diffstat (limited to 'src/map/pc.c')
-rw-r--r-- | src/map/pc.c | 54 |
1 files changed, 52 insertions, 2 deletions
diff --git a/src/map/pc.c b/src/map/pc.c index 1e7ac5817..24f71f47b 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -10990,7 +10990,7 @@ static int map_day_timer(int tid, int64 tick, int id, intptr_t data) map->night_flag = 0; // 0=day, 1=night [Yor] map->foreachpc(pc->daynight_timer_sub); safestrncpy(tmp_soutput, (data == 0) ? msg_txt(502) : msg_txt(60), sizeof(tmp_soutput)); // The day has arrived! - intif->broadcast(tmp_soutput, (int)strlen(tmp_soutput) + 1, BC_DEFAULT); + clif->broadcast(NULL, tmp_soutput, (int)strlen(tmp_soutput) + 1, BC_DEFAULT, ALL_CLIENT); return 0; } @@ -11011,7 +11011,7 @@ static int map_night_timer(int tid, int64 tick, int id, intptr_t data) map->night_flag = 1; // 0=day, 1=night [Yor] map->foreachpc(pc->daynight_timer_sub); safestrncpy(tmp_soutput, (data == 0) ? msg_txt(503) : msg_txt(59), sizeof(tmp_soutput)); // The night has fallen... - intif->broadcast(tmp_soutput, (int)strlen(tmp_soutput) + 1, BC_DEFAULT); + clif->broadcast(NULL, tmp_soutput, (int)strlen(tmp_soutput) + 1, BC_DEFAULT, ALL_CLIENT); return 0; } @@ -12311,6 +12311,54 @@ static void pc_check_supernovice_call(struct map_session_data *sd, const char *m } } +/** + * Sends a message t all online GMs having the specified permission. + * + * @param sender_name Sender character name. + * @param permission The required permission to receive this message. + * @param message The message body. + * + * @return The amount of characters the message was delivered to. + */ +// The transmission of GM only Wisp/Page from server to inter-server +static int pc_wis_message_to_gm(const char *sender_name, int permission, const char *message) +{ + nullpo_ret(sender_name); + nullpo_ret(message); + int mes_len = (int)strlen(message) + 1; // + null + int count = 0; + + // information is sent to all online GM + map->foreachpc(pc->wis_message_to_gm_sub, permission, sender_name, message, mes_len, &count); + + return count; +} + +/** + * Helper function for pc_wis_message_to_gm(). + */ +static int pc_wis_message_to_gm_sub(struct map_session_data *sd, va_list va) +{ + nullpo_ret(sd); + + int permission = va_arg(va, int); + if (!pc_has_permission(sd, permission)) + return 0; + + const char *sender_name = va_arg(va, const char *); + const char *message = va_arg(va, const char *); + int len = va_arg(va, int); + int *count = va_arg(va, int *); + + nullpo_ret(sender_name); + nullpo_ret(message); + nullpo_ret(count); + + clif->wis_message(sd->fd, sender_name, message, len); + ++*count; + return 1; +} + static void pc_update_job_and_level(struct map_session_data *sd) { nullpo_retv(sd); @@ -12758,6 +12806,8 @@ void pc_defaults(void) pc->check_supernovice_call = pc_check_supernovice_call; pc->process_chat_message = pc_process_chat_message; + pc->wis_message_to_gm = pc_wis_message_to_gm; + pc->wis_message_to_gm_sub = pc_wis_message_to_gm_sub; /** * Autotrade persistency [Ind/Hercules <3] |