summaryrefslogtreecommitdiff
path: root/src/map/pc.c
diff options
context:
space:
mode:
authorHaru <haru@dotalux.com>2019-08-25 17:44:10 +0200
committerHaru <haru@dotalux.com>2019-08-26 00:28:35 +0200
commit0ca24c219b8a5a7cd4beb15d8384380f7e6fa9b5 (patch)
treee783569a6e8c96827798d552181775ded9850171 /src/map/pc.c
parent247ec940d2efdcddbb3cf5d014ccdca42e1d2f0c (diff)
downloadhercules-0ca24c219b8a5a7cd4beb15d8384380f7e6fa9b5.tar.gz
hercules-0ca24c219b8a5a7cd4beb15d8384380f7e6fa9b5.tar.bz2
hercules-0ca24c219b8a5a7cd4beb15d8384380f7e6fa9b5.tar.xz
hercules-0ca24c219b8a5a7cd4beb15d8384380f7e6fa9b5.zip
Remove round-trip to the inter-server for the whisper-to-gm messages
Signed-off-by: Haru <haru@dotalux.com>
Diffstat (limited to 'src/map/pc.c')
-rw-r--r--src/map/pc.c50
1 files changed, 50 insertions, 0 deletions
diff --git a/src/map/pc.c b/src/map/pc.c
index 84d49e1db..827619be8 100644
--- a/src/map/pc.c
+++ b/src/map/pc.c
@@ -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]