Skip to content

Commit

Permalink
Make autopunctuation handle HTML and trailing spaces
Browse files Browse the repository at this point in the history
  • Loading branch information
out-of-phaze committed Jun 3, 2024
1 parent 844329c commit 343e4ee
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 30 deletions.
22 changes: 7 additions & 15 deletions code/modules/emotes/emote_mob.dm
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,6 @@
if(!message || !emoter)
return

message = html_decode(message)

name_anchor = findtext(message, anchor_char)
if(name_anchor > 0) // User supplied emote with visible_emote token (default ^)
pretext = copytext(message, 1, name_anchor)
Expand All @@ -139,11 +137,7 @@
if(end_char != " ")
pretext += " "

// Grab the last character of the emote message.
end_char = copytext(subtext, length(subtext), length(subtext) + 1)
if(!(end_char in list(".", "?", "!", "\"", "-", "~"))) // gotta include ~ for all you fucking weebs
// No punctuation supplied. Tack a period on the end.
subtext += "."
handle_autopunctuation(subtext)

// Add a space to the subtext, unless it begins with an apostrophe or comma.
if(subtext != ".")
Expand All @@ -153,12 +147,9 @@
if(start_char != "," && start_char != "'")
subtext = " " + subtext

pretext = capitalize(html_encode(pretext))
nametext = html_encode(nametext)
subtext = html_encode(subtext)
// Store the player's name in a nice bold, naturalement
nametext = "<B>[emoter]</B>"
return pretext + nametext + subtext
return capitalize(pretext) + nametext + subtext

/mob/proc/custom_emote(var/m_type = VISIBLE_MESSAGE, var/message = null)

Expand All @@ -171,15 +162,16 @@
else
input = message

if(input)
message = format_emote(src, message)
else
if(!input)
return

message = trim(html_encode(message))
message = filter_modify_message(message)
message = format_emote(src, message)

if (message)
log_emote("[name]/[key] : [message]")
//do not show NPC animal emotes to ghosts, it turns into hellscape
message = filter_modify_message(message)
var/check_ghosts = client ? /datum/client_preference/ghost_sight : null
if(m_type == VISIBLE_MESSAGE)
visible_message(message, checkghosts = check_ghosts)
Expand Down
19 changes: 4 additions & 15 deletions code/modules/mob/living/say.dm
Original file line number Diff line number Diff line change
Expand Up @@ -100,18 +100,6 @@
returns[2] = null
return returns

/mob/living/proc/format_say_message(var/message = null)
if(!message)
return

message = html_decode(message)

var/end_char = copytext_char(message, -1)
if(!(end_char in list(".", "?", "!", "-", "~")))
message += "."

return html_encode(message)

/mob/living/proc/handle_mob_specific_speech(message, message_mode, verb = "says", decl/language/speaking)
SHOULD_CALL_PARENT(TRUE)
return FALSE
Expand Down Expand Up @@ -142,7 +130,8 @@
else
message = copytext_char(message, 3)

message = trim_left(message)
// trim pre-language-parsing so we can get language and radio keys
message = trim(message)

//parse the language code and consume it
if(!speaking)
Expand Down Expand Up @@ -177,10 +166,10 @@
else
verb = say_quote(message, speaking)

message = trim_left(message)
message = trim(html_encode(message)) // trim again post-language-parsing
message = handle_autohiss(message, speaking)
message = format_say_message(message)
message = filter_modify_message(message)
message = handle_autopunctuation(message)

if(speaking && !speaking.can_be_spoken_properly_by(src))
message = speaking.muddle(message)
Expand Down
9 changes: 9 additions & 0 deletions code/modules/mob/say.dm
Original file line number Diff line number Diff line change
Expand Up @@ -111,3 +111,12 @@ var/global/list/special_channel_keys = list(
var/obj/item/mask = get_equipped_item(slot_wear_mask_str)
if(istype(mask, /obj/item/clothing/mask/muzzle) || istype(mask, /obj/item/sealant))
. = mask

/// Adds punctuation to an emote or speech message automatically.
/mob/proc/handle_autopunctuation(message)
if(!message)
return
var/end_char = copytext_char(trim_right(strip_html_properly(message)), -1)
if(!(end_char in list(".", "?", "!", "-", "~")))
message += "."
return message

0 comments on commit 343e4ee

Please sign in to comment.