mirror of
https://github.com/ParadiseSS13/Paradise.git
synced 2026-07-16 01:23:41 +01:00
Prevent language-switching in the middle of a word or number. (#29721)
This commit is contained in:
@@ -2,4 +2,5 @@ GLOBAL_DATUM_INIT(filename_forbidden_chars, /regex, regex(@{""|[\\\n\t/?%*:|<>]|
|
||||
GLOBAL_DATUM_INIT(is_color, /regex, regex("^#\[0-9a-fA-F]{6}$"))
|
||||
GLOBAL_DATUM_INIT(regex_rgb_text, /regex, regex(@"^#?(([0-9a-fA-F]{8})|([0-9a-fA-F]{6})|([0-9a-fA-F]{3}))$"))
|
||||
GLOBAL_DATUM_INIT(is_http_protocol, /regex, regex("^https?://"))
|
||||
GLOBAL_DATUM_INIT(is_alphanumeric, /regex, regex(@"[0-9a-zA-Z]"))
|
||||
GLOBAL_PROTECT(filename_forbidden_chars)
|
||||
|
||||
@@ -159,8 +159,17 @@
|
||||
|
||||
/mob/proc/find_valid_prefixes(message)
|
||||
var/list/prefixes = list() // [["Common", start, end], ["Gutter", start, end]]
|
||||
var/lower_message = lowertext(message)
|
||||
var/is_alphanumeric = FALSE
|
||||
var/was_alphanumeric = FALSE
|
||||
for(var/i in 1 to length(message))
|
||||
var/selection = trim_right(lowertext(copytext(message, i, i + 3)))
|
||||
was_alphanumeric = is_alphanumeric
|
||||
is_alphanumeric = GLOB.is_alphanumeric.Find(lower_message[i])
|
||||
if(was_alphanumeric)
|
||||
// Language prefixes should not activate in the middle of a word or number.
|
||||
continue
|
||||
|
||||
var/selection = trim_right(copytext(lower_message, i, i + 3))
|
||||
var/datum/language/L = GLOB.language_keys[selection]
|
||||
if(L != null && can_speak_language(L)) // What the fuck... remove the L != null check if you ever find out what the fuck is adding `null` to the languages list on absolutely random mobs... seriously what the hell...
|
||||
prefixes[++prefixes.len] = list(L, i, i + length(selection))
|
||||
|
||||
Reference in New Issue
Block a user