From 92ab2b41e81a5896986ffdc0c298a816ace9883c Mon Sep 17 00:00:00 2001
From: Kapu1178 <75460809+Kapu1178@users.noreply.github.com>
Date: Thu, 8 Jul 2021 21:18:37 -0400
Subject: [PATCH] Ports #44391 and #48637 from TGStation
---
code/__DEFINES/dcs/signals.dm | 2 +-
code/datums/brain_damage/brain_trauma.dm | 8 +++++---
code/datums/brain_damage/hypnosis.dm | 5 ++---
code/datums/brain_damage/phobia.dm | 11 +++++------
code/datums/brain_damage/split_personality.dm | 10 +++++-----
code/datums/status_effects/debuffs.dm | 10 ++++++++--
code/datums/status_effects/neutral.dm | 14 ++++++++++++++
code/game/say.dm | 2 +-
code/modules/antagonists/traitor/datum_traitor.dm | 14 ++++++++++++--
code/modules/mob/living/carbon/say.dm | 13 -------------
code/modules/mob/living/say.dm | 7 ++-----
11 files changed, 55 insertions(+), 41 deletions(-)
diff --git a/code/__DEFINES/dcs/signals.dm b/code/__DEFINES/dcs/signals.dm
index cbdf074ccb3..cb36b005421 100644
--- a/code/__DEFINES/dcs/signals.dm
+++ b/code/__DEFINES/dcs/signals.dm
@@ -181,7 +181,7 @@
#define COMSIG_MOB_THROW "mob_throw" //! from base of /mob/throw_item(): (atom/target)
#define COMSIG_MOB_UPDATE_SIGHT "mob_update_sight" //! from base of /mob/update_sight(): ()
#define COMSIG_MOB_EXAMINATE "mob_examinate" //from base of /mob/verb/examinate(): (atom/target)
-#define COMSIG_MOB_SAY "mob_say" // from /mob/living/say(): (proc args list)
+#define COMSIG_MOB_SAY "mob_say" // from /mob/living/say(): ()
#define COMPONENT_UPPERCASE_SPEECH 1
// used to access COMSIG_MOB_SAY argslist
#define SPEECH_MESSAGE 1
diff --git a/code/datums/brain_damage/brain_trauma.dm b/code/datums/brain_damage/brain_trauma.dm
index df353a563d4..ea42d62f88a 100644
--- a/code/datums/brain_damage/brain_trauma.dm
+++ b/code/datums/brain_damage/brain_trauma.dm
@@ -41,21 +41,23 @@
/datum/brain_trauma/proc/on_gain()
to_chat(owner, gain_text)
RegisterSignal(owner, COMSIG_MOB_SAY, .proc/handle_speech)
+ RegisterSignal(owner, COMSIG_MOVABLE_HEAR, .proc/handle_hearing)
//Called when removed from a mob
/datum/brain_trauma/proc/on_lose(silent)
if(!silent)
to_chat(owner, lose_text)
UnregisterSignal(owner, COMSIG_MOB_SAY)
+ UnregisterSignal(owner, COMSIG_MOVABLE_HEAR)
//Called when hearing a spoken message
-/datum/brain_trauma/proc/on_hear(message, speaker, message_language, raw_message, radio_freq)
- return message
+/datum/brain_trauma/proc/handle_hearing(datum/source, list/hearing_args)
+ SIGNAL_HANDLER
+ UnregisterSignal(owner, COMSIG_MOVABLE_HEAR)
//Called when speaking
/datum/brain_trauma/proc/handle_speech(datum/source, list/speech_args)
UnregisterSignal(owner, COMSIG_MOB_SAY)
-
//Called when hugging. expand into generally interacting, where future coders could switch the intent?
/datum/brain_trauma/proc/on_hug(mob/living/hugger, mob/living/hugged)
return
diff --git a/code/datums/brain_damage/hypnosis.dm b/code/datums/brain_damage/hypnosis.dm
index 8d997ba4a31..2bd9d5f1a33 100644
--- a/code/datums/brain_damage/hypnosis.dm
+++ b/code/datums/brain_damage/hypnosis.dm
@@ -51,6 +51,5 @@
if(2)
new /datum/hallucination/chat(owner, TRUE, FALSE, "[hypnotic_phrase]")
-/datum/brain_trauma/hypnosis/on_hear(message, speaker, message_language, raw_message, radio_freq)
- message = target_phrase.Replace(message, "$1")
- return message
+/datum/brain_trauma/hypnosis/handle_hearing(datum/source, list/hearing_args)
+ hearing_args[HEARING_RAW_MESSAGE] = target_phrase.Replace(hearing_args[HEARING_RAW_MESSAGE], "$1")
diff --git a/code/datums/brain_damage/phobia.dm b/code/datums/brain_damage/phobia.dm
index df1cdcfff7f..f0d8bc15830 100644
--- a/code/datums/brain_damage/phobia.dm
+++ b/code/datums/brain_damage/phobia.dm
@@ -172,21 +172,20 @@
-/datum/brain_trauma/mild/phobia/on_hear(message, speaker, message_language, raw_message, radio_freq)
+/datum/brain_trauma/mild/phobia/handle_hearing(datum/source, list/hearing_args)
if(!owner.can_hear()) //words can't trigger you if you can't hear them *taps head*
- return message
+ return
if(HAS_TRAIT(owner, TRAIT_FEARLESS))
- return message
+ return
for(var/word in trigger_words)
var/regex/reg = regex("(\\b|\\A)[REGEX_QUOTE(word)]'?s*(\\b|\\Z)", "i")
- if(findtext(raw_message, reg))
+ if(findtext(hearing_args[HEARING_RAW_MESSAGE], reg))
if(fear_state <= (PHOBIA_STATE_CALM)) //words can put you on edge, but won't take you over it, unless you have gotten stressed already. don't call freak_out to avoid gaming the adrenaline rush
fearscore ++
- message = reg.Replace(message, "$1")
+ hearing_args[HEARING_RAW_MESSAGE] = reg.Replace(hearing_args[HEARING_RAW_MESSAGE], "$1")
break
- return message
/datum/brain_trauma/mild/phobia/handle_speech(datum/source, list/speech_args)
if(HAS_TRAIT(owner, TRAIT_FEARLESS))
diff --git a/code/datums/brain_damage/split_personality.dm b/code/datums/brain_damage/split_personality.dm
index d15d0da3f40..653caf358a4 100644
--- a/code/datums/brain_damage/split_personality.dm
+++ b/code/datums/brain_damage/split_personality.dm
@@ -194,13 +194,13 @@
/datum/brain_trauma/severe/split_personality/brainwashing/on_life()
return //no random switching
-/datum/brain_trauma/severe/split_personality/brainwashing/on_hear(message, speaker, message_language, raw_message, radio_freq)
- if(HAS_TRAIT(owner, TRAIT_DEAF) || owner == speaker)
- return message
+/datum/brain_trauma/severe/split_personality/brainwashing/handle_hearing(datum/source, list/hearing_args)
+ if(HAS_TRAIT(owner, TRAIT_DEAF) || owner == hearing_args[HEARING_SPEAKER])
+ return
+ var/message = hearing_args[HEARING_RAW_MESSAGE]
if(findtext(message, codeword))
- message = replacetext(message, codeword, "[codeword]")
+ hearing_args[HEARING_RAW_MESSAGE] = replacetext(message, codeword, "[codeword]")
addtimer(CALLBACK(src, /datum/brain_trauma/severe/split_personality.proc/switch_personalities), 10)
- return message
/datum/brain_trauma/severe/split_personality/brainwashing/handle_speech(datum/source, list/speech_args)
if(findtext(speech_args[SPEECH_MESSAGE], codeword))
diff --git a/code/datums/status_effects/debuffs.dm b/code/datums/status_effects/debuffs.dm
index a4fdf25ea9d..f7259228e99 100644
--- a/code/datums/status_effects/debuffs.dm
+++ b/code/datums/status_effects/debuffs.dm
@@ -567,14 +567,20 @@
owner.remove_client_colour(/datum/client_colour/monochrome)
to_chat(owner, "You snap out of your trance!")
+<<<<<<< HEAD
/datum/status_effect/trance/proc/hypnotize(datum/source, message, atom/movable/speaker, message_language, raw_message, radio_freq, list/spans, list/message_mods = list())
+=======
+/datum/status_effect/trance/proc/hypnotize(datum/source, list/hearing_args, list/spans, list/message_mods = list())
+ SIGNAL_HANDLER
+
+>>>>>>> 3e6cc68be9 (Ports #44391 and #48637 from TGStation (#4755))
if(!owner.can_hear())
return
- if(speaker == owner)
+ if(hearing_args[HEARING_SPEAKER] == owner)
return
var/mob/living/carbon/C = owner
C.cure_trauma_type(/datum/brain_trauma/hypnosis, TRAUMA_RESILIENCE_SURGERY) //clear previous hypnosis
- addtimer(CALLBACK(C, /mob/living/carbon.proc/gain_trauma, /datum/brain_trauma/hypnosis, TRAUMA_RESILIENCE_SURGERY, raw_message), 10)
+ addtimer(CALLBACK(C, /mob/living/carbon.proc/gain_trauma, /datum/brain_trauma/hypnosis, TRAUMA_RESILIENCE_SURGERY, hearing_args[HEARING_RAW_MESSAGE]), 10)
addtimer(CALLBACK(C, /mob/living.proc/Stun, 60, TRUE, TRUE), 15) //Take some time to think about it
qdel(src)
diff --git a/code/datums/status_effects/neutral.dm b/code/datums/status_effects/neutral.dm
index fc86f3c2cc6..ff1f54aceed 100644
--- a/code/datums/status_effects/neutral.dm
+++ b/code/datums/status_effects/neutral.dm
@@ -130,6 +130,20 @@
alert_type = null
var/mob/living/listening_in
+/datum/status_effect/bugged/on_apply(mob/living/new_owner, mob/living/tracker)
+ . = ..()
+ if (.)
+ RegisterSignal(new_owner, COMSIG_MOVABLE_HEAR, .proc/handle_hearing)
+
+/datum/status_effect/bugged/on_remove()
+ . = ..()
+ UnregisterSignal(owner, COMSIG_MOVABLE_HEAR)
+
+/datum/status_effect/bugged/proc/handle_hearing(datum/source, list/hearing_args)
+ SIGNAL_HANDLER
+ listening_in.show_message(hearing_args[HEARING_MESSAGE])
+
+
/datum/status_effect/bugged/on_creation(mob/living/new_owner, mob/living/tracker)
. = ..()
if(.)
diff --git a/code/game/say.dm b/code/game/say.dm
index de162247598..373a414d7c6 100644
--- a/code/game/say.dm
+++ b/code/game/say.dm
@@ -29,7 +29,7 @@ GLOBAL_LIST_INIT(freqtospan, list(
send_speech(message, 7, src, , spans, message_language=language)
/atom/movable/proc/Hear(message, atom/movable/speaker, message_language, raw_message, radio_freq, list/spans, list/message_mods = list())
- SEND_SIGNAL(src, COMSIG_MOVABLE_HEAR, message, speaker, message_language, raw_message, radio_freq, spans, message_mods)
+ SEND_SIGNAL(src, COMSIG_MOVABLE_HEAR, args)
/atom/movable/proc/can_speak()
return 1
diff --git a/code/modules/antagonists/traitor/datum_traitor.dm b/code/modules/antagonists/traitor/datum_traitor.dm
index 0497cabaeab..00733ca687f 100644
--- a/code/modules/antagonists/traitor/datum_traitor.dm
+++ b/code/modules/antagonists/traitor/datum_traitor.dm
@@ -55,6 +55,13 @@
owner.special_role = null
..()
+/datum/antagonist/traitor/proc/handle_hearing(datum/source, list/hearing_args)
+ SIGNAL_HANDLER
+ var/message = hearing_args[HEARING_RAW_MESSAGE]
+ message = GLOB.syndicate_code_phrase_regex.Replace(message, "$1")
+ message = GLOB.syndicate_code_response_regex.Replace(message, "$1")
+ hearing_args[HEARING_RAW_MESSAGE] = message
+
/datum/antagonist/traitor/proc/add_objective(datum/objective/O)
objectives += O
log_objective(owner, O.explanation_text)
@@ -230,9 +237,11 @@
/datum/antagonist/traitor/apply_innate_effects(mob/living/mob_override)
. = ..()
update_traitor_icons_added()
- var/mob/living/silicon/ai/A = mob_override || owner.current
- if(istype(A) && traitor_kind == TRAITOR_AI)
+ var/mob/living/M = mob_override || owner.current
+ if(isAI(M) && traitor_kind == TRAITOR_AI)
+ var/mob/living/silicon/ai/A = M
A.hack_software = TRUE
+ RegisterSignal(M, COMSIG_MOVABLE_HEAR, .proc/handle_hearing)
/datum/antagonist/traitor/remove_innate_effects(mob/living/mob_override)
. = ..()
@@ -240,6 +249,7 @@
var/mob/living/silicon/ai/A = mob_override || owner.current
if(istype(A) && traitor_kind == TRAITOR_AI)
A.hack_software = FALSE
+ UnregisterSignal(owner.current, COMSIG_MOVABLE_HEAR, .proc/handle_hearing)
/datum/antagonist/traitor/proc/give_codewords()
if(!owner.current)
diff --git a/code/modules/mob/living/carbon/say.dm b/code/modules/mob/living/carbon/say.dm
index bded25089a7..e1b03583f74 100644
--- a/code/modules/mob/living/carbon/say.dm
+++ b/code/modules/mob/living/carbon/say.dm
@@ -19,16 +19,3 @@
else
. = initial(dt.flags) & TONGUELESS_SPEECH
-/mob/living/carbon/hear_intercept(message, atom/movable/speaker, datum/language/message_language, raw_message, radio_freq, list/spans, list/message_mods = list())
- var/datum/status_effect/bugged/B = has_status_effect(STATUS_EFFECT_BUGGED)
- if(B)
- B.listening_in.show_message(message)
- for(var/T in get_traumas())
- var/datum/brain_trauma/trauma = T
- message = trauma.on_hear(message, speaker, message_language, raw_message, radio_freq)
-
- if (src.mind.has_antag_datum(/datum/antagonist/traitor))
- message = GLOB.syndicate_code_phrase_regex.Replace(message, "$1")
- message = GLOB.syndicate_code_response_regex.Replace(message, "$1")
-
- return message
diff --git a/code/modules/mob/living/say.dm b/code/modules/mob/living/say.dm
index a87b452298b..8ea4baae2a4 100644
--- a/code/modules/mob/living/say.dm
+++ b/code/modules/mob/living/say.dm
@@ -73,7 +73,7 @@ GLOBAL_LIST_INIT(department_radio_keys, list(
return new_msg
-/mob/living/say(message, bubble_type,var/list/spans = list(), sanitize = TRUE, datum/language/language = null, ignore_spam = FALSE, forced = null)
+/mob/living/say(message, bubble_type, var/list/spans = list(), sanitize = TRUE, datum/language/language = null, ignore_spam = FALSE, forced = null)
var/static/list/crit_allowed_modes = list(WHISPER_MODE = TRUE, MODE_CHANGELING = TRUE, MODE_ALIEN = TRUE)
var/static/list/unconscious_allowed_modes = list(MODE_CHANGELING = TRUE, MODE_ALIEN = TRUE)
@@ -210,7 +210,7 @@ GLOBAL_LIST_INIT(department_radio_keys, list(
return 1
/mob/living/Hear(message, atom/movable/speaker, datum/language/message_language, raw_message, radio_freq, list/spans, list/message_mods = list())
- . = ..()
+ SEND_SIGNAL(src, COMSIG_MOVABLE_HEAR, args)
if(!client)
return
var/deaf_message
@@ -235,9 +235,6 @@ GLOBAL_LIST_INIT(department_radio_keys, list(
show_message(message, MSG_AUDIBLE, deaf_message, deaf_type)
return message
-/mob/living/proc/hear_intercept(message, atom/movable/speaker, datum/language/message_language, raw_message, radio_freq, list/spans, list/message_mods = list())
- return message
-
/mob/living/send_speech(message, message_range = 6, obj/source = src, bubble_type = bubble_icon, list/spans, datum/language/message_language=null, list/message_mods = list())
var/static/list/eavesdropping_modes = list(MODE_WHISPER = TRUE, MODE_WHISPER_CRIT = TRUE)
var/eavesdrop_range = 0