From ef19e7904f3d9f0c51bcb8b5caab9a4e3f4fb380 Mon Sep 17 00:00:00 2001 From: Bjorn Neergaard Date: Mon, 1 Feb 2016 10:20:42 -0600 Subject: [PATCH] Support Regex in replaceall, re-implement lizard hiss limits --- code/__HELPERS/510.dm | 10 +++++----- code/modules/mob/living/carbon/human/species_types.dm | 6 ++++-- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/code/__HELPERS/510.dm b/code/__HELPERS/510.dm index 8c3a26053e7..f448ae3df54 100644 --- a/code/__HELPERS/510.dm +++ b/code/__HELPERS/510.dm @@ -2,7 +2,11 @@ #if DM_VERSION < 510 #define BYGEX "code/__HELPERS/bygex.dll" /proc/replacetext(text, replace, replacement) - return call(BYGEX, "regex_replaceallliteral")(text, replace, replacement) + if(istype(replace, /regex)) + var/regex/R = replace + return R.Replace(text, replacement) + else + return call(BYGEX, "regex_replaceallliteral")(text, replace, replacement) /proc/replacetextEx(text, replace, replacement) return call(BYGEX, "regEx_replaceallliteral")(text, replace, replacement) @@ -246,8 +250,4 @@ #undef CannotBeFlat #undef CannotBeAssoc #undef BadList -#else -/regex/Replace() - ..() - return text #endif \ No newline at end of file diff --git a/code/modules/mob/living/carbon/human/species_types.dm b/code/modules/mob/living/carbon/human/species_types.dm index 0c3c10150f4..74ba5292a99 100644 --- a/code/modules/mob/living/carbon/human/species_types.dm +++ b/code/modules/mob/living/carbon/human/species_types.dm @@ -74,10 +74,12 @@ datum/species/human/spec_death(gibbed, mob/living/carbon/human/H) return randname +var/regex/lizard_hiss = new("s{1,2}(?!s)", "g") +var/regex/lizard_hiSS = new("S{1,2}(?!S)", "g") /datum/species/lizard/handle_speech(message) if(copytext(message, 1, 2) != "*") - message = replacetextEx(message, "s", "sss") - message = replacetextEx(message, "S", "SSS") + message = lizard_hiss.Replace(message, "sss") + message = lizard_hiSS.Replace(message, "SSS") return message //I wag in death