Unicode awareness Part 2 -- copytext() (#48512)

* Unicode support Part 2 -- copytext()

This is the transition of all copytext() calls to be unicode aware and also some nearby calls in the same functions. Most things are just replacing copytext() with copytext_char() as a terrible character limiter but a few others were slightly more involved.

I replaced a ton of
````
var/something = sanitize(input())
something = copytext(something, 1, MAX_MESSAGE_LEN)
````

with a single stripped_input() call. stripped_input() already calls html_encode(), trim(), and some other sanitization so there shouldn't be any major issues there.

This is still VERY rough btw; DNA is a mess, the status displays are complete ass, there's a copytext() in code\datums\shuttles.dm that I'm not sure what to do with, and I didn't touch anything in the tools folder. I haven't tested this much at all yet, I only got it to compile earlier this morning. There's also likely to be weird bugs until I get around to fixing length(), findtext(), and the rest of the string procs.

* Makes the code functional

* Assume color hex strings are always # followed by ascii.
Properly encodes and decodes the stuff in mob_helpers.dm which fixes some issues there.

* Removes ninjaspeak since it's unused
This commit is contained in:
MrPerson
2020-01-17 18:07:22 -06:00
committed by oranges
parent e7a9bf4a6d
commit f7eb2c905b
110 changed files with 501 additions and 557 deletions

View File

@@ -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)

View File

@@ -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)

View File

@@ -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)

View File

@@ -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"

View File

@@ -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)]"

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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)]"

View File

@@ -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

View File

@@ -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)

View File

@@ -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)

View File

@@ -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

View File

@@ -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

View File

@@ -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])"

View File

@@ -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)

View File

@@ -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
. += "<a href=\"[CONFIG_GET(string/githuburl)]/pull/[tm.number]\">#[tm.number][details]</a><br>"

View File

@@ -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)

View File

@@ -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

View File

@@ -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]<BR>"
/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

View File

@@ -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 = "<span class='boldwarning'>THEY NEEEEEEED [unhinged]!!</span>\n"

View File

@@ -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, " ", "-")

View File

@@ -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

View File

@@ -248,13 +248,18 @@
var/max_line_len = 7*DNA_BLOCK_SIZE
if(viable_occupant)
temp_html += "<div class='dnaBlockNumber'>1</div>"
var/len = length(viable_occupant.dna.uni_identity)
for(var/i=1, i<=len, i++)
temp_html += "<a class='dnaBlock' href='?src=[REF(src)];task=pulseui;num=[i];'>[copytext(viable_occupant.dna.uni_identity,i,i+1)]</a>"
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 += "<a class='dnaBlock' href='?src=[REF(src)];task=pulseui;num=[char_it];'>[char]</a>"
if((char_it % max_line_len) == 0)
temp_html += "</div><div class='clearBoth'>"
if((i % DNA_BLOCK_SIZE) == 0 && i < len)
temp_html += "<div class='dnaBlockNumber'>[(i / DNA_BLOCK_SIZE) + 1]</div>"
if((char_it % DNA_BLOCK_SIZE) == 0 && byte_it < len_byte)
temp_html += "<div class='dnaBlockNumber'>[(char_it / DNA_BLOCK_SIZE) + 1]</div>"
else
temp_html += "---------"
temp_html += "</div></div><br><h1>Buffer Menu</h1>"
@@ -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 += "<div class='statusLine'><table class='statusDisplay'><tr>"
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()

View File

@@ -124,7 +124,7 @@
to_chat(usr, "<span class='danger'>Unauthorized access.</span>")
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

View File

@@ -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))

View File

@@ -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

View File

@@ -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:<UL>"}
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()

View File

@@ -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

View File

@@ -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
. = ..()

View File

@@ -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)

View File

@@ -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"]

View File

@@ -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 = "<font color = #666633>-% New ID assigned: \"[id]\" %-</font>"

View File

@@ -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.

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -390,7 +390,7 @@
to_chat(user, "<span class='notice'>You spray a [temp] on \the [target.name]</span>")
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)

View File

@@ -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

View File

@@ -109,7 +109,7 @@
to_chat(usr,"<span class='warning'>You [transmit_holder ? "enable" : "disable"] your pAI's [transmitting ? "outgoing" : "incoming"] radio transmissions!</span>")
to_chat(pai,"<span class='warning'>Your owner has [transmit_holder ? "enabled" : "disabled"] your [transmitting ? "outgoing" : "incoming"] radio transmissions!</span>")
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"])

View File

@@ -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, "<span class='boldnotice'>[display]</span><br>")

View File

@@ -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()

View File

@@ -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]

View File

@@ -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))

View File

@@ -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

View File

@@ -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]</span>"
@@ -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 == "!")

View File

@@ -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

View File

@@ -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]"))

View File

@@ -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"])

View File

@@ -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, "<span class='danger'>World variables are not allowed to be accessed. Use global.</span>")
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, "<span class='danger'>Invalid pointer syntax: [expression[start + 1]]</span>")
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

View File

@@ -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: <type path>
/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: ''' <some text> ''' | '"' <some text > '"'
/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

View File

@@ -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

View File

@@ -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"

View File

@@ -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

View File

@@ -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)

View File

@@ -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, "<span class='warning'>Filename must end in '.dmm': [map]</span>")
return
var/datum/map_template/M

View File

@@ -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, "<span class='warning'>Filename must end in '.dmm': [map_file]</span>")
return

View File

@@ -6,7 +6,7 @@
to_chat(usr, "<span class='danger'>Speech is currently admin-disabled.</span>")
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 = "<span class='adminnotice'><b><font color=orange>CENTCOM:</font>[ADMIN_FULLMONTY(Sender)] [ADMIN_CENTCOM_REPLY(Sender)]:</b> [msg]</span>"
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 = "<span class='adminnotice'><b><font color=crimson>SYNDICATE:</font>[ADMIN_FULLMONTY(Sender)] [ADMIN_SYNDICATE_REPLY(Sender)]:</b> [msg]</span>"
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 = "<span class='adminnotice'><b><font color=orange>NUKE CODE REQUEST:</font>[ADMIN_FULLMONTY(Sender)] [ADMIN_CENTCOM_REPLY(Sender)] [ADMIN_SET_SD_CODE]:</b> [msg]</span>"
to_chat(GLOB.admins, msg)
for(var/obj/machinery/computer/communications/C in GLOB.machines)

View File

@@ -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 = "/"

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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, " ")

View File

@@ -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)

View File

@@ -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)

View File

@@ -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

View File

@@ -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]"
//////////////

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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)

View File

@@ -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"

View File

@@ -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)

View File

@@ -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

View File

@@ -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"])

View File

@@ -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)

View File

@@ -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")

View File

@@ -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

View File

@@ -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, "<span class='notice'>The crate unlocks!</span>")
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, "<span class='notice'>You leave the crate alone.</span>")
else
to_chat(user, "<span class='warning'>A red light flashes.</span>")
@@ -69,20 +72,27 @@
else
to_chat(user, "<span class='notice'>* Anti-Tamper Bomb will activate after [attempts] failed access attempts.</span>")
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, "<span class='notice'>Last code attempt, [lastattempt], had [bulls] correct digits at correct positions and [cows] correct digits at incorrect positions.</span>")
return

View File

@@ -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()

View File

@@ -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, "<span class='warning'>You cannot re-enter your body.</span>")
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, "<span class='warning'>Another consciousness is in your body...It is resisting you.</span>")
return
client.change_view(CONFIG_GET(string/default_view))

View File

@@ -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)

View File

@@ -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]

View File

@@ -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

View File

@@ -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]")

View File

@@ -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)

View File

@@ -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, "<span class='danger'>Invalid emote.</span>")
else if(copytext(input,1,9) == "exclaims")
to_chat(user, "<span class='danger'>Invalid emote.</span>")
else if(copytext(input,1,6) == "yells")
to_chat(user, "<span class='danger'>Invalid emote.</span>")
else if(copytext(input,1,5) == "asks")
to_chat(user, "<span class='danger'>Invalid emote.</span>")
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))

View File

@@ -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)

View File

@@ -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 ..()

View File

@@ -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))

View File

@@ -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

View File

@@ -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)

View File

@@ -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)

View File

@@ -32,7 +32,7 @@
to_chat(usr, "<span class='danger'>Speech is currently admin-disabled.</span>")
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]

View File

@@ -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

View File

@@ -45,15 +45,13 @@
to_chat(user, "<span class='notice'>You scribble illegibly on the cover of [src]!</span>")
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)

View File

@@ -70,7 +70,7 @@
if(mode)
to_chat(user, "<span class='notice'>You turn on [src].</span>")
//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, "<span class='warning'>Invalid text!</span>")
return

View File

@@ -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

View File

@@ -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")

View File

@@ -55,9 +55,8 @@
if(!user.is_literate())
to_chat(user, "<span class='notice'>You scribble illegibly on [src]!</span>")
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)

Some files were not shown because too many files have changed in this diff Show More