diff --git a/code/__DEFINES/typeids.dm b/code/__DEFINES/typeids.dm
index 8bfe6216e26..b86d9043e16 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, length(ref)-6) ) )
+#define GET_TYPEID(ref) ( ( (length(ref) <= 10) ? "TYPEID_NULL" : copytext(ref, 4, -6) ) )
#define IS_NORMAL_LIST(L) (GET_TYPEID("\ref[L]") == TYPEID_NORMAL_LIST)
diff --git a/code/__HELPERS/files.dm b/code/__HELPERS/files.dm
index 84d36f9db4b..ba53368ae9c 100644
--- a/code/__HELPERS/files.dm
+++ b/code/__HELPERS/files.dm
@@ -20,7 +20,7 @@
continue
path += choice
- if(copytext(path,-1,0) != "/") //didn't choose a directory, no need to iterate again
+ if(copytext_char(path, -1) != "/") //didn't choose a directory, no need to iterate again
break
var/extensions
for(var/i in valid_extensions)
diff --git a/code/__HELPERS/icons.dm b/code/__HELPERS/icons.dm
index 1944cff9c61..53eec1504d6 100644
--- a/code/__HELPERS/icons.dm
+++ b/code/__HELPERS/icons.dm
@@ -981,7 +981,7 @@ world
var/icon/atom_icon = new(A.icon, A.icon_state)
if(!letter)
- letter = copytext(A.name, 1, 2)
+ letter = A.name[1]
if(uppercase == 1)
letter = uppertext(letter)
else if(uppercase == -1)
@@ -1109,7 +1109,7 @@ GLOBAL_LIST_INIT(freon_color_matrix, list("#2E5E69", "#60A2A8", "#A1AFB1", rgb(0
WRITE_FILE(GLOB.iconCache[iconKey], icon)
var/iconData = GLOB.iconCache.ExportText(iconKey)
var/list/partial = splittext(iconData, "{")
- return replacetext(copytext(partial[2], 3, -5), "\n", "")
+ return replacetext(copytext_char(partial[2], 3, -5), "\n", "")
/proc/icon2html(thing, target, icon_state, dir, frame = 1, moving = FALSE)
if (!thing)
diff --git a/code/__HELPERS/pronouns.dm b/code/__HELPERS/pronouns.dm
index ae803b8c8f1..bfe09ba370c 100644
--- a/code/__HELPERS/pronouns.dm
+++ b/code/__HELPERS/pronouns.dm
@@ -28,10 +28,10 @@
. = "does"
/datum/proc/p_theyve(capitalized, temp_gender)
- . = p_they(capitalized, temp_gender) + "'" + copytext(p_have(temp_gender), 3)
+ . = p_they(capitalized, temp_gender) + "'" + copytext_char(p_have(temp_gender), 3)
/datum/proc/p_theyre(capitalized, temp_gender)
- . = p_they(capitalized, temp_gender) + "'" + copytext(p_are(temp_gender), 2)
+ . = p_they(capitalized, temp_gender) + "'" + copytext_char(p_are(temp_gender), 2)
/datum/proc/p_s(temp_gender) //is this a descriptive proc name, or what?
. = "s"
diff --git a/code/__HELPERS/sanitize_values.dm b/code/__HELPERS/sanitize_values.dm
index 4a6a9758d2c..9a2e18f3156 100644
--- a/code/__HELPERS/sanitize_values.dm
+++ b/code/__HELPERS/sanitize_values.dm
@@ -80,7 +80,9 @@
return crunch + .
/proc/sanitize_ooccolor(color)
- var/list/HSL = rgb2hsl(hex2num(copytext(color,2,4)),hex2num(copytext(color,4,6)),hex2num(copytext(color,6,8)))
+ if(length(color) != length_char(color))
+ CRASH("Invalid characters in color '[color]'")
+ var/list/HSL = rgb2hsl(hex2num(copytext(color, 2, 4)), hex2num(copytext(color, 4, 6)), hex2num(copytext(color, 6, 8)))
HSL[3] = min(HSL[3],0.4)
var/list/RGB = hsl2rgb(arglist(HSL))
return "#[num2hex(RGB[1],2)][num2hex(RGB[2],2)][num2hex(RGB[3],2)]"
diff --git a/code/__HELPERS/shell.dm b/code/__HELPERS/shell.dm
index eed86a3bd10..35a8e4635b4 100644
--- a/code/__HELPERS/shell.dm
+++ b/code/__HELPERS/shell.dm
@@ -55,6 +55,6 @@
if(bad_chars)
bad_match = url_encode(bad_chars_regex.match)
scrubbed_url += bad_match
- last_good = bad_chars + length(bad_match)
+ last_good = bad_chars + length(bad_chars_regex.match)
while(bad_chars)
. = scrubbed_url
diff --git a/code/__HELPERS/type2type.dm b/code/__HELPERS/type2type.dm
index 9495d2fb174..2026397a047 100644
--- a/code/__HELPERS/type2type.dm
+++ b/code/__HELPERS/type2type.dm
@@ -485,17 +485,17 @@
//assumes format #RRGGBB #rrggbb
/proc/color_hex2num(A)
- if(!A)
+ if(!A || length(A) != length_char(A))
return 0
- var/R = hex2num(copytext(A,2,4))
- var/G = hex2num(copytext(A,4,6))
- var/B = hex2num(copytext(A,6,0))
+ var/R = hex2num(copytext(A, 2, 4))
+ var/G = hex2num(copytext(A, 4, 6))
+ var/B = hex2num(copytext(A, 6, 8))
return R+G+B
//word of warning: using a matrix like this as a color value will simplify it back to a string after being set
/proc/color_hex2color_matrix(string)
var/length = length(string)
- if(length != 7 && length != 9)
+ if((length != 7 && length != 9) || length != length_char(string))
return color_matrix_identity()
var/r = hex2num(copytext(string, 2, 4))/255
var/g = hex2num(copytext(string, 4, 6))/255
diff --git a/code/__HELPERS/type_processing.dm b/code/__HELPERS/type_processing.dm
index 50684c79532..05a0dd28552 100644
--- a/code/__HELPERS/type_processing.dm
+++ b/code/__HELPERS/type_processing.dm
@@ -31,8 +31,8 @@
/mob = "M"
)
for (var/tn in TYPES_SHORTCUTS)
- if (copytext(typename,1, length("[tn]/")+1)=="[tn]/" /*findtextEx(typename,"[tn]/",1,2)*/ )
- typename = TYPES_SHORTCUTS[tn]+copytext(typename,length("[tn]/"))
+ if(copytext(typename, 1, length("[tn]/") + 1) == "[tn]/" /*findtextEx(typename,"[tn]/",1,2)*/ )
+ typename = TYPES_SHORTCUTS[tn] + copytext(typename, length("[tn]/"))
break
.[typename] = type
diff --git a/code/__HELPERS/unsorted.dm b/code/__HELPERS/unsorted.dm
index f49e49e2895..e6feb5274ac 100644
--- a/code/__HELPERS/unsorted.dm
+++ b/code/__HELPERS/unsorted.dm
@@ -6,22 +6,16 @@
//Inverts the colour of an HTML string
/proc/invertHTML(HTMLstring)
-
- if (!( istext(HTMLstring) ))
+ if(!istext(HTMLstring))
CRASH("Given non-text argument!")
- else
- if (length(HTMLstring) != 7)
- CRASH("Given non-HTML argument!")
+ else if(length(HTMLstring) != 7)
+ CRASH("Given non-HTML argument!")
+ else if(length_char(HTMLstring) != 7)
+ CRASH("Given non-hex symbols in argument!")
var/textr = copytext(HTMLstring, 2, 4)
var/textg = copytext(HTMLstring, 4, 6)
var/textb = copytext(HTMLstring, 6, 8)
- var/r = hex2num(textr)
- var/g = hex2num(textg)
- var/b = hex2num(textb)
- textr = num2hex(255 - r, 2)
- textg = num2hex(255 - g, 2)
- textb = num2hex(255 - b, 2)
- return text("#[][][]", textr, textg, textb)
+ return rgb(255 - hex2num(textr), 255 - hex2num(textg), 255 - hex2num(textb))
/proc/Get_Angle(atom/movable/start,atom/movable/end)//For beams.
if(!start || !end)
@@ -1400,7 +1394,7 @@ GLOBAL_DATUM_INIT(dview_mob, /mob/dview, new)
/proc/GUID()
var/const/GUID_VERSION = "b"
var/const/GUID_VARIANT = "d"
- var/node_id = copytext(md5("[rand()*rand(1,9999999)][world.name][world.hub][world.hub_password][world.internet_address][world.address][world.contents.len][world.status][world.port][rand()*rand(1,9999999)]"), 1, 13)
+ var/node_id = copytext_char(md5("[rand()*rand(1,9999999)][world.name][world.hub][world.hub_password][world.internet_address][world.address][world.contents.len][world.status][world.port][rand()*rand(1,9999999)]"), 1, 13)
var/time_high = "[num2hex(text2num(time2text(world.realtime,"YYYY")), 2)][num2hex(world.realtime, 6)]"
diff --git a/code/controllers/configuration/config_entry.dm b/code/controllers/configuration/config_entry.dm
index 49ff1c8d498..0115d5cb975 100644
--- a/code/controllers/configuration/config_entry.dm
+++ b/code/controllers/configuration/config_entry.dm
@@ -163,7 +163,8 @@
if(key_pos || value_mode == VALUE_MODE_FLAG)
key_name = lowertext(copytext(str_val, 1, key_pos))
- key_value = copytext(str_val, key_pos + 1)
+ if(key_pos)
+ key_value = copytext(str_val, key_pos + length(str_val[key_pos]))
var/new_key
var/new_value
var/continue_check_value
diff --git a/code/controllers/configuration/configuration.dm b/code/controllers/configuration/configuration.dm
index 5f874a8dd9c..e93c804ac25 100644
--- a/code/controllers/configuration/configuration.dm
+++ b/code/controllers/configuration/configuration.dm
@@ -111,13 +111,13 @@
if(!L)
continue
- var/firstchar = copytext(L, 1, 2)
+ var/firstchar = L[1]
if(firstchar == "#")
continue
var/lockthis = firstchar == "@"
if(lockthis)
- L = copytext(L, 2)
+ L = copytext(L, length(firstchar) + 1)
var/pos = findtext(L, " ")
var/entry = null
@@ -125,7 +125,7 @@
if(pos)
entry = lowertext(copytext(L, 1, pos))
- value = copytext(L, pos + 1)
+ value = copytext(L, pos + length(L[pos]))
else
entry = lowertext(L)
@@ -291,7 +291,7 @@ Example config:
t = trim(t)
if(length(t) == 0)
continue
- else if(copytext(t, 1, 2) == "#")
+ else if(t[1] == "#")
continue
var/pos = findtext(t, " ")
@@ -300,7 +300,7 @@ Example config:
if(pos)
command = lowertext(copytext(t, 1, pos))
- data = copytext(t, pos + 1)
+ data = copytext(t, pos + length(t[pos]))
else
command = lowertext(t)
diff --git a/code/controllers/subsystem/pai.dm b/code/controllers/subsystem/pai.dm
index b802c6868f7..2583ae99c87 100644
--- a/code/controllers/subsystem/pai.dm
+++ b/code/controllers/subsystem/pai.dm
@@ -37,34 +37,34 @@ SUBSYSTEM_DEF(pai)
switch(option)
if("name")
- t = input("Enter a name for your pAI", "pAI Name", candidate.name) as text|null
+ t = sanitize_name(stripped_input(usr, "Enter a name for your pAI", "pAI Name", candidate.name, MAX_NAME_LEN))
if(t)
- candidate.name = copytext(sanitize_name(t),1,MAX_NAME_LEN)
+ candidate.name = t
if("desc")
- t = input("Enter a description for your pAI", "pAI Description", candidate.description) as message|null
+ t = stripped_multiline_input(usr, "Enter a description for your pAI", "pAI Description", candidate.description, MAX_MESSAGE_LEN)
if(t)
- candidate.description = copytext(sanitize(t),1,MAX_MESSAGE_LEN)
+ candidate.description = t
if("role")
- t = input("Enter a role for your pAI", "pAI Role", candidate.role) as text|null
+ t = stripped_input(usr, "Enter a role for your pAI", "pAI Role", candidate.role, MAX_MESSAGE_LEN)
if(t)
- candidate.role = copytext(sanitize(t),1,MAX_MESSAGE_LEN)
+ candidate.role = t
if("ooc")
- t = input("Enter any OOC comments", "pAI OOC Comments", candidate.comments) as message|null
+ t = stripped_multiline_input(usr, "Enter any OOC comments", "pAI OOC Comments", candidate.comments, MAX_MESSAGE_LEN)
if(t)
- candidate.comments = copytext(sanitize(t),1,MAX_MESSAGE_LEN)
+ candidate.comments = t
if("save")
candidate.savefile_save(usr)
if("load")
candidate.savefile_load(usr)
//In case people have saved unsanitized stuff.
if(candidate.name)
- candidate.name = copytext(sanitize(candidate.name),1,MAX_NAME_LEN)
+ candidate.name = copytext_char(sanitize(candidate.name),1,MAX_NAME_LEN)
if(candidate.description)
- candidate.description = copytext(sanitize(candidate.description),1,MAX_MESSAGE_LEN)
+ candidate.description = copytext_char(sanitize(candidate.description),1,MAX_MESSAGE_LEN)
if(candidate.role)
- candidate.role = copytext(sanitize(candidate.role),1,MAX_MESSAGE_LEN)
+ candidate.role = copytext_char(sanitize(candidate.role),1,MAX_MESSAGE_LEN)
if(candidate.comments)
- candidate.comments = copytext(sanitize(candidate.comments),1,MAX_MESSAGE_LEN)
+ candidate.comments = copytext_char(sanitize(candidate.comments),1,MAX_MESSAGE_LEN)
if("submit")
if(candidate)
diff --git a/code/controllers/subsystem/processing/networks.dm b/code/controllers/subsystem/processing/networks.dm
index 0ca5472a6a2..719e97d1eed 100644
--- a/code/controllers/subsystem/processing/networks.dm
+++ b/code/controllers/subsystem/processing/networks.dm
@@ -46,6 +46,6 @@ PROCESSING_SUBSYSTEM_DEF(networks)
var/hex = md5(string)
if(!hex)
return //errored
- . = "[copytext(hex, 1, 9)]" //16 ^ 8 possibilities I think.
+ . = "[copytext_char(hex, 1, 9)]" //16 ^ 8 possibilities I think.
if(interfaces_by_id[.])
return resolve_collisions? make_address("[num2text(rand(HID_RESTRICTED_END, 999999999), 12)]"):null
diff --git a/code/datums/brain_damage/imaginary_friend.dm b/code/datums/brain_damage/imaginary_friend.dm
index 17c26854b76..6b4766aba3a 100644
--- a/code/datums/brain_damage/imaginary_friend.dm
+++ b/code/datums/brain_damage/imaginary_friend.dm
@@ -152,7 +152,7 @@
to_chat(src, compose_message(speaker, message_language, raw_message, radio_freq, spans, message_mode))
/mob/camera/imaginary_friend/proc/friend_talk(message)
- message = capitalize(trim(copytext(sanitize(message), 1, MAX_MESSAGE_LEN)))
+ message = capitalize(trim(copytext_char(sanitize(message), 1, MAX_MESSAGE_LEN)))
if(!message)
return
diff --git a/code/datums/components/gps.dm b/code/datums/components/gps.dm
index 3118deb6c2a..890a854694c 100644
--- a/code/datums/components/gps.dm
+++ b/code/datums/components/gps.dm
@@ -133,12 +133,11 @@ GLOBAL_LIST_EMPTY(GPS_list)
switch(action)
if("rename")
var/atom/parentasatom = parent
- var/a = input("Please enter desired tag.", parentasatom.name, gpstag) as text|null
+ var/a = stripped_input(usr, "Please enter desired tag.", parentasatom.name, gpstag, 20)
if (!a)
return
- a = copytext(sanitize(a), 1, 20)
gpstag = a
. = TRUE
parentasatom.name = "global positioning system ([gpstag])"
diff --git a/code/datums/dna.dm b/code/datums/dna.dm
index 6095e70fa14..231fc1ec01f 100644
--- a/code/datums/dna.dm
+++ b/code/datums/dna.dm
@@ -156,8 +156,8 @@
if(active)
return sequence
while(difficulty)
- var/randnum = rand(1, length(sequence))
- sequence = copytext(sequence, 1, randnum) + "X" + copytext(sequence, randnum+1, length(sequence)+1)
+ var/randnum = rand(1, length_char(sequence))
+ sequence = copytext_char(sequence, 1, randnum) + "X" + copytext_char(sequence, randnum + 1)
difficulty--
return sequence
@@ -461,14 +461,14 @@
/proc/getleftblocks(input,blocknumber,blocksize)
if(blocknumber > 1)
- return copytext(input,1,((blocksize*blocknumber)-(blocksize-1)))
+ return copytext_char(input,1,((blocksize*blocknumber)-(blocksize-1)))
/proc/getrightblocks(input,blocknumber,blocksize)
if(blocknumber < (length(input)/blocksize))
- return copytext(input,blocksize*blocknumber+1,length(input)+1)
+ return copytext_char(input,blocksize*blocknumber+1,length(input)+1)
/proc/getblock(input, blocknumber, blocksize=DNA_BLOCK_SIZE)
- return copytext(input, blocksize*(blocknumber-1)+1, (blocksize*blocknumber)+1)
+ return copytext_char(input, blocksize*(blocknumber-1)+1, (blocksize*blocknumber)+1)
/proc/setblock(istring, blocknumber, replacement, blocksize=DNA_BLOCK_SIZE)
if(!istring || !blocknumber || !replacement || !blocksize)
diff --git a/code/datums/helper_datums/getrev.dm b/code/datums/helper_datums/getrev.dm
index c9e96d6bc1f..fa2496ee3b1 100644
--- a/code/datums/helper_datums/getrev.dm
+++ b/code/datums/helper_datums/getrev.dm
@@ -44,7 +44,7 @@
for(var/line in testmerge)
var/datum/tgs_revision_information/test_merge/tm = line
var/cm = tm.pull_request_commit
- var/details = ": '" + html_encode(tm.title) + "' by " + html_encode(tm.author) + " at commit " + html_encode(copytext(cm, 1, min(length(cm), 11)))
+ var/details = ": '" + html_encode(tm.title) + "' by " + html_encode(tm.author) + " at commit " + html_encode(copytext_char(cm, 1, 11))
if(details && findtext(details, "\[s\]") && (!usr || !usr.client.holder))
continue
. += "#[tm.number][details]
"
diff --git a/code/datums/holocall.dm b/code/datums/holocall.dm
index 21bf6a293ad..a2bdec433b7 100644
--- a/code/datums/holocall.dm
+++ b/code/datums/holocall.dm
@@ -268,8 +268,8 @@
var/splitpoint = findtext(prepared_line," ")
if(!splitpoint)
continue
- var/command = copytext(prepared_line,1,splitpoint)
- var/value = copytext(prepared_line,splitpoint+1)
+ var/command = copytext(prepared_line, 1, splitpoint)
+ var/value = copytext(prepared_line, splitpoint + length(prepared_line[splitpoint]))
switch(command)
if("DELAY")
var/delay_value = text2num(value)
diff --git a/code/datums/martial/_martial.dm b/code/datums/martial/_martial.dm
index c18f2c8de24..2396a2f8a67 100644
--- a/code/datums/martial/_martial.dm
+++ b/code/datums/martial/_martial.dm
@@ -27,7 +27,7 @@
reset_streak(D)
streak = streak+element
if(length(streak) > max_streak_length)
- streak = copytext(streak,2)
+ streak = copytext(streak, 1 + length(streak[1]))
/datum/martial_art/proc/reset_streak(mob/living/carbon/human/new_target)
current_target = new_target
diff --git a/code/datums/mind.dm b/code/datums/mind.dm
index 54b064f4099..558b23111d5 100644
--- a/code/datums/mind.dm
+++ b/code/datums/mind.dm
@@ -183,9 +183,9 @@
last_death = world.time
/datum/mind/proc/store_memory(new_text)
- var/newlength = length(memory) + length(new_text)
+ var/newlength = length_char(memory) + length_char(new_text)
if (newlength > MAX_MESSAGE_LEN * 100)
- memory = copytext(memory, -newlength-MAX_MESSAGE_LEN * 100)
+ memory = copytext_char(memory, -newlength-MAX_MESSAGE_LEN * 100)
memory += "[new_text]
"
/datum/mind/proc/wipe_memory()
@@ -447,7 +447,7 @@
assigned_role = new_role
else if (href_list["memory_edit"])
- var/new_memo = copytext(sanitize(input("Write new memory", "Memory", memory) as null|message),1,MAX_MESSAGE_LEN)
+ var/new_memo = stripped_multiline_input(usr, "Write new memory", "Memory", memory, MAX_MESSAGE_LEN)
if (isnull(new_memo))
return
memory = new_memo
diff --git a/code/datums/mood_events/generic_negative_events.dm b/code/datums/mood_events/generic_negative_events.dm
index 52de07472a9..b2aa5b95cbd 100644
--- a/code/datums/mood_events/generic_negative_events.dm
+++ b/code/datums/mood_events/generic_negative_events.dm
@@ -176,7 +176,7 @@
/datum/mood_event/notcreepingsevere/add_effects(name)
var/list/unstable = list(name)
for(var/i in 1 to rand(3,5))
- unstable += copytext(name, -1)
+ unstable += copytext_char(name, -1)
var/unhinged = uppertext(unstable.Join(""))//example Tinea Luxor > TINEA LUXORRRR (with randomness in how long that slur is)
description = "THEY NEEEEEEED [unhinged]!!\n"
diff --git a/code/datums/verbs.dm b/code/datums/verbs.dm
index d8d7ee74334..8301c5fe384 100644
--- a/code/datums/verbs.dm
+++ b/code/datums/verbs.dm
@@ -88,8 +88,8 @@
var/list/entry = list()
entry["parent"] = "[type]"
entry["name"] = verbpath.desc
- if (copytext(verbpath.name,1,2) == "@")
- entry["command"] = copytext(verbpath.name,2)
+ if (verbpath.name[1] == "@")
+ entry["command"] = copytext(verbpath.name, length(verbpath.name[1]) + 1)
else
entry["command"] = replacetext(verbpath.name, " ", "-")
diff --git a/code/game/machinery/computer/cloning.dm b/code/game/machinery/computer/cloning.dm
index 835490daab2..a19bc6d3d23 100644
--- a/code/game/machinery/computer/cloning.dm
+++ b/code/game/machinery/computer/cloning.dm
@@ -578,7 +578,7 @@
R.fields["mrace"] = rando_race.type
R.fields["name"] = mob_occupant.real_name
- R.fields["id"] = copytext(md5(mob_occupant.real_name), 2, 6)
+ R.fields["id"] = copytext_char(md5(mob_occupant.real_name), 2, 6)
R.fields["UE"] = dna.unique_enzymes
R.fields["UI"] = dna.uni_identity
R.fields["SE"] = dna.mutation_index
diff --git a/code/game/machinery/computer/dna_console.dm b/code/game/machinery/computer/dna_console.dm
index bdf46bcdbd0..771060f0306 100644
--- a/code/game/machinery/computer/dna_console.dm
+++ b/code/game/machinery/computer/dna_console.dm
@@ -248,13 +248,18 @@
var/max_line_len = 7*DNA_BLOCK_SIZE
if(viable_occupant)
temp_html += "
1
"
- var/len = length(viable_occupant.dna.uni_identity)
- for(var/i=1, i<=len, i++)
- temp_html += "[copytext(viable_occupant.dna.uni_identity,i,i+1)]"
- if ((i % max_line_len) == 0)
+ var/char = ""
+ var/ui_text = viable_occupant.dna.uni_identity
+ var/len_byte = length(ui_text)
+ var/char_it = 0
+ for(var/byte_it = 1, byte_it <= len_byte, byte_it += length(char))
+ char_it++
+ char = ui_text[byte_it]
+ temp_html += "[char]"
+ if((char_it % max_line_len) == 0)
temp_html += ""
- if((i % DNA_BLOCK_SIZE) == 0 && i < len)
- temp_html += "
[(i / DNA_BLOCK_SIZE) + 1]
"
+ if((char_it % DNA_BLOCK_SIZE) == 0 && byte_it < len_byte)
+ temp_html += "
[(char_it / DNA_BLOCK_SIZE) + 1]
"
else
temp_html += "---------"
temp_html += "
Buffer Menu
"
@@ -516,7 +521,7 @@
if(!scrambled)
for(var/block in 1 to A.blocks)
var/whole_sequence = get_valid_gene_string(mutation)
- var/sequence = copytext(whole_sequence, 1+(block-1)*(DNA_SEQUENCE_LENGTH*2),(DNA_SEQUENCE_LENGTH*2*block+1))
+ var/sequence = copytext_char(whole_sequence, 1+(block-1)*(DNA_SEQUENCE_LENGTH*2),(DNA_SEQUENCE_LENGTH*2*block+1))
temp_html += ""
for(var/i in 1 to DNA_SEQUENCE_LENGTH)
var/num = 1+(i-1)*2
@@ -698,7 +703,7 @@
viable_occupant.radiation += (RADIATION_IRRADIATION_MULTIPLIER*radduration*radstrength)/(connected.damage_coeff ** 2) //Read comment in "transferbuffer" section above for explanation
switch(href_list["task"]) //Same thing as there but values are even lower, on best part they are about 0.0*, effectively no damage
if("pulseui")
- var/len = length(viable_occupant.dna.uni_identity)
+ var/len = length_char(viable_occupant.dna.uni_identity)
num = WRAP(num, 1, len+1)
num = randomize_radiation_accuracy(num, radduration + (connected.precision_coeff ** 2), len) //Each manipulator level above 1 makes randomization as accurate as selected time + manipulator lvl^2
//Value is this high for the same reason as with laser - not worth the hassle of upgrading if the bonus is low
@@ -706,12 +711,12 @@
var/subblock = num - block*DNA_BLOCK_SIZE
last_change = "UI #[block]-[subblock]; "
- var/hex = copytext(viable_occupant.dna.uni_identity, num, num+1)
+ var/hex = copytext_char(viable_occupant.dna.uni_identity, num, num+1)
last_change += "[hex]"
hex = scramble(hex, radstrength, radduration)
last_change += "->[hex]"
- viable_occupant.dna.uni_identity = copytext(viable_occupant.dna.uni_identity, 1, num) + hex + copytext(viable_occupant.dna.uni_identity, num+1, 0)
+ viable_occupant.dna.uni_identity = copytext_char(viable_occupant.dna.uni_identity, 1, num) + hex + copytext_char(viable_occupant.dna.uni_identity, num + 1)
viable_occupant.updateappearance(mutations_overlay_update=1)
else
current_screen = "mainmenu"
@@ -823,7 +828,7 @@
var/true_genes = GET_SEQUENCE(current_mutation)
new_gene = true_genes[num]
jokerready = world.time + JOKER_TIMEOUT - (JOKER_UPGRADE * (connected.precision_coeff-1))
- sequence = copytext(sequence, 1, num) + new_gene + copytext(sequence, num+1, length(sequence)+1)
+ sequence = copytext_char(sequence, 1, num) + new_gene + copytext_char(sequence, num + 1)
viable_occupant.dna.mutation_index[path] = sequence
viable_occupant.radiation += RADIATION_STRENGTH_MULTIPLIER/connected.damage_coeff
viable_occupant.domutcheck()
diff --git a/code/game/machinery/computer/prisoner/management.dm b/code/game/machinery/computer/prisoner/management.dm
index 75f21b8169a..a83b3b3161e 100644
--- a/code/game/machinery/computer/prisoner/management.dm
+++ b/code/game/machinery/computer/prisoner/management.dm
@@ -124,7 +124,7 @@
to_chat(usr, "Unauthorized access.")
else if(href_list["warn"])
- var/warning = copytext(sanitize(input(usr,"Message:","Enter your message here!","")),1,MAX_MESSAGE_LEN)
+ var/warning = stripped_input(usr, "Message:", "Enter your message here!", "", MAX_MESSAGE_LEN)
if(!warning)
return
var/obj/item/implant/I = locate(href_list["warn"]) in GLOB.tracked_implants
diff --git a/code/game/machinery/computer/security.dm b/code/game/machinery/computer/security.dm
index aabd5f6f7c2..6f34e0eba1f 100644
--- a/code/game/machinery/computer/security.dm
+++ b/code/game/machinery/computer/security.dm
@@ -608,7 +608,7 @@ What a mess.*/
switch(href_list["field"])
if("name")
if(istype(active1, /datum/data/record) || istype(active2, /datum/data/record))
- var/t1 = copytext(sanitize(input("Please input name:", "Secure. records", active1.fields["name"], null) as text),1,MAX_MESSAGE_LEN)
+ var/t1 = stripped_input(usr, "Please input name:", "Secure. records", active1.fields["name"], MAX_MESSAGE_LEN)
if(!canUseSecurityRecordsConsole(usr, t1, a1))
return
if(istype(active1, /datum/data/record))
diff --git a/code/game/machinery/magnet.dm b/code/game/machinery/magnet.dm
index 1a2553eaeb7..7eda6a94d16 100644
--- a/code/game/machinery/magnet.dm
+++ b/code/game/machinery/magnet.dm
@@ -305,7 +305,7 @@
if(speed <= 0)
speed = 1
if("setpath")
- var/newpath = copytext(sanitize(input(usr, "Please define a new path!",,path) as text|null),1,MAX_MESSAGE_LEN)
+ var/newpath = stripped_input(usr, "Please define a new path!", "New Path", path, MAX_MESSAGE_LEN)
if(newpath && newpath != "")
moving = 0 // stop moving
path = newpath
@@ -366,13 +366,19 @@
// Generates the rpath variable using the path string, think of this as "string2list"
// Doesn't use params2list() because of the akward way it stacks entities
rpath = list() // clear rpath
- var/maximum_character = min( 50, length(path) ) // chooses the maximum length of the iterator. 50 max length
+ var/maximum_characters = 50
+ var/lentext = length(path)
+ var/nextchar = ""
+ var/charcount = 0
- for(var/i=1, i<=maximum_character, i++) // iterates through all characters in path
+ for(var/i = 1, i <= lentext, i += length(nextchar)) // iterates through all characters in path
+ nextchar = path[i] // find next character
- var/nextchar = copytext(path, i, i+1) // find next character
-
- if(!(nextchar in list(";", "&", "*", " "))) // if char is a separator, ignore
- rpath += copytext(path, i, i+1) // else, add to list
+ if(nextchar in list(";", "&", "*", " ")) // if char is a separator, ignore
+ continue
+ rpath += nextchar // else, add to list
// there doesn't HAVE to be separators but it makes paths syntatically visible
+ charcount++
+ if(charcount >= maximum_characters)
+ break
diff --git a/code/game/machinery/navbeacon.dm b/code/game/machinery/navbeacon.dm
index 1e4bcdcbbcd..4cb33e4d1a1 100644
--- a/code/game/machinery/navbeacon.dm
+++ b/code/game/machinery/navbeacon.dm
@@ -65,7 +65,7 @@
var/index = findtext(e, "=") // format is "key=value"
if(index)
var/key = copytext(e, 1, index)
- var/val = copytext(e, index+1)
+ var/val = copytext(e, index + length(e[index]))
codes[key] = val
else
codes[e] = "1"
@@ -189,7 +189,7 @@ Transponder Codes:"}
usr.set_machine(src)
if(href_list["locedit"])
- var/newloc = copytext(sanitize(input("Enter New Location", "Navigation Beacon", location) as text|null),1,MAX_MESSAGE_LEN)
+ var/newloc = stripped_input(usr, "Enter New Location", "Navigation Beacon", location, MAX_MESSAGE_LEN)
if(newloc)
location = newloc
glob_lists_register()
diff --git a/code/game/machinery/newscaster.dm b/code/game/machinery/newscaster.dm
index ab7337e19b0..14b0c46d803 100644
--- a/code/game/machinery/newscaster.dm
+++ b/code/game/machinery/newscaster.dm
@@ -162,7 +162,7 @@ GLOBAL_LIST_EMPTY(allCasters)
NEWSCASTER.update_icon()
/datum/newscaster/feed_network/proc/save_photo(icon/photo)
- var/photo_file = copytext(md5("\icon[photo]"), 1, 6)
+ var/photo_file = copytext_char(md5("\icon[photo]"), 1, 6)
if(!fexists("[GLOB.log_directory]/photos/[photo_file].png"))
//Clean up repeated frames
var/icon/clean = new /icon()
@@ -506,8 +506,6 @@ GLOBAL_LIST_EMPTY(allCasters)
scan_user(usr)
if(href_list["set_channel_name"])
channel_name = stripped_input(usr, "Provide a Feed Channel Name", "Network Channel Handler", "", MAX_NAME_LEN)
- while (findtext(channel_name," ") == 1)
- channel_name = copytext(channel_name,2,length(channel_name)+1)
updateUsrDialog()
else if(href_list["set_channel_lock"])
c_locked = !c_locked
@@ -682,7 +680,7 @@ GLOBAL_LIST_EMPTY(allCasters)
updateUsrDialog()
else if(href_list["new_comment"])
var/datum/newscaster/feed_message/FM = locate(href_list["new_comment"]) in viewing_channel.messages
- var/cominput = copytext(stripped_input(usr, "Write your message:", "New comment", null),1,141)
+ var/cominput = stripped_input(usr, "Write your message:", "New comment", null, 140)
if(cominput)
scan_user(usr)
var/datum/newscaster/feed_comment/FC = new/datum/newscaster/feed_comment
diff --git a/code/game/machinery/requests_console.dm b/code/game/machinery/requests_console.dm
index 69379bd0dc8..3ee4c84c67a 100644
--- a/code/game/machinery/requests_console.dm
+++ b/code/game/machinery/requests_console.dm
@@ -237,10 +237,10 @@ GLOBAL_LIST_EMPTY(req_console_ckey_departments)
usr.set_machine(src)
add_fingerprint(usr)
- if(reject_bad_text(href_list["write"]))
- to_department = ckey(href_list["write"]) //write contains the string of the receiving department's name
+ if(href_list["write"])
+ to_department = ckey(reject_bad_text(href_list["write"])) //write contains the string of the receiving department's name
- var/new_message = (to_department in GLOB.req_console_ckey_departments) && copytext(reject_bad_text(input(usr, "Write your message:", "Awaiting Input", "")),1,MAX_MESSAGE_LEN)
+ var/new_message = (to_department in GLOB.req_console_ckey_departments) && stripped_input(usr, "Write your message:", "Awaiting Input", "", MAX_MESSAGE_LEN)
if(new_message)
to_department = GLOB.req_console_ckey_departments[to_department]
message = new_message
@@ -248,7 +248,7 @@ GLOBAL_LIST_EMPTY(req_console_ckey_departments)
priority = CLAMP(text2num(href_list["priority"]), REQ_NORMAL_MESSAGE_PRIORITY, REQ_EXTREME_MESSAGE_PRIORITY)
if(href_list["writeAnnouncement"])
- var/new_message = copytext(reject_bad_text(input(usr, "Write your message:", "Awaiting Input", "")),1,MAX_MESSAGE_LEN)
+ var/new_message = reject_bad_text(stripped_input(usr, "Write your message:", "Awaiting Input", "", MAX_MESSAGE_LEN))
if(new_message)
message = new_message
priority = CLAMP(text2num(href_list["priority"]) || REQ_NORMAL_MESSAGE_PRIORITY, REQ_NORMAL_MESSAGE_PRIORITY, REQ_EXTREME_MESSAGE_PRIORITY)
@@ -344,9 +344,8 @@ GLOBAL_LIST_EMPTY(req_console_ckey_departments)
updateUsrDialog()
/obj/machinery/requests_console/say_mod(input, message_mode)
- var/ending = copytext(input, length(input) - 2)
- if (ending == "!!!")
- . = "blares"
+ if(spantext_char(input, "!", -3))
+ return "blares"
else
. = ..()
diff --git a/code/game/machinery/status_display.dm b/code/game/machinery/status_display.dm
index def84dbac7c..66bedaa32a2 100644
--- a/code/game/machinery/status_display.dm
+++ b/code/game/machinery/status_display.dm
@@ -58,14 +58,14 @@
/// Call with no arguments to disable.
/obj/machinery/status_display/proc/set_message(m1, m2)
if(m1)
- index1 = (length(m1) > CHARS_PER_LINE)
+ index1 = (length_char(m1) > CHARS_PER_LINE)
message1 = m1
else
message1 = ""
index1 = 0
if(m2)
- index2 = (length(m2) > CHARS_PER_LINE)
+ index2 = (length_char(m2) > CHARS_PER_LINE)
message2 = m2
else
message2 = ""
@@ -80,19 +80,19 @@
var/line1 = message1
if(index1)
- line1 = copytext("[message1]|[message1]", index1, index1+CHARS_PER_LINE)
- var/message1_len = length(message1)
+ line1 = copytext_char("[message1]|[message1]", index1, index1 + CHARS_PER_LINE)
+ var/message1_len = length_char(message1)
index1 += SCROLL_SPEED
- if(index1 > message1_len)
- index1 -= message1_len
+ if(index1 > message1_len + 1)
+ index1 -= (message1_len + 1)
var/line2 = message2
if(index2)
- line2 = copytext("[message2]|[message2]", index2, index2+CHARS_PER_LINE)
- var/message2_len = length(message2)
+ line2 = copytext_char("[message2]|[message2]", index2, index2 + CHARS_PER_LINE)
+ var/message2_len = length_char(message2)
index2 += SCROLL_SPEED
- if(index2 > message2_len)
- index2 -= message2_len
+ if(index2 > message2_len + 1)
+ index2 -= (message2_len + 1)
update_display(line1, line2)
if (!index1 && !index2)
@@ -133,7 +133,7 @@
var/line1 = "-[shuttle.getModeStr()]-"
var/line2 = shuttle.getTimerStr()
- if(length(line2) > CHARS_PER_LINE)
+ if(length_char(line2) > CHARS_PER_LINE)
line2 = "error"
update_display(line1, line2)
else
@@ -245,7 +245,7 @@
else
line1 = "CARGO"
line2 = SSshuttle.supply.getTimerStr()
- if(length(line2) > CHARS_PER_LINE)
+ if(length_char(line2) > CHARS_PER_LINE)
line2 = "Error"
update_display(line1, line2)
diff --git a/code/game/machinery/telecomms/broadcasting.dm b/code/game/machinery/telecomms/broadcasting.dm
index d8321a42435..17a94726560 100644
--- a/code/game/machinery/telecomms/broadcasting.dm
+++ b/code/game/machinery/telecomms/broadcasting.dm
@@ -132,7 +132,7 @@
set waitfor = FALSE
// Perform final composition steps on the message.
- var/message = copytext(data["message"], 1, MAX_BROADCAST_LEN)
+ var/message = copytext_char(data["message"], 1, MAX_BROADCAST_LEN)
if(!message)
return
var/compression = data["compression"]
diff --git a/code/game/machinery/telecomms/machine_interactions.dm b/code/game/machinery/telecomms/machine_interactions.dm
index 1205bc17d70..569b6ef534a 100644
--- a/code/game/machinery/telecomms/machine_interactions.dm
+++ b/code/game/machinery/telecomms/machine_interactions.dm
@@ -179,7 +179,7 @@
if("id")
- var/newid = copytext(reject_bad_text(input(usr, "Specify the new ID for this machine", src, id) as null|text),1,MAX_MESSAGE_LEN)
+ var/newid = reject_bad_text(stripped_input(usr, "Specify the new ID for this machine", src, id, MAX_MESSAGE_LEN))
if(newid && canAccess(usr))
id = newid
temp = "-% New ID assigned: \"[id]\" %-"
diff --git a/code/game/mecha/mecha_topic.dm b/code/game/mecha/mecha_topic.dm
index ac3e281d18c..e4aa420a802 100644
--- a/code/game/mecha/mecha_topic.dm
+++ b/code/game/mecha/mecha_topic.dm
@@ -345,12 +345,10 @@
//Changes the exosuit name.
if(href_list["change_name"])
- var/userinput = input(usr, "Choose a new exosuit name.", "Rename exosuit", "") as null|text
- if(usr != occupant || usr.incapacitated())
+ var/userinput = stripped_input(usr, "Choose a new exosuit name.", "Rename exosuit", "", MAX_NAME_LEN)
+ if(!userinput || usr != occupant || usr.incapacitated())
return
- if(!isnull(userinput))
- var/newname = copytext(sanitize_name(userinput),1,MAX_NAME_LEN)
- name = newname ? newname : initial(name)
+ name = userinput
return
//Toggles ID upload.
diff --git a/code/game/objects/effects/contraband.dm b/code/game/objects/effects/contraband.dm
index 706599a3152..841777c704a 100644
--- a/code/game/objects/effects/contraband.dm
+++ b/code/game/objects/effects/contraband.dm
@@ -130,7 +130,7 @@
if (smooth & SMOOTH_DIAGONAL)
for (var/O in overlays)
var/image/I = O
- if (copytext(I.icon_state, 1, 3) == "d-")
+ if(copytext(I.icon_state, 1, 3) == "d-") //3 == length("d-") + 1
return
var/stuff_on_wall = 0
diff --git a/code/game/objects/items/cards_ids.dm b/code/game/objects/items/cards_ids.dm
index 61615855f67..ccafffc363d 100644
--- a/code/game/objects/items/cards_ids.dm
+++ b/code/game/objects/items/cards_ids.dm
@@ -398,30 +398,18 @@ update_label()
if(user.incapacitated())
return
if(popup_input == "Forge/Reset" && !forged)
- var/input_text = input(user, "What name would you like to put on this card? Leave blank to randomise.", "Agent card name", registered_name ? registered_name : (ishuman(user) ? user.real_name : user.name))as text | null
-
- if (isnull(input_text))
- return
-
- var/target_name = copytext(sanitize(input_text), 1, 26)
- if(!target_name || target_name == "Unknown" || target_name == "floor" || target_name == "wall" || target_name == "r-wall") //Same as mob/dead/new_player/preferences.dm
- if (ishuman(user))
- var/mob/living/carbon/human/human_agent = user
-
- // Invalid/blank names give a randomly generated one.
- if (human_agent.gender == "male")
- registered_name = "[pick(GLOB.first_names_male)] [pick(GLOB.last_names)]"
- else if (human_agent.gender == "female")
- registered_name = "[pick(GLOB.first_names_female)] [pick(GLOB.last_names)]"
- else
- registered_name = "[pick(GLOB.first_names)] [pick(GLOB.last_names)]"
+ var/input_name = stripped_input(user, "What name would you like to put on this card? Leave blank to randomise.", "Agent card name", registered_name ? registered_name : (ishuman(user) ? user.real_name : user.name), MAX_NAME_LEN)
+ input_name = reject_bad_name(input_name)
+ if(!input_name)
+ // Invalid/blank names give a randomly generated one.
+ if(user.gender == MALE)
+ input_name = "[pick(GLOB.first_names_male)] [pick(GLOB.last_names)]"
+ else if(user.gender == FEMALE)
+ input_name = "[pick(GLOB.first_names_female)] [pick(GLOB.last_names)]"
else
- alert ("Invalid name.")
- return
- else
- registered_name = target_name
+ input_name = "[pick(GLOB.first_names)] [pick(GLOB.last_names)]"
- var/target_occupation = copytext(sanitize(input(user, "What occupation would you like to put on this card?\nNote: This will not grant any access levels other than Maintenance.", "Agent card job assignment", assignment ? assignment : "Assistant") as text | null),1,MAX_MESSAGE_LEN)
+ var/target_occupation = stripped_input(user, "What occupation would you like to put on this card?\nNote: This will not grant any access levels other than Maintenance.", "Agent card job assignment", assignment ? assignment : "Assistant", MAX_MESSAGE_LEN)
if(!target_occupation)
registered_name = ""
return
diff --git a/code/game/objects/items/cigs_lighters.dm b/code/game/objects/items/cigs_lighters.dm
index fe86c92e21e..9ee249af734 100644
--- a/code/game/objects/items/cigs_lighters.dm
+++ b/code/game/objects/items/cigs_lighters.dm
@@ -217,7 +217,7 @@ CIGARETTE PACKETS ARE IN FANCY.DM
/obj/item/clothing/mask/cigarette/extinguish()
if(!lit)
return
- name = copytext(name,5,length(name)+1)
+ name = copytext_char(name, 5) //5 == length_char("lit ") + 1
attack_verb = null
hitsound = null
damtype = BRUTE
diff --git a/code/game/objects/items/crayons.dm b/code/game/objects/items/crayons.dm
index 1d19afb9103..5219a3032fd 100644
--- a/code/game/objects/items/crayons.dm
+++ b/code/game/objects/items/crayons.dm
@@ -390,7 +390,7 @@
to_chat(user, "You spray a [temp] on \the [target.name]")
if(length(text_buffer) > 1)
- text_buffer = copytext(text_buffer,2)
+ text_buffer = copytext(text_buffer, length(text_buffer[1]) + 1)
SStgui.update_uis(src)
if(post_noise)
diff --git a/code/game/objects/items/devices/PDA/PDA.dm b/code/game/objects/items/devices/PDA/PDA.dm
index 3b2d22973d0..78d7bd6fd07 100644
--- a/code/game/objects/items/devices/PDA/PDA.dm
+++ b/code/game/objects/items/devices/PDA/PDA.dm
@@ -533,13 +533,13 @@ GLOBAL_LIST_EMPTY(PDAs)
if("Clear")//Clears messages
tnote = null
if("Ringtone")
- var/t = input(U, "Please enter new ringtone", name, ttone) as text|null
+ var/t = stripped_input(U, "Please enter new ringtone", name, ttone, 20)
if(in_range(src, U) && loc == U && t)
if(SEND_SIGNAL(src, COMSIG_PDA_CHANGE_RINGTONE, U, t) & COMPONENT_STOP_RINGTONE_CHANGE)
U << browse(null, "window=pda")
return
else
- ttone = copytext(sanitize(t), 1, 20)
+ ttone = t
else
U << browse(null, "window=pda")
return
diff --git a/code/game/objects/items/devices/paicard.dm b/code/game/objects/items/devices/paicard.dm
index 004810a2a60..b7d71fc006d 100644
--- a/code/game/objects/items/devices/paicard.dm
+++ b/code/game/objects/items/devices/paicard.dm
@@ -109,7 +109,7 @@
to_chat(usr,"You [transmit_holder ? "enable" : "disable"] your pAI's [transmitting ? "outgoing" : "incoming"] radio transmissions!")
to_chat(pai,"Your owner has [transmit_holder ? "enabled" : "disabled"] your [transmitting ? "outgoing" : "incoming"] radio transmissions!")
if(href_list["setlaws"])
- var/newlaws = copytext(sanitize(input("Enter any additional directives you would like your pAI personality to follow. Note that these directives will not override the personality's allegiance to its imprinted master. Conflicting directives will be ignored.", "pAI Directive Configuration", pai.laws.supplied[1]) as message|null),1,MAX_MESSAGE_LEN)
+ var/newlaws = stripped_multiline_input("Enter any additional directives you would like your pAI personality to follow. Note that these directives will not override the personality's allegiance to its imprinted master. Conflicting directives will be ignored.", "pAI Directive Configuration", pai.laws.supplied[1], MAX_MESSAGE_LEN)
if(newlaws && pai)
pai.add_supplied_law(0,newlaws)
if(href_list["toggle_holo"])
diff --git a/code/game/objects/items/devices/scanners.dm b/code/game/objects/items/devices/scanners.dm
index bf9621116bb..e99195e8261 100644
--- a/code/game/objects/items/devices/scanners.dm
+++ b/code/game/objects/items/devices/scanners.dm
@@ -37,7 +37,7 @@ GENE SCANNER
/obj/item/t_scanner/proc/toggle_on()
on = !on
- icon_state = copytext(icon_state, 1, length(icon_state))+"[on]"
+ icon_state = copytext_char(icon_state, 1, -1) + "[on]"
if(on)
START_PROCESSING(SSobj, src)
else
@@ -733,10 +733,10 @@ GENE SCANNER
if(sequence)
var/display
- for(var/i in 0 to length(sequence) / DNA_MUTATION_BLOCKS-1)
+ for(var/i in 0 to length_char(sequence) / DNA_MUTATION_BLOCKS-1)
if(i)
display += "-"
- display += copytext(sequence, 1 + i*DNA_MUTATION_BLOCKS, DNA_MUTATION_BLOCKS*(1+i) + 1)
+ display += copytext_char(sequence, 1 + i*DNA_MUTATION_BLOCKS, DNA_MUTATION_BLOCKS*(1+i) + 1)
to_chat(user, "[display]
")
diff --git a/code/game/objects/items/twohanded.dm b/code/game/objects/items/twohanded.dm
index d3e69d151f2..a3267218453 100644
--- a/code/game/objects/items/twohanded.dm
+++ b/code/game/objects/items/twohanded.dm
@@ -35,9 +35,9 @@
wielded = 0
if(!isnull(force_unwielded))
force = force_unwielded
- var/sf = findtext(name," (Wielded)")
+ var/sf = findtext(name, " (Wielded)", -10)//10 == length(" (Wielded)")
if(sf)
- name = copytext(name,1,sf)
+ name = copytext(name, 1, sf)
else //something wrong
name = "[initial(name)]"
update_icon()
diff --git a/code/game/objects/objs.dm b/code/game/objects/objs.dm
index b70e418a7d5..37cee6addf7 100644
--- a/code/game/objects/objs.dm
+++ b/code/game/objects/objs.dm
@@ -63,8 +63,8 @@
var/flagslist = splittext(set_obj_flags,";")
var/list/string_to_objflag = GLOB.bitfields["obj_flags"]
for (var/flag in flagslist)
- if (findtext(flag,"!",1,2))
- flag = copytext(flag,1-(length(flag))) // Get all but the initial !
+ if(flag[1] == "!")
+ flag = copytext(flag, length(flag[1]) + 1) // Get all but the initial !
obj_flags &= ~string_to_objflag[flag]
else
obj_flags |= string_to_objflag[flag]
diff --git a/code/game/objects/structures/mirror.dm b/code/game/objects/structures/mirror.dm
index 8a74e668b7d..22f3d56c62e 100644
--- a/code/game/objects/structures/mirror.dm
+++ b/code/game/objects/structures/mirror.dm
@@ -136,8 +136,7 @@
switch(choice)
if("name")
- var/newname = copytext(sanitize_name(reject_bad_text(input(H, "Who are we again?", "Name change", H.name) as null|text)),1,MAX_NAME_LEN)
-
+ var/newname = sanitize_name(reject_bad_text(stripped_input(H, "Who are we again?", "Name change", H.name, MAX_NAME_LEN)))
if(!newname)
return
if(!user.canUseTopic(src, BE_CLOSE, FALSE, NO_TK))
diff --git a/code/game/objects/structures/musician.dm b/code/game/objects/structures/musician.dm
index 1d557cffbbc..fa49049e603 100644
--- a/code/game/objects/structures/musician.dm
+++ b/code/game/objects/structures/musician.dm
@@ -112,8 +112,10 @@
var/cur_note = text2ascii(note) - 96
if(cur_note < 1 || cur_note > 7)
continue
- for(var/i=2 to length(note))
- var/ni = copytext(note,i,i+1)
+ var/notelen = length(note)
+ var/ni = ""
+ for(var/i = length(note[1]) + 1, i <= notelen, i += length(ni))
+ ni = note[i]
if(!text2num(ni))
if(ni == "#" || ni == "b" || ni == "n")
cur_acc[cur_note] = ni
@@ -202,9 +204,10 @@
//split into lines
lines = splittext(text, "\n")
if(lines.len)
- if(copytext(lines[1],1,6) == "BPM: ")
- tempo = sanitize_tempo(600 / text2num(copytext(lines[1],6)))
- lines.Cut(1,2)
+ var/bpm_string = "BPM: "
+ if(findtext(lines[1], bpm_string, 1, length(bpm_string) + 1))
+ tempo = sanitize_tempo(600 / text2num(copytext(lines[1], length(bpm_string) + 1)))
+ lines.Cut(1, 2)
else
tempo = sanitize_tempo(5) // default 120 BPM
if(lines.len > MUSIC_MAXLINES)
@@ -212,7 +215,7 @@
lines.Cut(MUSIC_MAXLINES + 1)
var/linenum = 1
for(var/l in lines)
- if(length(l) > MUSIC_MAXLINECHARS)
+ if(length_char(l) > MUSIC_MAXLINECHARS)
to_chat(usr, "Line [linenum] too long!")
lines.Remove(l)
else
@@ -276,8 +279,8 @@
return
if(lines.len > MUSIC_MAXLINES)
return
- if(length(newline) > MUSIC_MAXLINECHARS)
- newline = copytext(newline, 1, MUSIC_MAXLINECHARS)
+ if(length_char(newline) > MUSIC_MAXLINECHARS)
+ newline = copytext_char(newline, 1, MUSIC_MAXLINECHARS)
lines.Add(newline)
else if(href_list["deleteline"])
@@ -288,11 +291,9 @@
else if(href_list["modifyline"])
var/num = round(text2num(href_list["modifyline"]),1)
- var/content = html_encode(input("Enter your line: ", instrumentObj.name, lines[num]) as text|null)
+ var/content = stripped_input(usr, "Enter your line: ", instrumentObj.name, lines[num], MUSIC_MAXLINECHARS)
if(!content || !usr.canUseTopic(instrumentObj, BE_CLOSE, FALSE, NO_TK))
return
- if(length(content) > MUSIC_MAXLINECHARS)
- content = copytext(content, 1, MUSIC_MAXLINECHARS)
if(num > lines.len || num < 1)
return
lines[num] = content
diff --git a/code/game/say.dm b/code/game/say.dm
index 626e7a9627d..81d33a03596 100644
--- a/code/game/say.dm
+++ b/code/game/say.dm
@@ -73,8 +73,8 @@ GLOBAL_LIST_INIT(freqtospan, list(
return ""
/atom/movable/proc/say_mod(input, message_mode)
- var/ending = copytext(input, length(input))
- if(copytext(input, length(input) - 1) == "!!")
+ var/ending = copytext_char(input, -1)
+ if(copytext_char(input, -2) == "!!")
return verb_yell
else if(ending == "?")
return verb_ask
@@ -87,7 +87,7 @@ GLOBAL_LIST_INIT(freqtospan, list(
if(!input)
input = "..."
- if(copytext(input, length(input) - 1) == "!!")
+ if(copytext_char(input, -2) == "!!")
spans |= SPAN_YELL
var/spanned = attach_spans(input, spans)
@@ -121,7 +121,7 @@ GLOBAL_LIST_INIT(freqtospan, list(
var/returntext = GLOB.reverseradiochannels["[freq]"]
if(returntext)
return returntext
- return "[copytext("[freq]", 1, 4)].[copytext("[freq]", 4, 5)]"
+ return "[copytext_char("[freq]", 1, 4)].[copytext_char("[freq]", 4, 5)]"
/proc/attach_spans(input, list/spans)
return "[message_spans_start(spans)][input]"
@@ -134,7 +134,7 @@ GLOBAL_LIST_INIT(freqtospan, list(
return output
/proc/say_test(text)
- var/ending = copytext(text, length(text))
+ var/ending = copytext_char(text, -1)
if (ending == "?")
return "1"
else if (ending == "!")
diff --git a/code/modules/admin/admin_verbs.dm b/code/modules/admin/admin_verbs.dm
index e48ff9a840e..a0043ca2b65 100644
--- a/code/modules/admin/admin_verbs.dm
+++ b/code/modules/admin/admin_verbs.dm
@@ -451,11 +451,9 @@ GLOBAL_PROTECT(admin_verbs_hideable)
mob.name = mob.real_name
mob.mouse_opacity = initial(mob.mouse_opacity)
else
- var/new_key = ckeyEx(input("Enter your desired display name.", "Fake Key", key) as text|null)
+ var/new_key = ckeyEx(stripped_input(usr, "Enter your desired display name.", "Fake Key", key, 26))
if(!new_key)
return
- if(length(new_key) >= 26)
- new_key = copytext(new_key, 1, 26)
holder.fakekey = new_key
createStealthKey()
if(isobserver(mob))
@@ -562,9 +560,9 @@ GLOBAL_PROTECT(admin_verbs_hideable)
set desc = "Gives a spell to a mob."
var/list/spell_list = list()
- var/type_length = length("/obj/effect/proc_holder/spell") + 2
+ var/type_length = length_char("/obj/effect/proc_holder/spell") + 2
for(var/A in GLOB.spells)
- spell_list[copytext("[A]", type_length)] = A
+ spell_list[copytext_char("[A]", type_length)] = A
var/obj/effect/proc_holder/spell/S = input("Choose the spell to give to that guy", "ABRAKADABRA") as null|anything in sortList(spell_list)
if(!S)
return
diff --git a/code/modules/admin/secrets.dm b/code/modules/admin/secrets.dm
index 4ecffc5b233..cab80ed0d96 100644
--- a/code/modules/admin/secrets.dm
+++ b/code/modules/admin/secrets.dm
@@ -340,7 +340,7 @@
if(!SSticker.HasRoundStarted())
alert("The game hasn't started yet!")
return
- var/objective = copytext(sanitize(input("Enter an objective")),1,MAX_MESSAGE_LEN)
+ var/objective = stripped_input(usr, "Enter an objective")
if(!objective)
return
SSblackbox.record_feedback("nested tally", "admin_secrets_fun_used", 1, list("Traitor All", "[objective]"))
diff --git a/code/modules/admin/topic.dm b/code/modules/admin/topic.dm
index 2debe036042..704f720ad9b 100644
--- a/code/modules/admin/topic.dm
+++ b/code/modules/admin/topic.dm
@@ -1727,8 +1727,6 @@
if(!check_rights(R_ADMIN))
return
src.admincaster_feed_channel.channel_name = stripped_input(usr, "Provide a Feed Channel Name.", "Network Channel Handler", "")
- while (findtext(src.admincaster_feed_channel.channel_name," ") == 1)
- src.admincaster_feed_channel.channel_name = copytext(src.admincaster_feed_channel.channel_name,2,length(src.admincaster_feed_channel.channel_name)+1)
src.access_news_network()
else if(href_list["ac_set_channel_lock"])
@@ -1768,9 +1766,7 @@
else if(href_list["ac_set_new_message"])
if(!check_rights(R_ADMIN))
return
- src.admincaster_feed_message.body = adminscrub(input(usr, "Write your Feed story.", "Network Channel Handler", ""))
- while (findtext(src.admincaster_feed_message.returnBody(-1)," ") == 1)
- src.admincaster_feed_message.body = copytext(src.admincaster_feed_message.returnBody(-1),2,length(src.admincaster_feed_message.returnBody(-1))+1)
+ src.admincaster_feed_message.body = adminscrub(stripped_input(usr, "Write your Feed story.", "Network Channel Handler", ""))
src.access_news_network()
else if(href_list["ac_submit_new_message"])
@@ -1829,17 +1825,13 @@
else if(href_list["ac_set_wanted_name"])
if(!check_rights(R_ADMIN))
return
- src.admincaster_wanted_message.criminal = adminscrub(input(usr, "Provide the name of the Wanted person.", "Network Security Handler", ""))
- while(findtext(src.admincaster_wanted_message.criminal," ") == 1)
- src.admincaster_wanted_message.criminal = copytext(admincaster_wanted_message.criminal,2,length(admincaster_wanted_message.criminal)+1)
+ src.admincaster_wanted_message.criminal = adminscrub(stripped_input(usr, "Provide the name of the Wanted person.", "Network Security Handler", ""))
src.access_news_network()
else if(href_list["ac_set_wanted_desc"])
if(!check_rights(R_ADMIN))
return
- src.admincaster_wanted_message.body = adminscrub(input(usr, "Provide the a description of the Wanted person and any other details you deem important.", "Network Security Handler", ""))
- while (findtext(src.admincaster_wanted_message.body," ") == 1)
- src.admincaster_wanted_message.body = copytext(src.admincaster_wanted_message.body,2,length(src.admincaster_wanted_message.body)+1)
+ src.admincaster_wanted_message.body = adminscrub(stripped_input(usr, "Provide the a description of the Wanted person and any other details you deem important.", "Network Security Handler", ""))
src.access_news_network()
else if(href_list["ac_submit_wanted"])
diff --git a/code/modules/admin/verbs/SDQL2/SDQL_2.dm b/code/modules/admin/verbs/SDQL2/SDQL_2.dm
index c987c5ac1f0..2c5283d12b7 100644
--- a/code/modules/admin/verbs/SDQL2/SDQL_2.dm
+++ b/code/modules/admin/verbs/SDQL2/SDQL_2.dm
@@ -906,8 +906,8 @@ GLOBAL_DATUM_INIT(sdql2_vv_statobj, /obj/effect/statclick/SDQL2_VV_all, new(null
else if(ispath(expression[i]))
val = expression[i]
- else if(copytext(expression[i], 1, 2) in list("'", "\""))
- val = copytext(expression[i], 2, length(expression[i]))
+ else if(expression[i][1] in list("'", "\""))
+ val = copytext_char(expression[i], 2, -1)
else if(expression[i] == "\[")
var/list/expressions_list = expression[++i]
@@ -1014,12 +1014,12 @@ GLOBAL_DATUM_INIT(sdql2_vv_statobj, /obj/effect/statclick/SDQL2_VV_all, new(null
if(is_proper_datum(object))
D = object
- if (object == world && (!long || expression[start + 1] == ".") && !(expression[start] in exclude) && copytext(expression[start], 1, 3) != "SS")
+ if (object == world && (!long || expression[start + 1] == ".") && !(expression[start] in exclude) && copytext(expression[start], 1, 3) != "SS") //3 == length("SS") + 1
to_chat(usr, "World variables are not allowed to be accessed. Use global.")
return null
else if(expression [start] == "{" && long)
- if(lowertext(copytext(expression[start + 1], 1, 3)) != "0x")
+ if(lowertext(copytext(expression[start + 1], 1, 3)) != "0x") //3 == length("0x") + 1
to_chat(usr, "Invalid pointer syntax: [expression[start + 1]]")
return null
v = locate("\[[expression[start + 1]]]")
@@ -1061,8 +1061,8 @@ GLOBAL_DATUM_INIT(sdql2_vv_statobj, /obj/effect/statclick/SDQL2_VV_all, new(null
if("CFG")
v = config
else
- if(copytext(expression[start], 1, 3) == "SS") //Subsystem
- var/SSname = copytext(expression[start], 3)
+ if(copytext(expression[start], 1, 3) == "SS") //Subsystem //3 == length("SS") + 1
+ var/SSname = copytext_char(expression[start], 3)
var/SSlength = length(SSname)
var/datum/controller/subsystem/SS
var/SSmatch
@@ -1106,9 +1106,10 @@ GLOBAL_DATUM_INIT(sdql2_vv_statobj, /obj/effect/statclick/SDQL2_VV_all, new(null
var/word = ""
var/list/query_list = list()
var/len = length(query_text)
+ var/char = ""
- for(var/i = 1, i <= len, i++)
- var/char = copytext(query_text, i, i + 1)
+ for(var/i = 1, i <= len, i += length(char))
+ char = query_text[i]
if(char in whitespace)
if(word != "")
@@ -1127,7 +1128,7 @@ GLOBAL_DATUM_INIT(sdql2_vv_statobj, /obj/effect/statclick/SDQL2_VV_all, new(null
query_list += word
word = ""
- var/char2 = copytext(query_text, i + 1, i + 2)
+ var/char2 = query_text[i + length(char)]
if(char2 in multi[char])
query_list += "[char][char2]"
@@ -1143,13 +1144,13 @@ GLOBAL_DATUM_INIT(sdql2_vv_statobj, /obj/effect/statclick/SDQL2_VV_all, new(null
word = "'"
- for(i++, i <= len, i++)
- char = copytext(query_text, i, i + 1)
+ for(i += length(char), i <= len, i += length(char))
+ char = query_text[i]
if(char == "'")
- if(copytext(query_text, i + 1, i + 2) == "'")
+ if(query_text[i + length(char)] == "'")
word += "'"
- i++
+ i += length(query_text[i + length(char)])
else
break
@@ -1171,13 +1172,13 @@ GLOBAL_DATUM_INIT(sdql2_vv_statobj, /obj/effect/statclick/SDQL2_VV_all, new(null
word = "\""
- for(i++, i <= len, i++)
- char = copytext(query_text, i, i + 1)
+ for(i += length(char), i <= len, i += length(char))
+ char = query_text[i]
if(char == "\"")
- if(copytext(query_text, i + 1, i + 2) == "'")
+ if(query_text[i + length(char)] == "'")
word += "\""
- i++
+ i += length(query_text[i + length(char)])
else
break
diff --git a/code/modules/admin/verbs/SDQL2/SDQL_2_parser.dm b/code/modules/admin/verbs/SDQL2/SDQL_2_parser.dm
index 5cbd2dd5571..32f385f8ec0 100644
--- a/code/modules/admin/verbs/SDQL2/SDQL_2_parser.dm
+++ b/code/modules/admin/verbs/SDQL2/SDQL_2_parser.dm
@@ -260,7 +260,7 @@
node += "*"
i++
- else if (copytext(token(i), 1, 2) == "/")
+ else if(token(i)[1] == "/")
i = object_type(i, node)
else
@@ -391,7 +391,7 @@
//object_type:
/datum/SDQL_parser/proc/object_type(i, list/node)
- if (copytext(token(i), 1, 2) != "/")
+ if(token(i)[1] != "/")
return parse_error("Expected type, but it didn't begin with /")
var/path = text2path(token(i))
@@ -430,7 +430,7 @@
//string: ''' ''' | '"' '"'
/datum/SDQL_parser/proc/string(i, list/node)
- if(copytext(token(i), 1, 2) in list("'", "\""))
+ if(token(i)[1] in list("'", "\""))
node += token(i)
else
@@ -441,7 +441,7 @@
//array: '[' expression_list ']'
/datum/SDQL_parser/proc/array(i, list/node)
// Arrays get turned into this: list("[", list(exp_1a = exp_1b, ...), ...), "[" is to mark the next node as an array.
- if(copytext(token(i), 1, 2) != "\[")
+ if(token(i)[1] != "\[")
parse_error("Expected an array but found '[token(i)]'")
return i + 1
@@ -613,7 +613,7 @@
node += "null"
i++
- else if(lowertext(copytext(token(i), 1, 3)) == "0x" && isnum(hex2num(copytext(token(i), 3))))
+ else if(lowertext(copytext(token(i), 1, 3)) == "0x" && isnum(hex2num(copytext(token(i), 3))))//3 == length("0x") + 1
node += hex2num(copytext(token(i), 3))
i++
@@ -621,16 +621,16 @@
node += text2num(token(i))
i++
- else if(copytext(token(i), 1, 2) in list("'", "\""))
+ else if(token(i)[1] in list("'", "\""))
i = string(i, node)
- else if(copytext(token(i), 1, 2) == "\[") // Start a list.
+ else if(token(i)[1] == "\[") // Start a list.
i = array(i, node)
- else if(copytext(token(i), 1, 3) == "@\[")
+ else if(copytext(token(i), 1, 3) == "@\[")//3 == length("@\[") + 1
i = selectors_array(i, node)
- else if(copytext(token(i), 1, 2) == "/")
+ else if(token(i)[1] == "/")
i = object_type(i, node)
else
diff --git a/code/modules/admin/verbs/adminhelp.dm b/code/modules/admin/verbs/adminhelp.dm
index dd152393e92..1bfdcc07ba0 100644
--- a/code/modules/admin/verbs/adminhelp.dm
+++ b/code/modules/admin/verbs/adminhelp.dm
@@ -167,7 +167,7 @@ GLOBAL_DATUM_INIT(ahelp_tickets, /datum/admin_help_tickets, new)
//is_bwoink is TRUE if this ticket was started by an admin PM
/datum/admin_help/New(msg, client/C, is_bwoink)
//clean the input msg
- msg = sanitize(copytext(msg,1,MAX_MESSAGE_LEN))
+ msg = sanitize(copytext_char(msg, 1, MAX_MESSAGE_LEN))
if(!msg || !C || !C.mob)
qdel(src)
return
diff --git a/code/modules/admin/verbs/adminpm.dm b/code/modules/admin/verbs/adminpm.dm
index 970cb596bb7..ec7f2fb07ee 100644
--- a/code/modules/admin/verbs/adminpm.dm
+++ b/code/modules/admin/verbs/adminpm.dm
@@ -40,7 +40,7 @@
return
var/client/C
if(istext(whom))
- if(cmptext(copytext(whom,1,2),"@"))
+ if(whom[1] == "@")
whom = findStealthKey(whom)
C = GLOB.directory[whom]
else if(istype(whom, /client))
@@ -75,7 +75,7 @@
var/client/recipient
var/external = 0
if(istext(whom))
- if(cmptext(copytext(whom,1,2),"@"))
+ if(whom[1] == "@")
whom = findStealthKey(whom)
if(whom == "IRCKEY")
external = 1
@@ -132,7 +132,7 @@
//clean the message if it's not sent by a high-rank admin
if(!check_rights(R_SERVER|R_DEBUG,0)||external)//no sending html to the poor bots
- msg = trim(sanitize(copytext(msg,1,MAX_MESSAGE_LEN)))
+ msg = trim(sanitize(msg), MAX_MESSAGE_LEN)
if(!msg)
return
@@ -293,7 +293,7 @@
if(!stealthkey)
stealthkey = GenTgsStealthKey()
- msg = sanitize(copytext(msg,1,MAX_MESSAGE_LEN))
+ msg = sanitize(copytext_char(msg, 1, MAX_MESSAGE_LEN))
if(!msg)
return "Error: No message"
diff --git a/code/modules/admin/verbs/adminsay.dm b/code/modules/admin/verbs/adminsay.dm
index ee01ba77242..99347010675 100644
--- a/code/modules/admin/verbs/adminsay.dm
+++ b/code/modules/admin/verbs/adminsay.dm
@@ -5,7 +5,7 @@
if(!check_rights(0))
return
- msg = emoji_parse(copytext(sanitize(msg), 1, MAX_MESSAGE_LEN))
+ msg = emoji_parse(copytext_char(sanitize(msg), 1, MAX_MESSAGE_LEN))
if(!msg)
return
diff --git a/code/modules/admin/verbs/deadsay.dm b/code/modules/admin/verbs/deadsay.dm
index 9b609bab9f1..37c09810ea6 100644
--- a/code/modules/admin/verbs/deadsay.dm
+++ b/code/modules/admin/verbs/deadsay.dm
@@ -14,7 +14,7 @@
if (handle_spam_prevention(msg,MUTE_DEADCHAT))
return
- msg = copytext(sanitize(msg), 1, MAX_MESSAGE_LEN)
+ msg = copytext_char(sanitize(msg), 1, MAX_MESSAGE_LEN)
mob.log_talk(msg, LOG_DSAY)
if (!msg)
diff --git a/code/modules/admin/verbs/map_template_loadverb.dm b/code/modules/admin/verbs/map_template_loadverb.dm
index f4638172e76..0e687c8b045 100644
--- a/code/modules/admin/verbs/map_template_loadverb.dm
+++ b/code/modules/admin/verbs/map_template_loadverb.dm
@@ -33,7 +33,7 @@
var/map = input(src, "Choose a Map Template to upload to template storage","Upload Map Template") as null|file
if(!map)
return
- if(copytext("[map]",-4) != ".dmm")
+ if(copytext("[map]", -4) != ".dmm")//4 == length(".dmm")
to_chat(src, "Filename must end in '.dmm': [map]")
return
var/datum/map_template/M
diff --git a/code/modules/admin/verbs/maprotation.dm b/code/modules/admin/verbs/maprotation.dm
index 9e61755e4ae..71fd233fa5a 100644
--- a/code/modules/admin/verbs/maprotation.dm
+++ b/code/modules/admin/verbs/maprotation.dm
@@ -49,7 +49,7 @@
if(isnull(map_file))
return
- if(copytext("[map_file]",-4) != ".dmm")
+ if(copytext("[map_file]", -4) != ".dmm")//4 == length(".dmm")
to_chat(src, "Filename must end in '.dmm': [map_file]")
return
diff --git a/code/modules/admin/verbs/pray.dm b/code/modules/admin/verbs/pray.dm
index c3840b1dad9..2e6c066297a 100644
--- a/code/modules/admin/verbs/pray.dm
+++ b/code/modules/admin/verbs/pray.dm
@@ -6,7 +6,7 @@
to_chat(usr, "Speech is currently admin-disabled.")
return
- msg = copytext(sanitize(msg), 1, MAX_MESSAGE_LEN)
+ msg = copytext_char(sanitize(msg), 1, MAX_MESSAGE_LEN)
if(!msg)
return
log_prayer("[src.key]/([src.name]): [msg]")
@@ -54,21 +54,21 @@
//log_admin("HELP: [key_name(src)]: [msg]")
/proc/CentCom_announce(text , mob/Sender)
- var/msg = copytext(sanitize(text), 1, MAX_MESSAGE_LEN)
+ var/msg = copytext_char(sanitize(text), 1, MAX_MESSAGE_LEN)
msg = "CENTCOM:[ADMIN_FULLMONTY(Sender)] [ADMIN_CENTCOM_REPLY(Sender)]: [msg]"
to_chat(GLOB.admins, msg)
for(var/obj/machinery/computer/communications/C in GLOB.machines)
C.overrideCooldown()
/proc/Syndicate_announce(text , mob/Sender)
- var/msg = copytext(sanitize(text), 1, MAX_MESSAGE_LEN)
+ var/msg = copytext_char(sanitize(text), 1, MAX_MESSAGE_LEN)
msg = "SYNDICATE:[ADMIN_FULLMONTY(Sender)] [ADMIN_SYNDICATE_REPLY(Sender)]: [msg]"
to_chat(GLOB.admins, msg)
for(var/obj/machinery/computer/communications/C in GLOB.machines)
C.overrideCooldown()
/proc/Nuke_request(text , mob/Sender)
- var/msg = copytext(sanitize(text), 1, MAX_MESSAGE_LEN)
+ var/msg = copytext_char(sanitize(text), 1, MAX_MESSAGE_LEN)
msg = "NUKE CODE REQUEST:[ADMIN_FULLMONTY(Sender)] [ADMIN_CENTCOM_REPLY(Sender)] [ADMIN_SET_SD_CODE]: [msg]"
to_chat(GLOB.admins, msg)
for(var/obj/machinery/computer/communications/C in GLOB.machines)
diff --git a/code/modules/admin/view_variables/modify_variables.dm b/code/modules/admin/view_variables/modify_variables.dm
index 79ec9509088..de7d86c5e75 100644
--- a/code/modules/admin/view_variables/modify_variables.dm
+++ b/code/modules/admin/view_variables/modify_variables.dm
@@ -55,9 +55,9 @@ GLOBAL_PROTECT(VVpixelmovement)
// the type with the base type removed from the begaining
var/fancytype = types[D.type]
if (findtext(fancytype, types[type]))
- fancytype = copytext(fancytype, length(types[type])+1)
- var/shorttype = copytext("[D.type]", length("[type]")+1)
- if (length(shorttype) > length(fancytype))
+ fancytype = copytext(fancytype, length(types[type]) + 1)
+ var/shorttype = copytext("[D.type]", length("[type]") + 1)
+ if (length_char(shorttype) > length_char(fancytype))
shorttype = fancytype
if (!length(shorttype))
shorttype = "/"
diff --git a/code/modules/antagonists/_common/antag_datum.dm b/code/modules/antagonists/_common/antag_datum.dm
index fd8ec694ba1..df501de1281 100644
--- a/code/modules/antagonists/_common/antag_datum.dm
+++ b/code/modules/antagonists/_common/antag_datum.dm
@@ -238,7 +238,7 @@ GLOBAL_LIST_EMPTY(antagonists)
return
/datum/antagonist/proc/edit_memory(mob/user)
- var/new_memo = copytext(trim(input(user,"Write new memory", "Memory", antag_memory) as null|message),1,MAX_MESSAGE_LEN)
+ var/new_memo = stripped_multiline_input(user, "Write new memory", "Memory", antag_memory, MAX_MESSAGE_LEN)
if (isnull(new_memo))
return
antag_memory = new_memo
diff --git a/code/modules/antagonists/blob/overmind.dm b/code/modules/antagonists/blob/overmind.dm
index 9f25e7649a7..2e8bd26ad2b 100644
--- a/code/modules/antagonists/blob/overmind.dm
+++ b/code/modules/antagonists/blob/overmind.dm
@@ -222,7 +222,7 @@ GLOBAL_LIST_EMPTY(blob_nodes)
/mob/camera/blob/proc/blob_talk(message)
- message = trim(copytext(sanitize(message), 1, MAX_MESSAGE_LEN))
+ message = trim(copytext_char(sanitize(message), 1, MAX_MESSAGE_LEN))
if (!message)
return
diff --git a/code/modules/antagonists/wizard/wizard.dm b/code/modules/antagonists/wizard/wizard.dm
index c0fb4cde2b6..fdd2d00e2cf 100644
--- a/code/modules/antagonists/wizard/wizard.dm
+++ b/code/modules/antagonists/wizard/wizard.dm
@@ -144,7 +144,7 @@
var/wizard_name_second = pick(GLOB.wizard_second)
var/randomname = "[wizard_name_first] [wizard_name_second]"
var/mob/living/wiz_mob = owner.current
- var/newname = copytext(sanitize_name(reject_bad_text(input(wiz_mob, "You are the [name]. Would you like to change your name to something else?", "Name change", randomname) as null|text)),1,MAX_NAME_LEN)
+ var/newname = sanitize_name(reject_bad_text(stripped_input(wiz_mob, "You are the [name]. Would you like to change your name to something else?", "Name change", randomname, MAX_NAME_LEN)))
if (!newname)
newname = randomname
diff --git a/code/modules/awaymissions/zlevel.dm b/code/modules/awaymissions/zlevel.dm
index a96acb027bb..b384172c513 100644
--- a/code/modules/awaymissions/zlevel.dm
+++ b/code/modules/awaymissions/zlevel.dm
@@ -43,7 +43,7 @@ GLOBAL_LIST_INIT(potentialRandomZlevels, generateMapList(filename = "[global.con
t = trim(t)
if (length(t) == 0)
continue
- else if (copytext(t, 1, 2) == "#")
+ else if (t[1] == "#")
continue
var/pos = findtext(t, " ")
diff --git a/code/modules/client/client_procs.dm b/code/modules/client/client_procs.dm
index 8b1c26e4fc9..04f9e9f4c3c 100644
--- a/code/modules/client/client_procs.dm
+++ b/code/modules/client/client_procs.dm
@@ -438,7 +438,7 @@ GLOBAL_LIST_EMPTY(external_rsc_urls)
winset(src, "[child]", "[entries[child]]")
if (!ispath(child, /datum/verbs/menu))
var/procpath/verbpath = child
- if (copytext(verbpath.name,1,2) != "@")
+ if (verbpath.name[1] != "@")
new child(src)
for (var/thing in prefs.menuoptions)
diff --git a/code/modules/client/preferences_savefile.dm b/code/modules/client/preferences_savefile.dm
index caff3d9e99a..3b8237dde68 100644
--- a/code/modules/client/preferences_savefile.dm
+++ b/code/modules/client/preferences_savefile.dm
@@ -141,7 +141,7 @@ SAVEFILE UPDATING/VERSIONING - 'Simplified', or rather, more coder-friendly ~Car
/datum/preferences/proc/load_path(ckey,filename="preferences.sav")
if(!ckey)
return
- path = "data/player_saves/[copytext(ckey,1,2)]/[ckey]/[filename]"
+ path = "data/player_saves/[ckey[1]]/[ckey]/[filename]"
/datum/preferences/proc/load_preferences()
if(!path)
@@ -416,7 +416,7 @@ SAVEFILE UPDATING/VERSIONING - 'Simplified', or rather, more coder-friendly ~Car
jumpsuit_style = sanitize_inlist(jumpsuit_style, GLOB.jumpsuitlist, initial(jumpsuit_style))
uplink_spawn_loc = sanitize_inlist(uplink_spawn_loc, GLOB.uplink_spawn_loc_list, initial(uplink_spawn_loc))
features["mcolor"] = sanitize_hexcolor(features["mcolor"], 3, 0)
- features["ethcolor"] = copytext(features["ethcolor"],1,7)
+ features["ethcolor"] = copytext_char(features["ethcolor"], 1, 7)
features["tail_lizard"] = sanitize_inlist(features["tail_lizard"], GLOB.tails_list_lizard)
features["tail_human"] = sanitize_inlist(features["tail_human"], GLOB.tails_list_human, "None")
features["snout"] = sanitize_inlist(features["snout"], GLOB.snouts_list)
diff --git a/code/modules/client/verbs/ooc.dm b/code/modules/client/verbs/ooc.dm
index 6646d4cbf5a..f5eb663fb74 100644
--- a/code/modules/client/verbs/ooc.dm
+++ b/code/modules/client/verbs/ooc.dm
@@ -28,7 +28,7 @@ GLOBAL_VAR_INIT(normal_ooc_colour, "#002eb8")
if(QDELETED(src))
return
- msg = copytext(sanitize(msg), 1, MAX_MESSAGE_LEN)
+ msg = copytext_char(sanitize(msg), 1, MAX_MESSAGE_LEN)
var/raw_msg = msg
if(!msg)
@@ -36,7 +36,7 @@ GLOBAL_VAR_INIT(normal_ooc_colour, "#002eb8")
msg = emoji_parse(msg)
- if((copytext(msg, 1, 2) in list(".",";",":","#")) || (findtext(lowertext(copytext(msg, 1, 5)), "say")))
+ if((msg[1] in list(".",";",":","#")) || findtext_char(msg, "say", 1, 5))
if(alert("Your message \"[raw_msg]\" looks like it was meant for in game communication, say it in OOC?", "Meant for OOC?", "No", "Yes") != "Yes")
return
diff --git a/code/modules/clothing/neck/_neck.dm b/code/modules/clothing/neck/_neck.dm
index 211909016ec..01bbfe414d5 100644
--- a/code/modules/clothing/neck/_neck.dm
+++ b/code/modules/clothing/neck/_neck.dm
@@ -181,7 +181,7 @@
return ..()
/obj/item/clothing/neck/petcollar/attack_self(mob/user)
- tagname = copytext(sanitize(input(user, "Would you like to change the name on the tag?", "Name your new pet", "Spot") as null|text),1,MAX_NAME_LEN)
+ tagname = stripped_input(user, "Would you like to change the name on the tag?", "Name your new pet", "Spot", MAX_NAME_LEN)
name = "[initial(name)] - [tagname]"
//////////////
diff --git a/code/modules/emoji/emoji_parse.dm b/code/modules/emoji/emoji_parse.dm
index db46ca09ca8..65e8063ce0c 100644
--- a/code/modules/emoji/emoji_parse.dm
+++ b/code/modules/emoji/emoji_parse.dm
@@ -12,14 +12,14 @@
parsed += copytext(text, pos, search)
if(search)
pos = search
- search = findtext(text, ":", pos+1)
+ search = findtext(text, ":", pos + length(text[pos]))
if(search)
- emoji = lowertext(copytext(text, pos+1, search))
+ emoji = lowertext(copytext(text, pos + length(text[pos]), search))
var/datum/asset/spritesheet/sheet = get_asset_datum(/datum/asset/spritesheet/goonchat)
var/tag = sheet.icon_tag("emoji-[emoji]")
if(tag)
parsed += tag
- pos = search + 1
+ pos = search + length(text[pos])
else
parsed += copytext(text, pos, search)
pos = search
@@ -42,12 +42,12 @@
search = findtext(text, ":", pos)
if(search)
pos = search
- search = findtext(text, ":", pos+1)
+ search = findtext(text, ":", pos + length(text[pos]))
if(search)
- var/word = lowertext(copytext(text, pos+1, search))
+ var/word = lowertext(copytext(text, pos + length(text[pos]), search))
if(word in emojis)
- final += lowertext(copytext(text, pos, search+1))
- pos = search + 1
+ final += lowertext(copytext(text, pos, search + length(text[search])))
+ pos = search + length(text[search])
continue
break
return final
diff --git a/code/modules/error_handler/error_handler.dm b/code/modules/error_handler/error_handler.dm
index 9791f89e14f..5fa58387e9c 100644
--- a/code/modules/error_handler/error_handler.dm
+++ b/code/modules/error_handler/error_handler.dm
@@ -12,14 +12,14 @@ GLOBAL_VAR_INIT(total_runtimes_skipped, 0)
return ..()
//this is snowflake because of a byond bug (ID:2306577), do not attempt to call non-builtin procs in this if
- if(copytext(E.name,1,32) == "Maximum recursion level reached")
+ if(copytext(E.name, 1, 32) == "Maximum recursion level reached")//32 == length() of that string + 1
//log to world while intentionally triggering the byond bug.
log_world("runtime error: [E.name]\n[E.desc]")
//if we got to here without silently ending, the byond bug has been fixed.
log_world("The bug with recursion runtimes has been fixed. Please remove the snowflake check from world/Error in [__FILE__]:[__LINE__]")
return //this will never happen.
- else if(copytext(E.name,1,18) == "Out of resources!")
+ else if(copytext(E.name, 1, 18) == "Out of resources!")//18 == length() of that string + 1
log_world("BYOND out of memory. Restarting")
log_game("BYOND out of memory. Restarting")
TgsEndProcess()
@@ -109,7 +109,7 @@ GLOBAL_VAR_INIT(total_runtimes_skipped, 0)
usrinfo = null
continue // Our usr info is better, replace it
- if(copytext(line, 1, 3) != " ")
+ if(copytext(line, 1, 3) != " ")//3 == length(" ") + 1
desclines += (" " + line) // Pad any unpadded lines, so they look pretty
else
desclines += line
diff --git a/code/modules/goonchat/browserOutput.dm b/code/modules/goonchat/browserOutput.dm
index 21ffdf66624..903a911a21e 100644
--- a/code/modules/goonchat/browserOutput.dm
+++ b/code/modules/goonchat/browserOutput.dm
@@ -66,8 +66,8 @@ GLOBAL_DATUM_INIT(iconCache, /savefile, new("tmp/iconCache.sav")) //Cache of ico
// Arguments are in the form "param[paramname]=thing"
var/list/params = list()
for(var/key in href_list)
- if(length(key) > 7 && findtext(key, "param")) // 7 is the amount of characters in the basic param key template.
- var/param_name = copytext(key, 7, -1)
+ if(length_char(key) > 7 && findtext(key, "param")) // 7 is the amount of characters in the basic param key template.
+ var/param_name = copytext_char(key, 7, -1)
var/item = href_list[key]
params[param_name] = item
diff --git a/code/modules/holiday/holidays.dm b/code/modules/holiday/holidays.dm
index f30e766d7d8..f64c5311fd5 100644
--- a/code/modules/holiday/holidays.dm
+++ b/code/modules/holiday/holidays.dm
@@ -23,8 +23,8 @@
// Returns special prefixes for the station name on certain days. You wind up with names like "Christmas Object Epsilon". See new_station_name()
/datum/holiday/proc/getStationPrefix()
//get the first word of the Holiday and use that
- var/i = findtext(name," ",1,0)
- return copytext(name,1,i)
+ var/i = findtext(name, " ")
+ return copytext(name, 1, i)
// Return 1 if this holidy should be celebrated today
/datum/holiday/proc/shouldCelebrate(dd, mm, yy, ww, ddd)
diff --git a/code/modules/hydroponics/gene_modder.dm b/code/modules/hydroponics/gene_modder.dm
index b61d286aa1e..1e662d28e58 100644
--- a/code/modules/hydroponics/gene_modder.dm
+++ b/code/modules/hydroponics/gene_modder.dm
@@ -407,7 +407,7 @@
/obj/machinery/plantgenes/proc/repaint_seed()
if(!seed)
return
- if(copytext(seed.name, 1, 13) == "experimental")
+ if(copytext(seed.name, 1, 13) == "experimental")//13 == length("experimental") + 1
return // Already modded name and icon
seed.name = "experimental " + seed.name
seed.icon_state = "seed-x"
diff --git a/code/modules/language/codespeak.dm b/code/modules/language/codespeak.dm
index bbad7befb89..12ac08b5d63 100644
--- a/code/modules/language/codespeak.dm
+++ b/code/modules/language/codespeak.dm
@@ -13,13 +13,13 @@
. = ""
var/list/words = list()
- while(length(.) < length(input))
+ while(length_char(.) < length_char(input))
words += generate_code_phrase(return_list=TRUE)
. = jointext(words, ", ")
. = capitalize(.)
- var/input_ending = copytext(input, length(input))
+ var/input_ending = copytext_char(input, -1)
var/static/list/endings
if(!endings)
diff --git a/code/modules/language/language.dm b/code/modules/language/language.dm
index 8b9cc09dffc..bf8087ad73c 100644
--- a/code/modules/language/language.dm
+++ b/code/modules/language/language.dm
@@ -80,11 +80,11 @@
if(lookup)
return lookup
- var/input_size = length(input)
+ var/input_size = length_char(input)
var/scrambled_text = ""
var/capitalize = TRUE
- while(length(scrambled_text) < input_size)
+ while(length_char(scrambled_text) < input_size)
var/next = pick(syllables)
if(capitalize)
next = capitalize(next)
@@ -98,10 +98,10 @@
scrambled_text += " "
scrambled_text = trim(scrambled_text)
- var/ending = copytext(scrambled_text, length(scrambled_text))
+ var/ending = copytext_char(scrambled_text, -1)
if(ending == ".")
- scrambled_text = copytext(scrambled_text,1,length(scrambled_text)-1)
- var/input_ending = copytext(input, input_size)
+ scrambled_text = copytext_char(scrambled_text, 1, -2)
+ var/input_ending = copytext_char(input, -1)
if(input_ending in list("!","?","."))
scrambled_text += input_ending
diff --git a/code/modules/library/lib_machines.dm b/code/modules/library/lib_machines.dm
index bcafa426367..0354b480c6b 100644
--- a/code/modules/library/lib_machines.dm
+++ b/code/modules/library/lib_machines.dm
@@ -377,9 +377,9 @@ GLOBAL_LIST(cachedbooks) // List of our cached book datums
if(checkoutperiod < 1)
checkoutperiod = 1
if(href_list["editbook"])
- buffer_book = copytext(sanitize(input("Enter the book's title:") as text|null),1,MAX_MESSAGE_LEN)
+ buffer_book = stripped_input(usr, "Enter the book's title:")
if(href_list["editmob"])
- buffer_mob = copytext(sanitize(input("Enter the recipient's name:") as text|null),1,MAX_NAME_LEN)
+ buffer_mob = stripped_input(usr, "Enter the recipient's name:", max_length = MAX_NAME_LEN)
if(href_list["checkout"])
var/datum/borrowbook/b = new /datum/borrowbook
b.bookname = sanitize(buffer_book)
@@ -396,7 +396,7 @@ GLOBAL_LIST(cachedbooks) // List of our cached book datums
if(b && istype(b))
inventory.Remove(b)
if(href_list["setauthor"])
- var/newauthor = copytext(sanitize(input("Enter the author's name: ") as text|null),1,MAX_MESSAGE_LEN)
+ var/newauthor = stripped_input(usr, "Enter the author's name: ")
if(newauthor)
scanner.cache.author = newauthor
if(href_list["setcategory"])
diff --git a/code/modules/library/soapstone.dm b/code/modules/library/soapstone.dm
index 3f9f33e2fc0..8c37a8645b7 100644
--- a/code/modules/library/soapstone.dm
+++ b/code/modules/library/soapstone.dm
@@ -149,7 +149,7 @@
/obj/structure/chisel_message/update_icon()
..()
var/hash = md5(hidden_message)
- var/newcolor = copytext(hash, 1, 7)
+ var/newcolor = copytext_char(hash, 1, 7)
add_atom_colour("#[newcolor]", FIXED_COLOUR_PRIORITY)
light_color = "#[newcolor]"
set_light(1)
diff --git a/code/modules/mapping/reader.dm b/code/modules/mapping/reader.dm
index 66b24d4e7fb..86b501c455d 100644
--- a/code/modules/mapping/reader.dm
+++ b/code/modules/mapping/reader.dm
@@ -241,7 +241,8 @@
var/variables_start = findtext(full_def, "{")
var/path_text = trim_text(copytext(full_def, 1, variables_start))
var/atom_def = text2path(path_text) //path definition, e.g /obj/foo/bar
- old_position = dpos + 1
+ if(dpos)
+ old_position = dpos + length(model[dpos])
if(!ispath(atom_def, /atom)) // Skip the item if the path does not exist. Fix your crap, mappers!
if(bad_paths)
@@ -253,7 +254,7 @@
var/list/fields = list()
if(variables_start)//if there's any variable
- full_def = copytext(full_def,variables_start+1,length(full_def))//removing the last '}'
+ full_def = copytext(full_def, variables_start + length(full_def[variables_start]), -length(copytext_char(full_def, -1))) //removing the last '}'
fields = readlist(full_def, ";")
if(fields.len)
if(!trim(fields[fields.len]))
@@ -305,7 +306,7 @@
//The next part of the code assumes there's ALWAYS an /area AND a /turf on a given tile
//first instance the /area and remove it from the members list
index = members.len
- if(members[index] != /area/template_noop)
+ if(members[index] != /area/template_noop)
var/atype = members[index]
world.preloader_setup(members_attributes[index], atype)//preloader for assigning set variables on atom creation
var/atom/instance = areaCache[atype]
@@ -423,12 +424,13 @@
var/trim_left = trim_text(copytext(text,old_position,(equal_position ? equal_position : position)))
var/left_constant = delimiter == ";" ? trim_left : parse_constant(trim_left)
- old_position = position + 1
+ if(position)
+ old_position = position + length(text[position])
if(equal_position && !isnum(left_constant))
// Associative var, so do the association.
// Note that numbers cannot be keys - the RHS is dropped if so.
- var/trim_right = trim_text(copytext(text,equal_position+1,position))
+ var/trim_right = trim_text(copytext(text, equal_position + length(text[equal_position]), position))
var/right_constant = parse_constant(trim_right)
.[left_constant] = right_constant
@@ -442,12 +444,12 @@
return num
// string
- if(findtext(text,"\"",1,2))
- return copytext(text,2,findtext(text,"\"",3,0))
+ if(text[1] == "\"")
+ return copytext(text, length(text[1]) + 1, findtext(text, "\"", length(text[1]) + 1))
// list
- if(copytext(text,1,6) == "list(")
- return readlist(copytext(text,6,length(text)))
+ if(copytext(text, 1, 6) == "list(")//6 == length("list(") + 1
+ return readlist(copytext(text, 6, -1))
// typepath
var/path = text2path(text)
@@ -455,8 +457,8 @@
return path
// file
- if(copytext(text,1,2) == "'")
- return file(copytext(text,2,length(text)))
+ if(text[1] == "'")
+ return file(copytext_char(text, 2, -1))
// null
if(text == "null")
diff --git a/code/modules/mapping/verify.dm b/code/modules/mapping/verify.dm
index a9834e37098..1f071aaec72 100644
--- a/code/modules/mapping/verify.dm
+++ b/code/modules/mapping/verify.dm
@@ -60,8 +60,9 @@
// build_cache will check bad paths for us
var/list/modelCache = build_cache(TRUE, report.bad_paths)
+ var/static/regex/area_or_turf = regex(@"/(turf|area)/")
for(var/path in report.bad_paths)
- if(copytext(path, 1, 7) == "/turf/" || copytext(path, 1, 7) == "/area/")
+ if(area_or_turf.Find("[path]", 1, 1))
report.loadable = FALSE
// check for tiles with the wrong number of turfs or areas
diff --git a/code/modules/mining/abandoned_crates.dm b/code/modules/mining/abandoned_crates.dm
index 59f2e9daba4..64151c75585 100644
--- a/code/modules/mining/abandoned_crates.dm
+++ b/code/modules/mining/abandoned_crates.dm
@@ -29,14 +29,17 @@
var/input = input(usr, "Enter [codelen] digits. All digits must be unique.", "Deca-Code Lock", "") as text|null
if(user.canUseTopic(src, BE_CLOSE))
var/list/sanitised = list()
- var/sanitycheck = 1
- for(var/i=1,i<=length(input),i++) //put the guess into a list
- sanitised += text2num(copytext(input,i,i+1))
- for(var/i=1,i<=(length(input)-1),i++) //compare each digit in the guess to all those following it
- for(var/j=(i+1),j<=length(input),j++)
+ var/sanitycheck = TRUE
+ var/char = ""
+ var/length_input = length(input)
+ for(var/i = 1, i <= length_input, i += length(char)) //put the guess into a list
+ char = input[i]
+ sanitised += text2num(char)
+ for(var/i = 1, i <= length(sanitised) - 1, i++) //compare each digit in the guess to all those following it
+ for(var/j = i + 1, j <= length(sanitised), j++)
if(sanitised[i] == sanitised[j])
- sanitycheck = null //if a digit is repeated, reject the input
- if (input == code)
+ sanitycheck = FALSE //if a digit is repeated, reject the input
+ if(input == code)
to_chat(user, "The crate unlocks!")
locked = FALSE
cut_overlays()
@@ -44,7 +47,7 @@
tamperproof = 0 // set explosion chance to zero, so we dont accidently hit it with a multitool and instantly die
if(!spawned_loot)
spawn_loot()
- else if (input == null || sanitycheck == null || length(input) != codelen)
+ else if(!input || !sanitycheck || length(sanitised) != codelen)
to_chat(user, "You leave the crate alone.")
else
to_chat(user, "A red light flashes.")
@@ -69,20 +72,27 @@
else
to_chat(user, "* Anti-Tamper Bomb will activate after [attempts] failed access attempts.")
if(lastattempt != null)
- var/list/guess = list()
- var/list/answer = list()
- var/bulls = 0
- var/cows = 0
- for(var/i=1,i<=length(lastattempt),i++)
- guess += text2num(copytext(lastattempt,i,i+1))
- for(var/i=1,i<=length(lastattempt),i++)
- answer += text2num(copytext(code,i,i+1))
- for(var/i = 1, i < codelen + 1, i++) // Go through list and count matches
- if( answer.Find(guess[i],1,codelen+1))
- ++cows
- if( answer[i] == guess[i])
+ var/bulls = 0 //right position, right number
+ var/cows = 0 //wrong position but in the puzzle
+
+ var/lastattempt_char = ""
+ var/length_lastattempt = length(lastattempt)
+ var/lastattempt_it = 1
+
+ var/code_char = ""
+ var/length_code = length(code)
+ var/code_it = 1
+
+ while(lastattempt_it <= length_lastattempt && code_it <= length_code) // Go through list and count matches
+ lastattempt_char = lastattempt[lastattempt_it]
+ code_char = code[code_it]
+ if(lastattempt_char == code_char)
++bulls
- --cows
+ else if(findtext(code, lastattempt_char))
+ ++cows
+
+ lastattempt_it += length(lastattempt_char)
+ code_it += length(code_char)
to_chat(user, "Last code attempt, [lastattempt], had [bulls] correct digits at correct positions and [cows] correct digits at incorrect positions.")
return
diff --git a/code/modules/mining/machine_silo.dm b/code/modules/mining/machine_silo.dm
index 8bea7b76099..94912dfc554 100644
--- a/code/modules/mining/machine_silo.dm
+++ b/code/modules/mining/machine_silo.dm
@@ -235,5 +235,5 @@ GLOBAL_LIST_EMPTY(silo_access_logs)
var/val = round(materials[key]) / MINERAL_MATERIAL_AMOUNT
msg += sep
sep = ", "
- msg += "[amount < 0 ? "-" : "+"][val] [copytext(key, 2)]"
+ msg += "[amount < 0 ? "-" : "+"][val] [copytext(key, length(key[1]) + 1)]"
formatted = msg.Join()
diff --git a/code/modules/mob/dead/observer/observer.dm b/code/modules/mob/dead/observer/observer.dm
index 6d3db2d2838..58f110428e6 100644
--- a/code/modules/mob/dead/observer/observer.dm
+++ b/code/modules/mob/dead/observer/observer.dm
@@ -230,14 +230,16 @@ GLOBAL_VAR_INIT(observer_default_invisibility, INVISIBILITY_OBSERVER)
var/b_val
var/g_val
var/color_format = length(input_color)
+ if(color_format != length_char(input_color))
+ return 0
if(color_format == 3)
- r_val = hex2num(copytext(input_color, 1, 2))*16
- g_val = hex2num(copytext(input_color, 2, 3))*16
- b_val = hex2num(copytext(input_color, 3, 0))*16
+ r_val = hex2num(copytext(input_color, 1, 2)) * 16
+ g_val = hex2num(copytext(input_color, 2, 3)) * 16
+ b_val = hex2num(copytext(input_color, 3, 4)) * 16
else if(color_format == 6)
r_val = hex2num(copytext(input_color, 1, 3))
g_val = hex2num(copytext(input_color, 3, 5))
- b_val = hex2num(copytext(input_color, 5, 0))
+ b_val = hex2num(copytext(input_color, 5, 7))
else
return 0 //If the color format is not 3 or 6, you're using an unexpected way to represent a color.
@@ -251,7 +253,7 @@ GLOBAL_VAR_INIT(observer_default_invisibility, INVISIBILITY_OBSERVER)
if(b_val > 255)
b_val = 255
- return num2hex(r_val, 2) + num2hex(g_val, 2) + num2hex(b_val, 2)
+ return copytext(rgb(r_val, g_val, b_val), 2)
/*
Transfer_mind is there to check if mob is being deleted/not going to have a body.
@@ -260,7 +262,7 @@ Works together with spawning an observer, noted above.
/mob/proc/ghostize(can_reenter_corpse = TRUE)
if(key)
- if(!cmptext(copytext(key,1,2),"@")) // Skip aghosts.
+ if(key[1] != "@") // Skip aghosts.
stop_sound_channel(CHANNEL_HEARTBEAT) //Stop heartbeat sounds because You Are A Ghost Now
var/mob/dead/observer/ghost = new(src) // Transfer safety to observer spawning proc.
SStgui.on_transfer(src, ghost) // Transfer NanoUIs.
@@ -331,7 +333,7 @@ This is the proc mobs get to turn into a ghost. Forked from ghostize due to comp
if(!can_reenter_corpse)
to_chat(src, "You cannot re-enter your body.")
return
- if(mind.current.key && copytext(mind.current.key,1,2)!="@") //makes sure we don't accidentally kick any clients
+ if(mind.current.key && mind.current.key[1] != "@") //makes sure we don't accidentally kick any clients
to_chat(usr, "Another consciousness is in your body...It is resisting you.")
return
client.change_view(CONFIG_GET(string/default_view))
diff --git a/code/modules/mob/dead/observer/say.dm b/code/modules/mob/dead/observer/say.dm
index 633b0d6cb16..159772e037d 100644
--- a/code/modules/mob/dead/observer/say.dm
+++ b/code/modules/mob/dead/observer/say.dm
@@ -1,18 +1,17 @@
/mob/dead/observer/check_emote(message, forced)
if(message == "*spin" || message == "*flip")
- emote(copytext(message, 2), intentional = !forced)
- return 1
+ emote(copytext(message, length(message[1]) + 1), intentional = !forced)
+ return TRUE
/mob/dead/observer/say(message, bubble_type, list/spans = list(), sanitize = TRUE, datum/language/language = null, ignore_spam = FALSE, forced = null)
- message = trim(copytext(sanitize(message), 1, MAX_MESSAGE_LEN))
+ message = trim(copytext_char(sanitize(message), 1, MAX_MESSAGE_LEN))
if (!message)
return
var/message_mode = get_message_mode(message)
if(client && (message_mode == MODE_ADMIN || message_mode == MODE_DEADMIN))
- message = copytext(message, 3)
- if(findtext(message, " ", 1, 2))
- message = copytext(message, 2)
+ message = copytext_char(message, 3)
+ message = trim_left(message)
if(message_mode == MODE_ADMIN)
client.cmd_admin_say(message)
diff --git a/code/modules/mob/emote.dm b/code/modules/mob/emote.dm
index 7577bcca357..c0d8c192382 100644
--- a/code/modules/mob/emote.dm
+++ b/code/modules/mob/emote.dm
@@ -4,7 +4,7 @@
var/param = message
var/custom_param = findchar(act, " ")
if(custom_param)
- param = copytext(act, custom_param + 1, length(act) + 1)
+ param = copytext(act, custom_param + length(act[custom_param]))
act = copytext(act, 1, custom_param)
var/list/key_emotes = GLOB.emote_list[act]
diff --git a/code/modules/mob/living/blood.dm b/code/modules/mob/living/blood.dm
index d27db8155f9..37b1283bb99 100644
--- a/code/modules/mob/living/blood.dm
+++ b/code/modules/mob/living/blood.dm
@@ -178,7 +178,7 @@
var/datum/disease/D = thing
blood_data["viruses"] += D.Copy()
- blood_data["blood_DNA"] = copytext(dna.unique_enzymes,1,0)
+ blood_data["blood_DNA"] = dna.unique_enzymes
if(disease_resistances && disease_resistances.len)
blood_data["resistances"] = disease_resistances.Copy()
var/list/temp_chem = list()
@@ -196,7 +196,7 @@
if(!suiciding)
blood_data["cloneable"] = 1
- blood_data["blood_type"] = copytext(dna.blood_type,1,0)
+ blood_data["blood_type"] = dna.blood_type
blood_data["gender"] = gender
blood_data["real_name"] = real_name
blood_data["features"] = dna.features
diff --git a/code/modules/mob/living/carbon/human/say.dm b/code/modules/mob/living/carbon/human/say.dm
index 107c157ddd0..4c2b8d092d7 100644
--- a/code/modules/mob/living/carbon/human/say.dm
+++ b/code/modules/mob/living/carbon/human/say.dm
@@ -82,30 +82,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/carbon/human/species_types/ethereal.dm b/code/modules/mob/living/carbon/human/species_types/ethereal.dm
index a7376302ed8..f8f8f2ab8b1 100644
--- a/code/modules/mob/living/carbon/human/species_types/ethereal.dm
+++ b/code/modules/mob/living/carbon/human/species_types/ethereal.dm
@@ -69,7 +69,7 @@
if(!emageffect)
current_color = rgb(r2 + ((r1-r2)*healthpercent), g2 + ((g1-g2)*healthpercent), b2 + ((b1-b2)*healthpercent))
H.set_light(1 + (2 * healthpercent), 1 + (1 * healthpercent), current_color)
- fixed_mut_color = copytext(current_color, 2)
+ fixed_mut_color = copytext_char(current_color, 2)
else
H.set_light(0)
fixed_mut_color = rgb(128,128,128)
diff --git a/code/modules/mob/living/emote.dm b/code/modules/mob/living/emote.dm
index 8639547ec3d..9daaeee352e 100644
--- a/code/modules/mob/living/emote.dm
+++ b/code/modules/mob/living/emote.dm
@@ -411,17 +411,11 @@
. = ..() && intentional
/datum/emote/living/custom/proc/check_invalid(mob/user, input)
- . = TRUE
- if(copytext(input,1,5) == "says")
+ var/static/regex/stop_bad_mime = regex(@"says|exclaims|yells|asks")
+ if(stop_bad_mime.Find(input, 1, 1))
to_chat(user, "Invalid emote.")
- else if(copytext(input,1,9) == "exclaims")
- to_chat(user, "Invalid emote.")
- else if(copytext(input,1,6) == "yells")
- to_chat(user, "Invalid emote.")
- else if(copytext(input,1,5) == "asks")
- to_chat(user, "Invalid emote.")
- else
- . = FALSE
+ return TRUE
+ return FALSE
/datum/emote/living/custom/run_emote(mob/user, params, type_override = null, intentional = FALSE)
if(!can_run_emote(user, TRUE, intentional))
diff --git a/code/modules/mob/living/say.dm b/code/modules/mob/living/say.dm
index 39b0feea4c7..cd169a000a8 100644
--- a/code/modules/mob/living/say.dm
+++ b/code/modules/mob/living/say.dm
@@ -94,7 +94,7 @@ GLOBAL_LIST_INIT(department_radio_keys, list(
ic_blocked = TRUE
if(sanitize)
- message = trim(copytext(sanitize(message), 1, MAX_MESSAGE_LEN))
+ message = trim(copytext_char(sanitize(message), 1, MAX_MESSAGE_LEN))
if(!message || message == "")
return
@@ -110,12 +110,10 @@ GLOBAL_LIST_INIT(department_radio_keys, list(
var/in_critical = InCritical()
if(one_character_prefix[message_mode])
- message = copytext(message, 2)
+ message = copytext_char(message, 2)
else if(message_mode || saymode)
- message = copytext(message, 3)
- if(findtext(message, " ", 1, 2))
- message = copytext(message, 2)
-
+ message = copytext_char(message, 3)
+ message = trim_left(message)
if(message_mode == MODE_ADMIN)
if(client)
client.cmd_admin_say(message)
@@ -146,11 +144,10 @@ GLOBAL_LIST_INIT(department_radio_keys, list(
// No, you cannot speak in xenocommon just because you know the key
if(can_speak_language(message_language))
language = message_language
- message = copytext(message, 3)
+ message = copytext_char(message, 3)
// Trim the space if they said ",0 I LOVE LANGUAGES"
- if(findtext(message, " ", 1, 2))
- message = copytext(message, 2)
+ message = trim_left(message)
if(!language)
language = get_selected_language()
@@ -178,8 +175,8 @@ GLOBAL_LIST_INIT(department_radio_keys, list(
if(fullcrit)
var/health_diff = round(-HEALTH_THRESHOLD_DEAD + health)
// If we cut our message short, abruptly end it with a-..
- var/message_len = length(message)
- message = copytext(message, 1, health_diff) + "[message_len > health_diff ? "-.." : "..."]"
+ var/message_len = length_char(message)
+ message = copytext_char(message, 1, health_diff) + "[message_len > health_diff ? "-.." : "..."]"
message = Ellipsis(message, 10, 1)
last_words = message
message_mode = MODE_WHISPER_CRIT
@@ -321,13 +318,13 @@ GLOBAL_LIST_INIT(department_radio_keys, list(
return 1
/mob/living/proc/get_key(message)
- var/key = copytext(message, 1, 2)
+ var/key = message[1]
if(key in GLOB.department_radio_prefixes)
- return lowertext(copytext(message, 2, 3))
+ return lowertext(message[1 + length(key)])
/mob/living/proc/get_message_language(message)
- if(copytext(message, 1, 2) == ",")
- var/key = copytext(message, 2, 3)
+ if(message[1] == ",")
+ var/key = message[1 + length(message[1])]
for(var/ld in GLOB.all_languages)
var/datum/language/LD = ld
if(initial(LD.key) == key)
diff --git a/code/modules/mob/living/silicon/ai/say.dm b/code/modules/mob/living/silicon/ai/say.dm
index e2bdea92c5d..b36036892d2 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 2c473be7495..1b95b60061e 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 d8ad27592f0..b02b84adc1e 100644
--- a/code/modules/mob/living/simple_animal/parrot.dm
+++ b/code/modules/mob/living/simple_animal/parrot.dm
@@ -213,8 +213,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"])
@@ -422,8 +422,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]"
@@ -431,8 +431,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/mob/mob.dm b/code/modules/mob/mob.dm
index 3a7fc256fba..90f49faa0c5 100644
--- a/code/modules/mob/mob.dm
+++ b/code/modules/mob/mob.dm
@@ -138,7 +138,7 @@
if(!client)
return
- msg = copytext(msg, 1, MAX_MESSAGE_LEN)
+ msg = copytext_char(msg, 1, MAX_MESSAGE_LEN)
if(type)
if(type & MSG_VISUAL && eye_blind )//Vision related
@@ -527,7 +527,7 @@
if (world.time < memory_throttle_time)
return
memory_throttle_time = world.time + 5 SECONDS
- msg = copytext(msg, 1, MAX_MESSAGE_LEN)
+ msg = copytext_char(msg, 1, MAX_MESSAGE_LEN)
msg = sanitize(msg)
mind.store_memory(msg)
diff --git a/code/modules/mob/mob_helpers.dm b/code/modules/mob/mob_helpers.dm
index 19b410b8d55..6f7cf5c4f06 100644
--- a/code/modules/mob/mob_helpers.dm
+++ b/code/modules/mob/mob_helpers.dm
@@ -51,134 +51,127 @@
/**
* Convert random parts of a passed in message to stars
*
- * * n - the string to convert
- * * pr - probability any character gets changed
+ * * phrase - the string to convert
+ * * probability - probability any character gets changed
*
* This proc is dangerously laggy, avoid it or die
*/
-/proc/stars(n, pr)
- n = html_encode(n)
- if (pr == null)
- pr = 25
- if (pr <= 0)
- return null
- else
- if (pr >= 100)
- return n
- var/te = n
- var/t = ""
- n = length(n)
-
- for(var/p = 1 to min(n,MAX_BROADCAST_LEN))
- if ((copytext(te, p, p + 1) == " " || prob(pr)))
- t = text("[][]", t, copytext(te, p, p + 1))
+/proc/stars(phrase, probability = 25)
+ if(probability <= 0)
+ return phrase
+ phrase = html_decode(phrase)
+ var/leng = length(phrase)
+ . = ""
+ var/char = ""
+ for(var/i = 1, i <= leng, i += length(char))
+ char = phrase[i]
+ if(char == " " || !prob(probability))
+ . += char
else
- t = text("[]*", t)
- if(n > MAX_BROADCAST_LEN)
- t += "..." //signals missing text
- return sanitize(t)
+ . += "*"
+ return sanitize(.)
+
/**
* Makes you speak like you're drunk
*/
-/proc/slur(n)
- var/phrase = html_decode(n)
+/proc/slur(phrase)
+ phrase = html_decode(phrase)
var/leng = length(phrase)
- var/counter=length(phrase)
- var/newphrase=""
- var/newletter=""
- while(counter>=1)
- newletter=copytext(phrase,(leng-counter)+1,(leng-counter)+2)
- if(rand(1,3)==3)
- if(lowertext(newletter)=="o")
- newletter="u"
- if(lowertext(newletter)=="s")
- newletter="ch"
- if(lowertext(newletter)=="a")
- newletter="ah"
- if(lowertext(newletter)=="u")
- newletter="oo"
- if(lowertext(newletter)=="c")
- newletter="k"
- if(rand(1,20)==20)
- if(newletter==" ")
- newletter="...huuuhhh..."
- if(newletter==".")
- newletter=" *BURP*."
- switch(rand(1,20))
+ . = ""
+ var/newletter = ""
+ var/rawchar = ""
+ for(var/i = 1, i <= leng, i += length(rawchar))
+ rawchar = newletter = phrase[i]
+ if(rand(1, 3) == 3)
+ var/lowerletter = lowertext(newletter)
+ if(lowerletter == "o")
+ newletter = "u"
+ else if(lowerletter == "s")
+ newletter = "ch"
+ else if(lowerletter == "a")
+ newletter = "ah"
+ else if(lowerletter == "u")
+ newletter = "oo"
+ else if(lowerletter == "c")
+ newletter = "k"
+ if(rand(1, 20) == 20)
+ if(newletter == " ")
+ newletter = "...huuuhhh..."
+ else if(newletter == ".")
+ newletter = " *BURP*."
+ switch(rand(1, 20))
if(1)
- newletter+="'"
+ newletter += "'"
if(10)
- newletter+="[newletter]"
+ newletter += "[newletter]"
if(20)
- newletter+="[newletter][newletter]"
- newphrase+="[newletter]";counter-=1
- return newphrase
+ newletter += "[newletter][newletter]"
+ . += "[newletter]"
+ return sanitize(.)
/// Makes you talk like you got cult stunned, which is slurring but with some dark messages
-/proc/cultslur(n) // Inflicted on victims of a stun talisman
- var/phrase = html_decode(n)
+/proc/cultslur(phrase) // Inflicted on victims of a stun talisman
+ phrase = html_decode(phrase)
var/leng = length(phrase)
- var/counter=length(phrase)
- var/newphrase=""
- var/newletter=""
- while(counter>=1)
- newletter=copytext(phrase,(leng-counter)+1,(leng-counter)+2)
- if(rand(1,2)==2)
- if(lowertext(newletter)=="o")
- newletter="u"
- if(lowertext(newletter)=="t")
- newletter="ch"
- if(lowertext(newletter)=="a")
- newletter="ah"
- if(lowertext(newletter)=="u")
- newletter="oo"
- if(lowertext(newletter)=="c")
- newletter=" NAR "
- if(lowertext(newletter)=="s")
- newletter=" SIE "
- if(rand(1,4)==4)
- if(newletter==" ")
- newletter=" no hope... "
- if(newletter=="H")
- newletter=" IT COMES... "
+ . = ""
+ var/newletter = ""
+ var/rawchar = ""
+ for(var/i = 1, i <= leng, i += length(rawchar))
+ rawchar = newletter = phrase[i]
+ if(rand(1, 2) == 2)
+ var/lowerletter = lowertext(newletter)
+ if(lowerletter == "o")
+ newletter = "u"
+ else if(lowerletter == "t")
+ newletter = "ch"
+ else if(lowerletter == "a")
+ newletter = "ah"
+ else if(lowerletter == "u")
+ newletter = "oo"
+ else if(lowerletter == "c")
+ newletter = " NAR "
+ else if(lowerletter == "s")
+ newletter = " SIE "
+ if(rand(1, 4) == 4)
+ if(newletter == " ")
+ newletter = " no hope... "
+ else if(newletter == "H")
+ newletter = " IT COMES... "
- switch(rand(1,15))
+ switch(rand(1, 15))
if(1)
- newletter="'"
+ newletter = "'"
if(2)
- newletter+="agn"
+ newletter += "agn"
if(3)
- newletter="fth"
+ newletter = "fth"
if(4)
- newletter="nglu"
+ newletter = "nglu"
if(5)
- newletter="glor"
- newphrase+="[newletter]";counter-=1
- return newphrase
+ newletter = "glor"
+ . += newletter
+ return sanitize(.)
///Adds stuttering to the message passed in
-/proc/stutter(n)
- var/te = html_decode(n)
- var/t = ""//placed before the message. Not really sure what it's for.
- n = length(n)//length of the entire word
- var/p = null
- p = 1//1 is the start of any word
- while(p <= n)//while P, which starts at 1 is less or equal to N which is the length.
- var/n_letter = copytext(te, p, p + 1)//copies text from a certain distance. In this case, only one letter at a time.
- if (prob(80) && (ckey(n_letter) in list("b","c","d","f","g","h","j","k","l","m","n","p","q","r","s","t","v","w","x","y","z")))
- if (prob(10))
- n_letter = text("[n_letter]-[n_letter]-[n_letter]-[n_letter]")//replaces the current letter with this instead.
+/proc/stutter(phrase)
+ phrase = html_decode(phrase)
+ var/leng = length(phrase)
+ . = ""
+ var/newletter = ""
+ var/rawchar
+ for(var/i = 1, i <= leng, i += length(rawchar))
+ rawchar = newletter = phrase[i]
+ if(prob(80) && !(lowertext(newletter) in list("a", "e", "i", "o", "u", " ")))
+ if(prob(10))
+ newletter = "[newletter]-[newletter]-[newletter]-[newletter]"
+ else if(prob(20))
+ newletter = "[newletter]-[newletter]-[newletter]"
+ else if (prob(5))
+ newletter = ""
else
- if (prob(20))
- n_letter = text("[n_letter]-[n_letter]-[n_letter]")
- else
- if (prob(5))
- n_letter = null
- else
- n_letter = text("[n_letter]-[n_letter]")
- t = text("[t][n_letter]")//since the above is ran through for each letter, the text just adds up back to the original word.
- p++//for each letter p is increased to find where the next letter will be.
- return copytext(sanitize(t),1,MAX_MESSAGE_LEN)
+ newletter = "[newletter]-[newletter]"
+ . += newletter
+ return sanitize(.)
///Convert a message to derpy speak
/proc/derpspeech(message, stuttering)
@@ -204,48 +197,20 @@
* text is the inputted message, replace_characters will cause original letters to be replaced and chance are the odds that a character gets modified.
*/
/proc/Gibberish(text, replace_characters = FALSE, chance = 50)
+ text = html_decode(text)
. = ""
- for(var/i in 1 to length(text))
- var/letter = text[i]
+ var/rawchar = ""
+ var/letter = ""
+ var/lentext = length(text)
+ for(var/i = 1, i <= lentext, i += length(rawchar))
+ rawchar = letter = text[i]
if(prob(chance))
if(replace_characters)
letter = ""
for(var/j in 1 to rand(0, 2))
- letter += pick("#","@","*","&","%","$","/", "<", ">", ";","*","*","*","*","*","*","*")
+ letter += pick("#", "@", "*", "&", "%", "$", "/", "<", ">", ";", "*", "*", "*", "*", "*", "*", "*")
. += letter
-
-
-/**
- * Convert a message into leet non gaijin speak
- *
- * The difference with stutter is that this proc can stutter more than 1 letter
- *
- * The issue here is that anything that does not have a space is treated as one word (in many instances). For instance, "LOOKING," is a word, including the comma.
- *
- * It's fairly easy to fix if dealing with single letters but not so much with compounds of letters./N
- */
-/proc/ninjaspeak(n) //NINJACODE
- var/te = html_decode(n)
- var/t = ""
- n = length(n)
- var/p = 1
- while(p <= n)
- var/n_letter
- var/n_mod = rand(1,4)
- if(p+n_mod>n+1)
- n_letter = copytext(te, p, n+1)
- else
- n_letter = copytext(te, p, p+n_mod)
- if (prob(50))
- if (prob(30))
- n_letter = text("[n_letter]-[n_letter]-[n_letter]")
- else
- n_letter = text("[n_letter]-[n_letter]")
- else
- n_letter = text("[n_letter]")
- t = text("[t][n_letter]")
- p=p+n_mod
- return copytext(sanitize(t),1,MAX_MESSAGE_LEN)
+ return sanitize(.)
///Shake the camera of the person viewing the mob SO REAL!
/proc/shake_camera(mob/M, duration, strength=1)
diff --git a/code/modules/mob/say.dm b/code/modules/mob/say.dm
index 5df7959c02e..330d1f83a20 100644
--- a/code/modules/mob/say.dm
+++ b/code/modules/mob/say.dm
@@ -32,7 +32,7 @@
to_chat(usr, "Speech is currently admin-disabled.")
return
- message = trim(copytext(sanitize(message), 1, MAX_MESSAGE_LEN))
+ message = trim(copytext_char(sanitize(message), 1, MAX_MESSAGE_LEN))
usr.emote("me",1,message,TRUE)
@@ -84,9 +84,9 @@
///Check if this message is an emote
/mob/proc/check_emote(message, forced)
- if(copytext(message, 1, 2) == "*")
- emote(copytext(message, 2), intentional = !forced)
- return 1
+ if(message[1] == "*")
+ emote(copytext(message, length(message[1]) + 1), intentional = !forced)
+ return TRUE
///Check if the mob has a hivemind channel
/mob/proc/hivecheck()
@@ -105,11 +105,11 @@
* * A department radio (lots of values here)
*/
/mob/proc/get_message_mode(message)
- var/key = copytext(message, 1, 2)
+ var/key = message[1]
if(key == "#")
return MODE_WHISPER
else if(key == ";")
return MODE_HEADSET
- else if(length(message) > 2 && (key in GLOB.department_radio_prefixes))
- var/key_symbol = lowertext(copytext(message, 2, 3))
+ else if((length(message) > (length(key) + 1)) && (key in GLOB.department_radio_prefixes))
+ var/key_symbol = lowertext(message[length(key) + 1])
return GLOB.department_radio_keys[key_symbol]
diff --git a/code/modules/mob/transform_procs.dm b/code/modules/mob/transform_procs.dm
index 32e241bde01..62e66038a0a 100644
--- a/code/modules/mob/transform_procs.dm
+++ b/code/modules/mob/transform_procs.dm
@@ -41,8 +41,8 @@
// hash the original name?
if(tr_flags & TR_HASHNAME)
- O.name = "monkey ([copytext(md5(real_name), 2, 6)])"
- O.real_name = "monkey ([copytext(md5(real_name), 2, 6)])"
+ O.name = "monkey ([copytext_char(md5(real_name), 2, 6)])"
+ O.real_name = "monkey ([copytext_char(md5(real_name), 2, 6)])"
//handle DNA and other attributes
dna.transfer_identity(O)
@@ -216,7 +216,7 @@
dna.transfer_identity(O)
O.updateappearance(mutcolor_update=1)
- if(cmptext("monkey",copytext(O.dna.real_name,1,7)))
+ if(findtext(O.dna.real_name, "monkey", 1, 7)) //7 == length("monkey") + 1
O.real_name = random_unique_name(O.gender)
O.dna.generate_unique_enzymes(O)
else
diff --git a/code/modules/paperwork/folders.dm b/code/modules/paperwork/folders.dm
index 451c1b04371..be26b588aa9 100644
--- a/code/modules/paperwork/folders.dm
+++ b/code/modules/paperwork/folders.dm
@@ -45,15 +45,13 @@
to_chat(user, "You scribble illegibly on the cover of [src]!")
return
- var/inputvalue = input(user, "What would you like to label the folder?", "Folder Labelling", null) as text|null
-
- if (isnull(inputvalue))
+ var/inputvalue = stripped_input(user, "What would you like to label the folder?", "Folder Labelling", "", MAX_NAME_LEN)
+
+ if(!inputvalue)
return
-
- var/n_name = copytext(sanitize(inputvalue), 1, MAX_NAME_LEN)
-
+
if(user.canUseTopic(src, BE_CLOSE))
- name = "folder[(n_name ? " - '[n_name]'" : null)]"
+ name = "folder[(inputvalue ? " - '[inputvalue]'" : null)]"
/obj/item/folder/attack_self(mob/user)
diff --git a/code/modules/paperwork/handlabeler.dm b/code/modules/paperwork/handlabeler.dm
index bfebf63bc5c..d22cd747ca7 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 3eab1968d33..6f98b5f6036 100644
--- a/code/modules/paperwork/paper.dm
+++ b/code/modules/paperwork/paper.dm
@@ -148,7 +148,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 9cab2b1ec0c..4f6136e1102 100644
--- a/code/modules/photography/_pictures.dm
+++ b/code/modules/photography/_pictures.dm
@@ -117,9 +117,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 1d648086e69..67813f46594 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
..()
@@ -86,9 +85,9 @@
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.incapacitated())
+ if(n_name && (loc == usr || loc.loc && loc.loc == usr) && usr.stat == CONSCIOUS && !usr.incapacitated())
name = "photo[(n_name ? text("- '[n_name]'") : null)]"
add_fingerprint(usr)
diff --git a/code/modules/power/pipecleaners.dm b/code/modules/power/pipecleaners.dm
index 4b75fe34784..1b12d64a027 100644
--- a/code/modules/power/pipecleaners.dm
+++ b/code/modules/power/pipecleaners.dm
@@ -85,8 +85,8 @@ By design, d1 is the smallest direction and d2 is the highest
// ensure d1 & d2 reflect the icon_state for entering and exiting pipe_cleaner
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])))
if(d1)
stored = new/obj/item/stack/pipe_cleaner_coil(null,2,pipe_cleaner_color)
diff --git a/code/modules/procedural_mapping/mapGenerator.dm b/code/modules/procedural_mapping/mapGenerator.dm
index 01a6d7ac471..323f74d0efe 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/recycling/sortingmachinery.dm b/code/modules/recycling/sortingmachinery.dm
index 47bd9b467b4..d8573ee7030 100644
--- a/code/modules/recycling/sortingmachinery.dm
+++ b/code/modules/recycling/sortingmachinery.dm
@@ -46,7 +46,7 @@
if(!user.is_literate())
to_chat(user, "You scribble illegibly on the side of [src]!")
return
- var/str = copytext(sanitize(input(user,"Label text?","Set label","")),1,MAX_NAME_LEN)
+ var/str = stripped_input(user, "Label text?", "Set label", "", MAX_NAME_LEN)
if(!user.canUseTopic(src, BE_CLOSE))
return
if(!str || !length(str))
@@ -73,10 +73,10 @@
return
user.visible_message("[user] attaches [W] to [src].", "You attach [W] to [src].")
note = W
+ var/overlaystring = "[icon_state]_note"
if(giftwrapped)
- add_overlay(copytext("[icon_state]_note",5))
- return
- add_overlay("[icon_state]_note")
+ overlaystring = copytext(overlaystring, 5) //5 == length("gift") + 1
+ add_overlay(overlaystring)
else
return ..()
@@ -158,7 +158,7 @@
if(!user.is_literate())
to_chat(user, "You scribble illegibly on the side of [src]!")
return
- var/str = copytext(sanitize(input(user,"Label text?","Set label","")),1,MAX_NAME_LEN)
+ var/str = stripped_input(user, "Label text?", "Set label", "", MAX_NAME_LEN)
if(!user.canUseTopic(src, BE_CLOSE))
return
if(!str || !length(str))
@@ -185,10 +185,10 @@
return
user.visible_message("[user] attaches [W] to [src].", "You attach [W] to [src].")
note = W
+ var/overlaystring = "[icon_state]_note"
if(giftwrapped)
- add_overlay(copytext("[icon_state]_note",5))
- return
- add_overlay("[icon_state]_note")
+ overlaystring = copytext_char(overlaystring, 5) //5 == length("gift") + 1
+ add_overlay(overlaystring)
/obj/item/destTagger
name = "destination tagger"
diff --git a/code/modules/research/xenobiology/crossbreeding/stabilized.dm b/code/modules/research/xenobiology/crossbreeding/stabilized.dm
index 340b78b1a49..eee23636f78 100644
--- a/code/modules/research/xenobiology/crossbreeding/stabilized.dm
+++ b/code/modules/research/xenobiology/crossbreeding/stabilized.dm
@@ -153,7 +153,7 @@ Stabilized extracts:
saved_mind = null
START_PROCESSING(SSobj, src)
if(choice == "Familiar Name")
- var/newname = copytext(sanitize_name(input(user, "Would you like to change the name of [mob_name]", "Name change", mob_name) as null|text),1,MAX_NAME_LEN)
+ var/newname = sanitize_name(stripped_input(user, "Would you like to change the name of [mob_name]", "Name change", mob_name, MAX_NAME_LEN))
if(newname)
mob_name = newname
to_chat(user, "You speak softly into [src], and it shakes slightly in response.")
diff --git a/code/modules/research/xenobiology/xenobiology.dm b/code/modules/research/xenobiology/xenobiology.dm
index 4a767e1ec0f..f7440816b32 100644
--- a/code/modules/research/xenobiology/xenobiology.dm
+++ b/code/modules/research/xenobiology/xenobiology.dm
@@ -641,7 +641,7 @@
M.set_nutrition(700)
to_chat(M, "You absorb the potion and feel your intense desire to feed melt away.")
to_chat(user, "You feed the slime the potion, removing its hunger and calming it.")
- var/newname = copytext(sanitize_name(input(user, "Would you like to give the slime a name?", "Name your new pet", "pet slime") as null|text),1,MAX_NAME_LEN)
+ var/newname = sanitize_name(stripped_input(user, "Would you like to give the slime a name?", "Name your new pet", "pet slime", MAX_NAME_LEN))
if (!newname)
newname = "pet slime"
diff --git a/code/modules/spells/spell_types/mind_transfer.dm b/code/modules/spells/spell_types/mind_transfer.dm
index e85888c389e..4cebceeca82 100644
--- a/code/modules/spells/spell_types/mind_transfer.dm
+++ b/code/modules/spells/spell_types/mind_transfer.dm
@@ -61,7 +61,7 @@ Also, you never added distance checking after target is selected. I've went ahea
return
var/datum/mind/TM = target.mind
- if((target.anti_magic_check(TRUE, FALSE) || TM.has_antag_datum(/datum/antagonist/wizard) || TM.has_antag_datum(/datum/antagonist/cult) || TM.has_antag_datum(/datum/antagonist/changeling) || TM.has_antag_datum(/datum/antagonist/rev)) || cmptext(copytext(target.key,1,2),"@"))
+ if(target.anti_magic_check(TRUE, FALSE) || TM.has_antag_datum(/datum/antagonist/wizard) || TM.has_antag_datum(/datum/antagonist/cult) || TM.has_antag_datum(/datum/antagonist/changeling) || TM.has_antag_datum(/datum/antagonist/rev) || target.key[1] == "@")
if(!silent)
to_chat(user, "[target.p_their(TRUE)] mind is resisting your spell!")
return
diff --git a/code/modules/surgery/organs/eyes.dm b/code/modules/surgery/organs/eyes.dm
index 4309f5fa809..3c51ad92998 100644
--- a/code/modules/surgery/organs/eyes.dm
+++ b/code/modules/surgery/organs/eyes.dm
@@ -197,7 +197,7 @@
/obj/item/organ/eyes/robotic/shield/emp_act(severity)
return
-#define RGB2EYECOLORSTRING(definitionvar) ("[copytext(definitionvar,2,3)][copytext(definitionvar,4,5)][copytext(definitionvar,6,7)]")
+#define RGB2EYECOLORSTRING(definitionvar) ("[copytext_char(definitionvar, 2, 3)][copytext_char(definitionvar, 4, 5)][copytext_char(definitionvar, 6, 7)]")
/obj/item/organ/eyes/robotic/glow
name = "High Luminosity Eyes"
diff --git a/code/modules/surgery/organs/tongue.dm b/code/modules/surgery/organs/tongue.dm
index f97c0b7fcf9..d6e2a313d75 100644
--- a/code/modules/surgery/organs/tongue.dm
+++ b/code/modules/surgery/organs/tongue.dm
@@ -169,7 +169,7 @@
var/insertpos = rand(1, message_list.len - 1)
var/inserttext = message_list[insertpos]
- if(!(copytext(inserttext, length(inserttext) - 2) == "..."))
+ if(!(copytext(inserttext, -3) == "..."))//3 == length("...")
message_list[insertpos] = inserttext + "..."
if(prob(20) && message_list.len > 3)
diff --git a/code/modules/surgery/organs/vocal_cords.dm b/code/modules/surgery/organs/vocal_cords.dm
index e92ef603588..4de3d105070 100644
--- a/code/modules/surgery/organs/vocal_cords.dm
+++ b/code/modules/surgery/organs/vocal_cords.dm
@@ -186,7 +186,7 @@
listeners = list(L) //Devil names are unique.
power_multiplier *= 5 //if you're a devil and god himself addressed you, you fucked up
//Cut out the name so it doesn't trigger commands
- message = copytext(message, 0, start)+copytext(message, start + length(devilinfo.truename), length(message) + 1)
+ message = copytext(message, 1, start) + copytext(message, start + length(devilinfo.truename))
break
else if(findtext(message, L.real_name, 1, length(L.real_name) + 1))
specific_listeners += L //focus on those with the specified name
@@ -206,7 +206,7 @@
if(specific_listeners.len)
listeners = specific_listeners
power_multiplier *= (1 + (1/specific_listeners.len)) //2x on a single guy, 1.5x on two and so on
- message = copytext(message, 0, 1)+copytext(message, 1 + length(found_string), length(message) + 1)
+ message = copytext(message, length(found_string) + 1)
var/static/regex/stun_words = regex("stop|wait|stand still|hold on|halt")
var/static/regex/knockdown_words = regex("drop|fall|trip|knockdown")
diff --git a/interface/menu.dm b/interface/menu.dm
index 547c2edfc1d..2e54fa32a43 100644
--- a/interface/menu.dm
+++ b/interface/menu.dm
@@ -69,8 +69,8 @@ GLOBAL_LIST_EMPTY(menulist)
if (!verbpath || !(verbpath in typesof("[type]/verb")))
return
- if (copytext(verbpath.name,1,2) == "@")
- winset(C, null, list2params(list("command" = copytext(verbpath.name,2))))
+ if(verbpath.name[1] == "@")
+ winset(C, null, list2params(list("command" = copytext(verbpath.name, length(verbpath.name[1]) + 1))))
else
winset(C, null, list2params(list("command" = replacetext(verbpath.name, " ", "-"))))