Skip to content

Commit

Permalink
[PORT] Unterminated speech now ends in a period, automatically! from …
Browse files Browse the repository at this point in the history
…Bubber (PRs #628 & #852) (#587)
  • Loading branch information
TyrantCerberus authored May 30, 2024
1 parent ddfd944 commit ecf9dcb
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
6 changes: 4 additions & 2 deletions code/__DEFINES/say.dm
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,9 @@
#define MSG_VISUAL (1<<0)
#define MSG_AUDIBLE (1<<1)



//Used in visible_message_flags, audible_message_flags and runechat_flags
#define EMOTE_MESSAGE (1<<0)

//Auto punctuation global datums
GLOBAL_DATUM_INIT(has_no_eol_punctuation, /regex, regex("\\w$"))
GLOBAL_DATUM_INIT(noncapital_i, /regex, regex("\\b\[i]\\b", "g"))
14 changes: 14 additions & 0 deletions code/modules/mob/living/living_say.dm
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,9 @@ GLOBAL_LIST_INIT(message_modes_stat_limits, list(
succumb()
return

//Handle auto-capitalization of isolated 'i's, adds a period to the end of unterminated inputs <-- like this one.
message = autopunct_bare(message)

//This is before anything that sends say a radio message, and after all important message type modifications, so you can scumb in alien chat or something
if(saymode && !saymode.handle_message(src, message, language))
return
Expand Down Expand Up @@ -485,3 +488,14 @@ GLOBAL_LIST_INIT(message_modes_stat_limits, list(
if(get_minds && mind)
return mind.get_language_holder()
. = ..()

/**
* Ensures sentences end in a period if no other terminal punctuation is present
* and that all whitespace-bounded 'i' characters are capitalized.
*/
/mob/living/proc/autopunct_bare(input_text)
if (findtext(input_text, GLOB.has_no_eol_punctuation))
input_text += "."

input_text = replacetext(input_text, GLOB.noncapital_i, "I")
return input_text

0 comments on commit ecf9dcb

Please sign in to comment.