summaryrefslogtreecommitdiff
path: root/src/map/pc.c
diff options
context:
space:
mode:
authorHaru <haru@dotalux.com>2016-04-21 23:03:43 +0200
committerHaru <haru@dotalux.com>2016-04-23 09:52:31 +0200
commit7aa70331b7dcfb21533c3806a694819e70f936c2 (patch)
treef92b7137a7f0cf65ffbe5553b0075181b5b5891c /src/map/pc.c
parentccfd0549ce64e84e41069ec8e040ce9806b963f2 (diff)
downloadhercules-7aa70331b7dcfb21533c3806a694819e70f936c2.tar.gz
hercules-7aa70331b7dcfb21533c3806a694819e70f936c2.tar.bz2
hercules-7aa70331b7dcfb21533c3806a694819e70f936c2.tar.xz
hercules-7aa70331b7dcfb21533c3806a694819e70f936c2.zip
Removed some code duplication in chat processing functions
Moved non-clif code that handles chat delay, atcommand detection, idle timers to pc.c Signed-off-by: Haru <haru@dotalux.com>
Diffstat (limited to 'src/map/pc.c')
-rw-r--r--src/map/pc.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/map/pc.c b/src/map/pc.c
index 2edb09d85..8fe9ddd6e 100644
--- a/src/map/pc.c
+++ b/src/map/pc.c
@@ -11517,6 +11517,36 @@ int pc_have_magnifier(struct map_session_data *sd)
}
/**
+ * Verifies a chat message, searching for atcommands, checking if the sender
+ * character can chat, and updating the idle timer.
+ *
+ * @param sd The sender character.
+ * @param message The message text.
+ * @return Whether the message is a valid chat message.
+ */
+bool pc_process_chat_message(struct map_session_data *sd, const char *message)
+{
+ if (atcommand->exec(sd->fd, sd, message, true)) {
+ return false;
+ }
+
+ if (!pc->can_talk(sd)) {
+ return false;
+ }
+
+ if (battle_config.min_chat_delay != 0) {
+ if (DIFF_TICK(sd->cantalk_tick, timer->gettick()) > 0) {
+ return false;
+ }
+ sd->cantalk_tick = timer->gettick() + battle_config.min_chat_delay;
+ }
+
+ pc->update_idle_time(sd, BCIDLE_CHAT);
+
+ return true;
+}
+
+/**
* Checks a chat message, scanning for the Super Novice prayer sequence.
*
* If a match is found, the angel is invoked or the counter is incremented as
@@ -11923,6 +11953,7 @@ void pc_defaults(void) {
pc->validate_levels = pc_validate_levels;
pc->check_supernovice_call = pc_check_supernovice_call;
+ pc->process_chat_message = pc_process_chat_message;
/**
* Autotrade persistency [Ind/Hercules <3]