From a7c6681a6f561bcc3a97ffe30799012f9d340ed2 Mon Sep 17 00:00:00 2001 From: X0-11 Date: Sun, 18 Jun 2023 18:33:34 +0100 Subject: [PATCH] vehicle compat pt 2 --- code/datums/chatmessage.dm | 18 +++++++++++++----- code/modules/mob/hear_say.dm | 7 +++---- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/code/datums/chatmessage.dm b/code/datums/chatmessage.dm index dd0a248faf447..67c3e295ec648 100644 --- a/code/datums/chatmessage.dm +++ b/code/datums/chatmessage.dm @@ -41,9 +41,10 @@ * * target - The target atom to display the overlay at * * owner - The mob that owns this overlay, only this mob will be able to view it * * extra_classes - Extra classes to apply to the span that holds the text + * * messageloc_override - Put the message above this item, instead. * * lifespan - The lifespan of the message in deciseconds */ -/datum/chatmessage/New(text, atom/target, mob/owner, list/extra_classes = null, lifespan = CHAT_MESSAGE_LIFESPAN) +/datum/chatmessage/New(text, atom/target, mob/owner, list/extra_classes = null, messageloc_override = null, lifespan = CHAT_MESSAGE_LIFESPAN) . = ..() if (!istype(target)) CRASH("Invalid target given for chatmessage") @@ -51,6 +52,8 @@ stack_trace("/datum/chatmessage created with [isnull(owner) ? "null" : "invalid"] mob owner") qdel(src) return + if(messageloc_override) + message_loc = messageloc_override INVOKE_ASYNC(src, .proc/generate_image, text, target, owner, extra_classes, lifespan) /datum/chatmessage/Destroy() @@ -125,7 +128,8 @@ approx_lines = max(1, mheight / CHAT_MESSAGE_APPROX_LHEIGHT) // Translate any existing messages upwards, apply exponential decay factors to timers - message_loc = target + if(!message_loc) //For overriding line in-vehicles and whatnot. + message_loc = target if (owned_by.seen_messages) var/idx = 1 var/combined_height = approx_lines @@ -190,15 +194,19 @@ spans = spans?.Copy() var/atom/movable/originalSpeaker = speaker + var/messageloc_override = null // Ignore virtual speaker (most often radio messages) from ourself if (originalSpeaker != src && speaker == src) return - if(istype(speaker.loc,/obj/vehicles) || istype(speaker.loc,/obj/structure/closet)) - speaker = originalSpeaker.loc + if(speaker.z != src.z) //We'll assume that speech from people we can't see is radio-speech. + return //They don't want to see non-z (radio) messages. + + if(istype(originalSpeaker.loc,/obj/vehicles) || istype(originalSpeaker.loc,/obj/structure/closet)) + messageloc_override = originalSpeaker.loc // Display visual above source - new /datum/chatmessage(capitalize(raw_message), speaker, src, spans) + new /datum/chatmessage(capitalize(raw_message), speaker, src, spans, messageloc_override) // Tweak these defines to change the available color ranges diff --git a/code/modules/mob/hear_say.dm b/code/modules/mob/hear_say.dm index a70ade1a9be9c..598fc33412e31 100644 --- a/code/modules/mob/hear_say.dm +++ b/code/modules/mob/hear_say.dm @@ -74,10 +74,9 @@ else if(language) on_hear_say("[speaker_name][alt_name] [track][language.format_message(message, verb)]") - if(speaker && speaker.z == src.z) //I don't think we should go through the whole rigamarole for people we can't even see or won't see any time soon. - if(speaker.client && speaker.client.prefs && !(speaker.client.prefs.chat_on_map)) - return - create_chat_message(speaker, language, message, list(), null) + if(client && client.prefs && !(client.prefs.chat_on_map)) + return + create_chat_message(speaker, language, message, list(), null) else on_hear_say("[speaker_name][alt_name] [track][verb], \"[message]\"") if (speech_sound && (get_dist(speaker, src) <= world.view && src.z == speaker.z))