Skip to content

Commit

Permalink
[MIRROR] Wraps lowertext() to ensure proper stringification. (#2824)
Browse files Browse the repository at this point in the history
* [MIRROR] Wraps `lowertext()` to ensure proper stringification. (#1908)

* Wraps `lowertext()` to ensure proper stringification.

* Modular

---------

Co-authored-by: san7890 <[email protected]>
Co-authored-by: Mal <[email protected]>

* replaced lower_text with macros.

---------

Co-authored-by: NovaBot <[email protected]>
Co-authored-by: san7890 <[email protected]>
Co-authored-by: Mal <[email protected]>
Co-authored-by: ReezeBL <[email protected]>
  • Loading branch information
5 people authored Apr 11, 2024
1 parent f2e4d95 commit 86aa41d
Show file tree
Hide file tree
Showing 122 changed files with 218 additions and 204 deletions.
4 changes: 4 additions & 0 deletions code/__DEFINES/text.dm
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@
*/
#define PREVENT_CHARACTER_TRIM_LOSS(integer) (integer + 1)

/// BYOND's string procs don't support being used on datum references (as in it doesn't look for a name for stringification)
/// We just use this macro to ensure that we will only pass strings to this BYOND-level function without developers needing to really worry about it.
#define LOWER_TEXT(thing) lowertext(UNLINT("[thing]"))

/// Folder directory for strings
#define STRING_DIRECTORY "strings"

Expand Down
14 changes: 7 additions & 7 deletions code/__DEFINES/~ff_defines/__HELPERS/names.dm
Original file line number Diff line number Diff line change
Expand Up @@ -59,22 +59,22 @@
if(2)
switch(rand(1,3))//Food, drinks, or places. Only selectable once.
if(1)
. += lowertext(pick(drinks))
. += LOWER_TEXT(pick(drinks))
if(2)
. += lowertext(pick(foods))
. += LOWER_TEXT(pick(foods))
if(3)
. += lowertext(pick(locations))
. += LOWER_TEXT(pick(locations))
safety -= 2
if(3)
switch(rand(1,4))//Abstract nouns, objects, adjectives, threats. Can be selected more than once.
if(1)
. += lowertext(pick(nouns))
. += LOWER_TEXT(pick(nouns))
if(2)
. += lowertext(pick(objects))
. += LOWER_TEXT(pick(objects))
if(3)
. += lowertext(pick(adjectives))
. += LOWER_TEXT(pick(adjectives))
if(4)
. += lowertext(pick(threats))
. += LOWER_TEXT(pick(threats))
if(!return_list)
if(words == 1)
. += "."
Expand Down
4 changes: 2 additions & 2 deletions code/__HELPERS/atmospherics.dm
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ GLOBAL_LIST_EMPTY(gas_handbook)
factor_info["factor_name"] = factor
factor_info["factor_type"] = "misc"
if(factor == "Temperature" || factor == "Pressure")
factor_info["tooltip"] = "Reaction is influenced by the [lowertext(factor)] of the place where the reaction is occuring."
factor_info["tooltip"] = "Reaction is influenced by the [LOWER_TEXT(factor)] of the place where the reaction is occuring."
else if(factor == "Energy")
factor_info["tooltip"] = "Energy released by the reaction, may or may not result in linear temperature change depending on a slew of other factors."
else if(factor == "Radiation")
Expand Down Expand Up @@ -138,7 +138,7 @@ GLOBAL_LIST_EMPTY(gas_handbook)
factor_info["factor_name"] = factor
factor_info["factor_type"] = "misc"
if(factor == "Temperature" || factor == "Pressure")
factor_info["tooltip"] = "Reaction is influenced by the [lowertext(factor)] of the place where the reaction is occuring."
factor_info["tooltip"] = "Reaction is influenced by the [LOWER_TEXT(factor)] of the place where the reaction is occuring."
else if(factor == "Energy")
factor_info["tooltip"] = "Energy released by the reaction, may or may not result in linear temperature change depending on a slew of other factors."
else if(factor == "Radiation")
Expand Down
2 changes: 1 addition & 1 deletion code/__HELPERS/chat_filter.dm
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// [2] is the group index of the blocked term when it is not using word bounds.
// This is sanity checked by unit tests.
#define GET_MATCHED_GROUP(regex) (lowertext(regex.group[2] || regex.match))
#define GET_MATCHED_GROUP(regex) (LOWER_TEXT(regex.group[2] || regex.match))

/// Given a text, will return what word is on the IC filter, with the reason.
/// Returns null if the message is OK.
Expand Down
2 changes: 1 addition & 1 deletion code/__HELPERS/hearted.dm
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
if(!heart_nominee)
return

heart_nominee = lowertext(heart_nominee)
heart_nominee = LOWER_TEXT(heart_nominee)
var/list/name_checks = get_mob_by_name(heart_nominee)
if(!name_checks || name_checks.len == 0)
query_heart(attempt + 1)
Expand Down
2 changes: 1 addition & 1 deletion code/__HELPERS/icons.dm
Original file line number Diff line number Diff line change
Expand Up @@ -679,7 +679,7 @@ world
if(uppercase == 1)
letter = uppertext(letter)
else if(uppercase == -1)
letter = lowertext(letter)
letter = LOWER_TEXT(letter)

var/image/text_image = new(loc = A)
text_image.maptext = MAPTEXT("<span style='font-size: 24pt'>[letter]</span>")
Expand Down
14 changes: 7 additions & 7 deletions code/__HELPERS/names.dm
Original file line number Diff line number Diff line change
Expand Up @@ -216,22 +216,22 @@ GLOBAL_DATUM(syndicate_code_response_regex, /regex)
if(2)
switch(rand(1,3))//Food, drinks, or places. Only selectable once.
if(1)
. += lowertext(pick(drinks))
. += LOWER_TEXT(pick(drinks))
if(2)
. += lowertext(pick(foods))
. += LOWER_TEXT(pick(foods))
if(3)
. += lowertext(pick(locations))
. += LOWER_TEXT(pick(locations))
safety -= 2
if(3)
switch(rand(1,4))//Abstract nouns, objects, adjectives, threats. Can be selected more than once.
if(1)
. += lowertext(pick(nouns))
. += LOWER_TEXT(pick(nouns))
if(2)
. += lowertext(pick(objects))
. += LOWER_TEXT(pick(objects))
if(3)
. += lowertext(pick(adjectives))
. += LOWER_TEXT(pick(adjectives))
if(4)
. += lowertext(pick(threats))
. += LOWER_TEXT(pick(threats))
if(!return_list)
if(words == 1)
. += "."
Expand Down
4 changes: 2 additions & 2 deletions code/__HELPERS/reagents.dm
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@

///Returns a list of chemical_reaction datums that have the input STRING as a product
/proc/get_reagent_type_from_product_string(string)
var/input_reagent = replacetext(lowertext(string), " ", "") //95% of the time, the reagent id is a lowercase/no spaces version of the name
var/input_reagent = replacetext(LOWER_TEXT(string), " ", "") //95% of the time, the reagent id is a lowercase/no spaces version of the name
if (isnull(input_reagent))
return

Expand Down Expand Up @@ -194,7 +194,7 @@
/proc/get_chem_id(chem_name)
for(var/X in GLOB.chemical_reagents_list)
var/datum/reagent/R = GLOB.chemical_reagents_list[X]
if(ckey(chem_name) == ckey(lowertext(R.name)))
if(ckey(chem_name) == ckey(LOWER_TEXT(R.name)))
return X

///Takes a type in and returns a list of associated recipes
Expand Down
2 changes: 1 addition & 1 deletion code/__HELPERS/sanitize_values.dm
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
if(97 to 102) //letters a to f
. += char
if(65 to 70) //letters A to F
char = lowertext(char)
char = LOWER_TEXT(char)
. += char
else
break
Expand Down
4 changes: 2 additions & 2 deletions code/__HELPERS/text.dm
Original file line number Diff line number Diff line change
Expand Up @@ -785,7 +785,7 @@ GLOBAL_LIST_INIT(binary, list("0","1"))
return string

var/base = next_backslash == 1 ? "" : copytext(string, 1, next_backslash)
var/macro = lowertext(copytext(string, next_backslash + length(string[next_backslash]), next_space))
var/macro = LOWER_TEXT(copytext(string, next_backslash + length(string[next_backslash]), next_space))
var/rest = next_backslash > leng ? "" : copytext(string, next_space + length(string[next_space]))

//See https://secure.byond.com/docs/ref/info.html#/DM/text/macros
Expand Down Expand Up @@ -1082,7 +1082,7 @@ GLOBAL_LIST_INIT(binary, list("0","1"))
var/text_length = length(text)

//remove caps since words will be shuffled
text = lowertext(text)
text = LOWER_TEXT(text)
//remove punctuation for same reasons as above
var/punctuation = ""
var/punctuation_hit_list = list("!","?",".","-")
Expand Down
2 changes: 1 addition & 1 deletion code/__HELPERS/type2type.dm
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ GLOBAL_LIST_INIT(modulo_angle_to_dir, list(NORTH,NORTHEAST,EAST,SOUTHEAST,SOUTH,
if(/turf)
return "turf"
else //regex everything else (works for /proc too)
return lowertext(replacetext("[the_type]", "[type2parent(the_type)]/", ""))
return LOWER_TEXT(replacetext("[the_type]", "[type2parent(the_type)]/", ""))

/// Return html to load a url.
/// for use inside of browse() calls to html assets that might be loaded on a cdn.
Expand Down
8 changes: 4 additions & 4 deletions code/controllers/configuration/config_entry.dm
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
/datum/config_entry/New()
if(type == abstract_type)
CRASH("Abstract config entry [type] instatiated!")
name = lowertext(type2top(type))
name = LOWER_TEXT(type2top(type))
default_protection = protection
set_default()

Expand Down Expand Up @@ -100,7 +100,7 @@
return FALSE
config_entry_value = auto_trim ? trim(str_val) : str_val
if(lowercase)
config_entry_value = lowertext(config_entry_value)
config_entry_value = LOWER_TEXT(config_entry_value)
return TRUE

/datum/config_entry/number
Expand Down Expand Up @@ -148,7 +148,7 @@
return FALSE
str_val = trim(str_val)
if (str_val != "")
config_entry_value += lowercase ? lowertext(str_val) : str_val
config_entry_value += lowercase ? LOWER_TEXT(str_val) : str_val
return TRUE

/datum/config_entry/number_list
Expand Down Expand Up @@ -246,7 +246,7 @@
config_key = jointext(config_entry_words, splitter)

if(lowercase_key)
config_key = lowertext(config_key)
config_key = LOWER_TEXT(config_key)

is_ambiguous = (length(config_entry_words) > 2)

Expand Down
14 changes: 7 additions & 7 deletions code/controllers/configuration/configuration.dm
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@
if(IsAdminAdvancedProcCall())
return

var/filename_to_test = world.system_type == MS_WINDOWS ? lowertext(filename) : filename
var/filename_to_test = world.system_type == MS_WINDOWS ? LOWER_TEXT(filename) : filename
if(filename_to_test in stack)
log_config_error("Warning: Config recursion detected ([english_list(stack)]), breaking!")
return
Expand All @@ -197,10 +197,10 @@
var/value = null

if(pos)
entry = lowertext(copytext(L, 1, pos))
entry = LOWER_TEXT(copytext(L, 1, pos))
value = copytext(L, pos + length(L[pos]))
else
entry = lowertext(L)
entry = LOWER_TEXT(L)

if(!entry)
continue
Expand All @@ -215,7 +215,7 @@

// Reset directive, used for setting a config value back to defaults. Useful for string list config types
if (entry == "$reset")
var/datum/config_entry/resetee = _entries[lowertext(value)]
var/datum/config_entry/resetee = _entries[LOWER_TEXT(value)]
if (!value || !resetee)
log_config_error("Warning: invalid $reset directive: [value]")
continue
Expand Down Expand Up @@ -366,10 +366,10 @@ Example config:
var/data = null

if(pos)
command = lowertext(copytext(t, 1, pos))
command = LOWER_TEXT(copytext(t, 1, pos))
data = copytext(t, pos + length(t[pos]))
else
command = lowertext(t)
command = LOWER_TEXT(t)

if(!command)
continue
Expand Down Expand Up @@ -473,7 +473,7 @@ Example config:
var/list/formatted_banned_words = list()

for (var/banned_word in banned_words)
formatted_banned_words[lowertext(banned_word)] = banned_words[banned_word]
formatted_banned_words[LOWER_TEXT(banned_word)] = banned_words[banned_word]
return formatted_banned_words

/datum/controller/configuration/proc/compile_filter_regex(list/banned_words)
Expand Down
2 changes: 1 addition & 1 deletion code/controllers/configuration/entries/resources.dm
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

/datum/config_entry/string/asset_transport
/datum/config_entry/string/asset_transport/ValidateAndSet(str_val)
return (lowertext(str_val) in list("simple", "webroot")) && ..(lowertext(str_val))
return (LOWER_TEXT(str_val) in list("simple", "webroot")) && ..(LOWER_TEXT(str_val))

/datum/config_entry/string/asset_cdn_webroot
protection = CONFIG_ENTRY_LOCKED
Expand Down
4 changes: 2 additions & 2 deletions code/controllers/subsystem/ticker.dm
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ SUBSYSTEM_DEF(ticker)
var/use_rare_music = prob(1)

for(var/S in provisional_title_music)
var/lower = lowertext(S)
var/lower = LOWER_TEXT(S)
var/list/L = splittext(lower,"+")
switch(L.len)
if(3) //rare+MAP+sound.ogg or MAP+rare.sound.ogg -- Rare Map-specific sounds
Expand All @@ -116,7 +116,7 @@ SUBSYSTEM_DEF(ticker)
for(var/S in music)
var/list/L = splittext(S,".")
if(L.len >= 2)
var/ext = lowertext(L[L.len]) //pick the real extension, no 'honk.ogg.exe' nonsense here
var/ext = LOWER_TEXT(L[L.len]) //pick the real extension, no 'honk.ogg.exe' nonsense here
if(byond_sound_formats[ext])
continue
music -= S
Expand Down
2 changes: 1 addition & 1 deletion code/controllers/subsystem/title.dm
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ SUBSYSTEM_DEF(title)
for(var/S in provisional_title_screens)
var/list/L = splittext(S,"+")
if((L.len == 1 && (L[1] != "exclude" && L[1] != "blank.png")) || (L.len > 1 && ((use_rare_screens && lowertext(L[1]) == "rare") || (lowertext(L[1]) == lowertext(SSmapping.config.map_name)))))
if((L.len == 1 && (L[1] != "exclude" && L[1] != "blank.png")) || (L.len > 1 && ((use_rare_screens && LOWER_TEXT(L[1]) == "rare") || (LOWER_TEXT(L[1]) == LOWER_TEXT(SSmapping.config.map_name)))))
title_screens += S
if(length(title_screens))
Expand Down
2 changes: 1 addition & 1 deletion code/datums/brain_damage/hypnosis.dm
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
..()
if(SPT_PROB(1, seconds_per_tick))
if(prob(50))
to_chat(owner, span_hypnophrase("<i>...[lowertext(hypnotic_phrase)]...</i>"))
to_chat(owner, span_hypnophrase("<i>...[LOWER_TEXT(hypnotic_phrase)]...</i>"))
else
owner.cause_hallucination( \
/datum/hallucination/chat, \
Expand Down
2 changes: 1 addition & 1 deletion code/datums/brain_damage/mild.dm
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@
word = copytext(word, 1, suffix_foundon)
word = html_decode(word)

if(lowertext(word) in common_words)
if(LOWER_TEXT(word) in common_words)
new_message += word + suffix
else
if(prob(30) && message_split.len > 2)
Expand Down
6 changes: 3 additions & 3 deletions code/datums/components/cult_ritual_item.dm
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@
cultist.log_message("erased a [rune.cultist_name] rune with [parent].", LOG_GAME)
message_admins("[ADMIN_LOOKUPFLW(cultist)] erased a [rune.cultist_name] rune with [parent].")

to_chat(cultist, span_notice("You carefully erase the [lowertext(rune.cultist_name)] rune."))
to_chat(cultist, span_notice("You carefully erase the [LOWER_TEXT(rune.cultist_name)] rune."))
qdel(rune)

/*
Expand Down Expand Up @@ -338,8 +338,8 @@
var/obj/effect/rune/made_rune = new rune_to_scribe(our_turf, chosen_keyword)
made_rune.add_mob_blood(cultist)

to_chat(cultist, span_cult("The [lowertext(made_rune.cultist_name)] rune [made_rune.cultist_desc]"))
cultist.log_message("scribed \a [lowertext(made_rune.cultist_name)] rune using [parent] ([parent.type])", LOG_GAME)
to_chat(cultist, span_cult("The [LOWER_TEXT(made_rune.cultist_name)] rune [made_rune.cultist_desc]"))
cultist.log_message("scribed \a [LOWER_TEXT(made_rune.cultist_name)] rune using [parent] ([parent.type])", LOG_GAME)
SSblackbox.record_feedback("tally", "cult_runes_scribed", 1, made_rune.cultist_name)

return TRUE
Expand Down
4 changes: 2 additions & 2 deletions code/datums/components/deadchat_control.dm
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
/datum/component/deadchat_control/proc/deadchat_react(mob/source, message)
SIGNAL_HANDLER

message = lowertext(message)
message = LOWER_TEXT(message)

if(!inputs[message])
return
Expand Down Expand Up @@ -162,7 +162,7 @@
*/
/datum/component/deadchat_control/proc/waive_automute(mob/speaker, client/client, message, mute_type)
SIGNAL_HANDLER
if(mute_type == MUTE_DEADCHAT && inputs[lowertext(message)])
if(mute_type == MUTE_DEADCHAT && inputs[LOWER_TEXT(message)])
return WAIVE_AUTOMUTE_CHECK
return NONE

Expand Down
2 changes: 1 addition & 1 deletion code/datums/components/food/edible.dm
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ Behavior that's still missing from this component that original food items had t

if(foodtypes)
var/list/types = bitfield_to_list(foodtypes, FOOD_FLAGS)
examine_list += span_notice("It is [lowertext(english_list(types))].")
examine_list += span_notice("It is [LOWER_TEXT(english_list(types))].")

var/quality = get_perceived_food_quality(user)
if(quality > 0)
Expand Down
2 changes: 1 addition & 1 deletion code/datums/components/material/material_container.dm
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
var/datum/material/M = I
var/amt = materials[I] / SHEET_MATERIAL_AMOUNT
if(amt)
examine_texts += span_notice("It has [amt] sheets of [lowertext(M.name)] stored.")
examine_texts += span_notice("It has [amt] sheets of [LOWER_TEXT(M.name)] stored.")

/datum/component/material_container/vv_edit_var(var_name, var_value)
var/old_flags = mat_container_flags
Expand Down
2 changes: 1 addition & 1 deletion code/datums/components/surgery_initiator.dm
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@
var/datum/surgery/procedure = new surgery.type(target, selected_zone, affecting_limb)
ADD_TRAIT(target, TRAIT_ALLOWED_HONORBOUND_ATTACK, type)

target.balloon_alert(user, "starting \"[lowertext(procedure.name)]\"")
target.balloon_alert(user, "starting \"[LOWER_TEXT(procedure.name)]\"")

user.visible_message(
span_notice("[user] drapes [parent] over [target]'s [parse_zone(selected_zone)] to prepare for surgery."),
Expand Down
8 changes: 4 additions & 4 deletions code/datums/components/uplink.dm
Original file line number Diff line number Diff line change
Expand Up @@ -378,8 +378,8 @@
/datum/component/uplink/proc/new_ringtone(datum/source, mob/living/user, new_ring_text)
SIGNAL_HANDLER

if(trim(lowertext(new_ring_text)) != trim(lowertext(unlock_code)))
if(trim(lowertext(new_ring_text)) == trim(lowertext(failsafe_code)))
if(trim(LOWER_TEXT(new_ring_text)) != trim(LOWER_TEXT(unlock_code)))
if(trim(LOWER_TEXT(new_ring_text)) == trim(LOWER_TEXT(failsafe_code)))
failsafe(user)
return COMPONENT_STOP_RINGTONE_CHANGE
return
Expand Down Expand Up @@ -415,8 +415,8 @@
if(channel != RADIO_CHANNEL_UPLINK)
return

if(!findtext(lowertext(message), lowertext(unlock_code)))
if(failsafe_code && findtext(lowertext(message), lowertext(failsafe_code)))
if(!findtext(LOWER_TEXT(message), LOWER_TEXT(unlock_code)))
if(failsafe_code && findtext(LOWER_TEXT(message), LOWER_TEXT(failsafe_code)))
failsafe(user) // no point returning cannot radio, youre probably ded
return
locked = FALSE
Expand Down
Loading

0 comments on commit 86aa41d

Please sign in to comment.