mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-10 10:12:45 +00:00
Merge pull request #6300 from Novacat/nova-basicfixes
Chat fix by Aronai
This commit is contained in:
1
code/_global_vars/lists/misc.dm
Normal file
1
code/_global_vars/lists/misc.dm
Normal file
@@ -0,0 +1 @@
|
||||
GLOBAL_LIST_INIT(speech_toppings, list("|" = "i", "+" = "b", "_" = "u"))
|
||||
@@ -22,7 +22,7 @@
|
||||
|
||||
|
||||
if (message)
|
||||
message = say_emphasis(message)
|
||||
message = encode_html_emphasis(message)
|
||||
|
||||
// Hearing gasp and such every five seconds is not good emotes were not global for a reason.
|
||||
// Maybe some people are okay with that.
|
||||
@@ -81,7 +81,7 @@
|
||||
else
|
||||
input = message
|
||||
|
||||
input = say_emphasis(input)
|
||||
input = encode_html_emphasis(input)
|
||||
|
||||
if(input)
|
||||
log_ghostemote(input, src)
|
||||
|
||||
@@ -45,7 +45,7 @@
|
||||
if(italics)
|
||||
message = "<i>[message]</i>"
|
||||
|
||||
message = say_emphasis(message)
|
||||
message = encode_html_emphasis(message)
|
||||
|
||||
var/track = null
|
||||
if(istype(src, /mob/observer/dead))
|
||||
@@ -115,36 +115,14 @@
|
||||
/mob/living/silicon/ai/special_mentions()
|
||||
return list("AI") // AI door!
|
||||
|
||||
// Converts specific characters, like +, |, and _ to formatted output.
|
||||
/mob/proc/say_emphasis(var/message)
|
||||
message = encode_html_emphasis(message, "|", "i")
|
||||
message = encode_html_emphasis(message, "+", "b")
|
||||
message = encode_html_emphasis(message, "_", "u")
|
||||
return message
|
||||
|
||||
// Replaces a character inside message with html tags. Note that html var must not include brackets.
|
||||
// Will not create an open html tag if it would not have a closing one.
|
||||
/proc/encode_html_emphasis(var/message, var/char, var/html)
|
||||
var/i = 20 // Infinite loop safety.
|
||||
var/pattern = "(?<!<)\\" + char
|
||||
var/regex/re = regex(pattern,"i") // This matches results which do not have a < next to them, to avoid stripping slashes from closing html tags.
|
||||
var/first = re.Find(message) // Find first occurance.
|
||||
var/second = re.Find(message, first + 1) // Then the second.
|
||||
while(first && second && i)
|
||||
// Calculate how far foward the second char is, as the first replacetext() will displace it.
|
||||
var/length_increase = length("<[html]>") - 1
|
||||
|
||||
// Now replace both.
|
||||
message = replacetext(message, char, "<[html]>", first, first + 1)
|
||||
message = replacetext(message, char, "</[html]>", second + length_increase, second + length_increase + 1)
|
||||
|
||||
// Check again to see if we need to keep going.
|
||||
first = re.Find(message)
|
||||
second = re.Find(message, first + 1)
|
||||
i--
|
||||
if(!i)
|
||||
CRASH("Possible infinite loop occured in encode_html_emphasis().")
|
||||
return message
|
||||
/proc/encode_html_emphasis(message)
|
||||
var/tagged_message = message
|
||||
for(var/delimiter in GLOB.speech_toppings)
|
||||
var/regex/R = new("\\[delimiter](.+?)\\[delimiter]","g")
|
||||
var/tag = GLOB.speech_toppings[delimiter]
|
||||
tagged_message = R.Replace(tagged_message,"<[tag]>$1</[tag]>")
|
||||
|
||||
return tagged_message
|
||||
|
||||
/mob/proc/hear_radio(var/message, var/verb="says", var/datum/language/language=null, var/part_a, var/part_b, var/part_c, var/mob/speaker = null, var/hard_to_hear = 0, var/vname ="")
|
||||
|
||||
@@ -240,7 +218,7 @@
|
||||
speaker_name = "[speaker.real_name] ([speaker_name])"
|
||||
track = "[speaker_name] ([ghost_follow_link(speaker, src)])"
|
||||
|
||||
message = say_emphasis(message)
|
||||
message = encode_html_emphasis(message)
|
||||
|
||||
var/formatted
|
||||
if(language)
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
if (!message)
|
||||
return
|
||||
|
||||
message = speaker.say_emphasis(message)
|
||||
message = encode_html_emphasis(message)
|
||||
|
||||
var/message_start = "<i><span class='game say'>[name], <span class='name'>[speaker.name]</span>"
|
||||
var/message_body = "<span class='message'>[speaker.say_quote(message)], \"[message]\"</span></span></i>"
|
||||
|
||||
@@ -51,7 +51,7 @@
|
||||
usr << "<span class='danger'>You have deadchat muted.</span>"
|
||||
return
|
||||
|
||||
message = say_emphasis(message)
|
||||
message = encode_html_emphasis(message)
|
||||
|
||||
say_dead_direct("[pick("complains","moans","whines","laments","blubbers")], <span class='message'>\"[message]\"</span>", src)
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
return
|
||||
|
||||
if (message)
|
||||
message = say_emphasis(message)
|
||||
message = encode_html_emphasis(message)
|
||||
|
||||
var/list/vis = get_mobs_and_objs_in_view_fast(get_turf(src),1,2) //Turf, Range, and type 2 is emote
|
||||
var/list/vis_mobs = vis["mobs"]
|
||||
|
||||
@@ -91,6 +91,7 @@
|
||||
#include "code\_global_vars\mobs.dm"
|
||||
#include "code\_global_vars\sensitive.dm"
|
||||
#include "code\_global_vars\lists\mapping.dm"
|
||||
#include "code\_global_vars\lists\misc.dm"
|
||||
#include "code\_helpers\_global_objects.dm"
|
||||
#include "code\_helpers\_global_objects_vr.dm"
|
||||
#include "code\_helpers\_lists.dm"
|
||||
|
||||
Reference in New Issue
Block a user