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: