diff --git a/code/__DEFINES/typeids.dm b/code/__DEFINES/typeids.dm index b86d9043e1..275f7719f0 100644 --- a/code/__DEFINES/typeids.dm +++ b/code/__DEFINES/typeids.dm @@ -2,7 +2,7 @@ #define TYPEID_NULL "0" #define TYPEID_NORMAL_LIST "f" //helper macros -#define GET_TYPEID(ref) ( ( (length(ref) <= 10) ? "TYPEID_NULL" : copytext(ref, 4, -6) ) ) +#define GET_TYPEID(ref) ( ( (length(ref) <= 10) ? "TYPEID_NULL" : copytext(ref, 4, -7) ) ) #define IS_NORMAL_LIST(L) (GET_TYPEID("\ref[L]") == TYPEID_NORMAL_LIST) diff --git a/code/modules/mob/living/carbon/human/say.dm b/code/modules/mob/living/carbon/human/say.dm index 8e12ac97d3..29597344cf 100644 --- a/code/modules/mob/living/carbon/human/say.dm +++ b/code/modules/mob/living/carbon/human/say.dm @@ -87,30 +87,22 @@ /mob/living/carbon/human/proc/forcesay(list/append) //this proc is at the bottom of the file because quote fuckery makes notepad++ cri if(stat == CONSCIOUS) if(client) - var/virgin = 1 //has the text been modified yet? var/temp = winget(client, "input", "text") - if(findtextEx(temp, "Say \"", 1, 7) && length(temp) > 5) //"case sensitive means + var/say_starter = "Say \"" //" + if(findtextEx(temp, say_starter, 1, length(say_starter) + 1) && length(temp) > length(say_starter)) //case sensitive means - temp = replacetext(temp, ";", "") //general radio + temp = trim_left(copytext(temp, length(say_starter + 1))) + temp = replacetext(temp, ";", "", 1, 2) //general radio + while(trim_left(temp)[1] == ":") //dept radio again (necessary) + temp = copytext_char(trim_left(temp), 3) - if(findtext(trim_left(temp), ":", 6, 7)) //dept radio - temp = copytext(trim_left(temp), 8) - virgin = 0 - - if(virgin) - temp = copytext(trim_left(temp), 6) //normal speech - virgin = 0 - - while(findtext(trim_left(temp), ":", 1, 2)) //dept radio again (necessary) - temp = copytext(trim_left(temp), 3) - - if(findtext(temp, "*", 1, 2)) //emotes + if(temp[1] == "*") //emotes return var/trimmed = trim_left(temp) if(length(trimmed)) if(append) - temp += pick(append) + trimmed += pick(append) - say(temp) + say(trimmed) winset(client, "input", "text=[null]") diff --git a/code/modules/mob/living/silicon/ai/say.dm b/code/modules/mob/living/silicon/ai/say.dm index d9cc3a0c7b..4a76eafc53 100644 --- a/code/modules/mob/living/silicon/ai/say.dm +++ b/code/modules/mob/living/silicon/ai/say.dm @@ -26,7 +26,8 @@ ..() /mob/living/silicon/ai/get_message_mode(message) - if(copytext(message, 1, 3) in list(":h", ":H", ".h", ".H", "#h", "#H")) + var/static/regex/holopad_finder = regex(@"[:.#][hH]") + if(holopad_finder.Find(message, 1, 1)) return MODE_HOLOPAD else return ..() diff --git a/code/modules/mob/living/silicon/pai/personality.dm b/code/modules/mob/living/silicon/pai/personality.dm index acb2273c41..62f2ed7047 100644 --- a/code/modules/mob/living/silicon/pai/personality.dm +++ b/code/modules/mob/living/silicon/pai/personality.dm @@ -8,7 +8,7 @@ */ /datum/paiCandidate/proc/savefile_path(mob/user) - return "data/player_saves/[copytext(user.ckey, 1, 2)]/[user.ckey]/pai.sav" + return "data/player_saves/[user.ckey[1]]/[user.ckey]/pai.sav" /datum/paiCandidate/proc/savefile_save(mob/user) if(IsGuestKey(user.key)) diff --git a/code/modules/mob/living/simple_animal/parrot.dm b/code/modules/mob/living/simple_animal/parrot.dm index f6b29b95aa..f386231d7a 100644 --- a/code/modules/mob/living/simple_animal/parrot.dm +++ b/code/modules/mob/living/simple_animal/parrot.dm @@ -208,8 +208,8 @@ ears.forceMove(drop_location()) ears = null for(var/possible_phrase in speak) - if(copytext(possible_phrase,1,3) in GLOB.department_radio_keys) - possible_phrase = copytext(possible_phrase,3) + if(copytext_char(possible_phrase, 2, 3) in GLOB.department_radio_keys) + possible_phrase = copytext_char(possible_phrase, 3) //Adding things to inventory else if(href_list["add_inv"]) @@ -419,8 +419,8 @@ if(prob(50)) useradio = 1 - if((copytext(possible_phrase,1,2) in GLOB.department_radio_prefixes) && (copytext(possible_phrase,2,3) in GLOB.department_radio_keys)) - possible_phrase = "[useradio?pick(available_channels):""][copytext(possible_phrase,3)]" //crop out the channel prefix + if((possible_phrase[1] in GLOB.department_radio_prefixes) && (copytext_char(possible_phrase, 2, 3) in GLOB.department_radio_keys)) + possible_phrase = "[useradio?pick(available_channels):""][copytext_char(possible_phrase, 3)]" //crop out the channel prefix else possible_phrase = "[useradio?pick(available_channels):""][possible_phrase]" @@ -428,8 +428,8 @@ else //If we have no headset or channels to use, dont try to use any! for(var/possible_phrase in speak) - if((copytext(possible_phrase,1,2) in GLOB.department_radio_prefixes) && (copytext(possible_phrase,2,3) in GLOB.department_radio_keys)) - possible_phrase = copytext(possible_phrase,3) //crop out the channel prefix + if((possible_phrase[1] in GLOB.department_radio_prefixes) && (copytext_char(possible_phrase, 2, 3) in GLOB.department_radio_keys)) + possible_phrase = copytext_char(possible_phrase, 3) //crop out the channel prefix newspeak.Add(possible_phrase) speak = newspeak diff --git a/code/modules/paperwork/folders.dm b/code/modules/paperwork/folders.dm index 0a4bdf0c1c..4cd44af5ab 100644 --- a/code/modules/paperwork/folders.dm +++ b/code/modules/paperwork/folders.dm @@ -44,9 +44,11 @@ if(!user.is_literate()) to_chat(user, "You scribble illegibly on the cover of [src]!") return - var/n_name = copytext(sanitize(input(user, "What would you like to label the folder?", "Folder Labelling", null) as text), 1, MAX_NAME_LEN) + var/inputvalue = stripped_input(user, "What would you like to label the folder?", "Folder Labelling", "", MAX_NAME_LEN) + if(!inputvalue) + return if(user.canUseTopic(src, BE_CLOSE)) - name = "folder[(n_name ? " - '[n_name]'" : null)]" + name = "folder - '[inputvalue]'" /obj/item/folder/attack_self(mob/user) diff --git a/code/modules/paperwork/handlabeler.dm b/code/modules/paperwork/handlabeler.dm index 7c0edf3f0e..d054e5ff12 100644 --- a/code/modules/paperwork/handlabeler.dm +++ b/code/modules/paperwork/handlabeler.dm @@ -70,7 +70,7 @@ if(mode) to_chat(user, "You turn on [src].") //Now let them chose the text. - var/str = copytext(reject_bad_text(input(user,"Label text?","Set label","")),1,MAX_NAME_LEN) + var/str = reject_bad_text(stripped_input(user, "Label text?", "Set label","", MAX_NAME_LEN)) if(!str || !length(str)) to_chat(user, "Invalid text!") return diff --git a/code/modules/paperwork/paper.dm b/code/modules/paperwork/paper.dm index c9b7fb7b57..20f4ab0c86 100644 --- a/code/modules/paperwork/paper.dm +++ b/code/modules/paperwork/paper.dm @@ -152,7 +152,10 @@ if(istart == 0) return //No field found with matching id - laststart = istart+1 + if(links) + laststart = istart + length(info_links[istart]) + else + laststart = istart + length(info[istart]) locid++ if(locid == id) var/iend = 1 diff --git a/code/modules/photography/_pictures.dm b/code/modules/photography/_pictures.dm index 62fc01efda..f667e18f47 100644 --- a/code/modules/photography/_pictures.dm +++ b/code/modules/photography/_pictures.dm @@ -111,9 +111,9 @@ if(data.len < 5) return null var/timestamp = data[2] - var/year = copytext(timestamp, 1, 5) - var/month = copytext(timestamp, 5, 7) - var/day = copytext(timestamp, 7, 9) + var/year = copytext_char(timestamp, 1, 5) + var/month = copytext_char(timestamp, 5, 7) + var/day = copytext_char(timestamp, 7, 9) var/round = data[4] . += "[year]/[month]/[day]/round-[round]" if("O") diff --git a/code/modules/photography/photos/photo.dm b/code/modules/photography/photos/photo.dm index b15aa308a3..d51f569738 100644 --- a/code/modules/photography/photos/photo.dm +++ b/code/modules/photography/photos/photo.dm @@ -55,9 +55,8 @@ if(!user.is_literate()) to_chat(user, "You scribble illegibly on [src]!") return - var/txt = sanitize(input(user, "What would you like to write on the back?", "Photo Writing", null) as text) - txt = copytext(txt, 1, 128) - if(user.canUseTopic(src, BE_CLOSE)) + var/txt = stripped_input(user, "What would you like to write on the back?", "Photo Writing", "", 128) + if(txt && user.canUseTopic(src, BE_CLOSE)) scribble = txt ..() @@ -85,8 +84,8 @@ set category = "Object" set src in usr - var/n_name = copytext(sanitize(input(usr, "What would you like to label the photo?", "Photo Labelling", null) as text), 1, MAX_NAME_LEN) + var/n_name = stripped_input(usr, "What would you like to label the photo?", "Photo Labelling", "", MAX_NAME_LEN) //loc.loc check is for making possible renaming photos in clipboards - if((loc == usr || loc.loc && loc.loc == usr) && usr.stat == CONSCIOUS && usr.canmove && !usr.restrained()) + if(n_name && (loc == usr || loc.loc && loc.loc == usr) && usr.stat == CONSCIOUS && usr.canmove && !usr.restrained()) name = "photo[(n_name ? text("- '[n_name]'") : null)]" add_fingerprint(usr) diff --git a/code/modules/power/cable.dm b/code/modules/power/cable.dm index cee9a17ebf..3c807390a0 100644 --- a/code/modules/power/cable.dm +++ b/code/modules/power/cable.dm @@ -85,8 +85,8 @@ By design, d1 is the smallest direction and d2 is the highest if(isnull(_d1) || isnull(_d2)) // ensure d1 & d2 reflect the icon_state for entering and exiting cable var/dash = findtext(icon_state, "-") - d1 = text2num( copytext( icon_state, 1, dash ) ) - d2 = text2num( copytext( icon_state, dash+1 ) ) + d1 = text2num(copytext(icon_state, 1, dash)) + d2 = text2num(copytext(icon_state, dash + length(icon_state[dash]))) else d1 = _d1 d2 = _d2 diff --git a/code/modules/procedural_mapping/mapGenerator.dm b/code/modules/procedural_mapping/mapGenerator.dm index 4c9e1dddea..f509c409ce 100644 --- a/code/modules/procedural_mapping/mapGenerator.dm +++ b/code/modules/procedural_mapping/mapGenerator.dm @@ -30,7 +30,7 @@ /datum/mapGenerator/New() ..() if(buildmode_name == "Undocumented") - buildmode_name = copytext("[type]", 20) // / d a t u m / m a p g e n e r a t o r / = 20 characters. + buildmode_name = copytext_char("[type]", 20) // / d a t u m / m a p g e n e r a t o r / = 20 characters. initialiseModules() //Defines the region the map represents, sets map diff --git a/code/modules/reagents/chem_wiki_render.dm b/code/modules/reagents/chem_wiki_render.dm index e24da70d47..018161b075 100644 --- a/code/modules/reagents/chem_wiki_render.dm +++ b/code/modules/reagents/chem_wiki_render.dm @@ -196,7 +196,7 @@ return "" - var/outstring = "|
!\[[R.color]\](https://placehold.it/15/[copytext(R.color, 2, 8)]/000000?text=+)[R.name]
pH: [R.pH] | " + var/outstring = "|
!\[[R.color]\](https://placehold.it/15/[copytext_char(R.color, 2, 8)]/000000?text=+)[R.name]
pH: [R.pH] | " var/datum/reagent/R3 if(CR) outstring += "