Adds support for 513(and unicode), additionally drops supports for 512 in the process and updates dreamchecker(turdis) and casually fixes about 90 bugs in the codebase (#8324)

* Cherry picks the unicode part 2 PR from TG

* Things

* drop 512 support

* TAN --> tan

* Manually does the things that was in renamed files

* CLAMP --> clamp

* ismovableatom -> ismovable

* bugfixes, tg is bad

* Ports sanitize_name

* Bumps checks

* Fixes new linter errors (#48126)

About The Pull Request

This fixes the errors raised by the new feature I'm adding to the linter: SpaceManiac/SpacemanDMM#119

* Update SpacemanDMM suite to 1.2 (#48785)

* Update SpacemanDMM suite to 1.2

* Fix new lint errors

* Removes unreachable code (#48143)

About The Pull Request

As detected by SpaceManiac/SpacemanDMM#123

* casually fixes 50 bugs

* stoopid evil dreamchecker

* stoopid evil dreamchecker

* stoopid evil dreamchecker

* almost the same thing

* Makes all UIs UTF-8

* Fixes bugs

* Fixes runtimes, some related to 513, some not

* Fixes agent ids

Co-authored-by: MrPerson <spamtaffic@gmail.com>
Co-authored-by: alexkar598 <>
Co-authored-by: spookydonut <github@spooksoftware.com>
This commit is contained in:
alexkar598
2020-05-02 00:43:42 -04:00
committed by GitHub
parent 4fd902cf69
commit 2333d64f09
442 changed files with 1572 additions and 1604 deletions

2
SpacemanDMM.toml Normal file
View File

@@ -0,0 +1,2 @@
[langserver]
dreamchecker = true

View File

@@ -1,17 +1,7 @@
// simple is_type and similar inline helpers
#if DM_VERSION < 513
#define islist(L) (istype(L, /list))
#endif
#define in_range(source, user) (get_dist(source, user) <= 1 && (get_step(source, 0)?:z) == (get_step(user, 0)?:z))
#if DM_VERSION < 513
#define ismovableatom(A) (istype(A, /atom/movable))
#else
#define ismovableatom(A) ismovable(A)
#endif
#define isatom(A) (isloc(A))
#define isweakref(D) (istype(D, /datum/weakref))

View File

@@ -16,7 +16,7 @@
#define TICK_USAGE_TO_MS(starting_tickusage) (TICK_DELTA_TO_MS(TICK_USAGE_REAL - starting_tickusage))
#define PERCENT(val) (round((val)*100, 0.1))
#define CLAMP01(x) (CLAMP(x, 0, 1))
#define CLAMP01(x) (clamp(x, 0, 1))
//time of day but automatically adjusts to the server going into the next day within the same round.
//for when you need a reliable time number that doesn't depend on byond time.
@@ -30,27 +30,14 @@
// round() acts like floor(x, 1) by default but can't handle other values
#define FLOOR(x, y) ( round((x) / (y)) * (y) )
#if DM_VERSION < 513
#define CLAMP(CLVALUE,CLMIN,CLMAX) ( max( (CLMIN), min((CLVALUE), (CLMAX)) ) )
#else
#define CLAMP(CLVALUE,CLMIN,CLMAX) clamp(CLVALUE, CLMIN, CLMAX)
#endif
// Similar to clamp but the bottom rolls around to the top and vice versa. min is inclusive, max is exclusive
#define WRAP(val, min, max) ( min == max ? min : (val) - (round(((val) - (min))/((max) - (min))) * ((max) - (min))) )
// Real modulus that handles decimals
#define MODULUS(x, y) ( (x) - (y) * round((x) / (y)) )
// Tangent
#if DM_VERSION < 513
#define TAN(x) (sin(x) / cos(x))
#else
#define TAN(x) tan(x)
#endif
// Cotangent
#define COT(x) (1 / TAN(x))
#define COT(x) (1 / tan(x))
// Secant
#define SEC(x) (1 / cos(x))
@@ -187,8 +174,8 @@
while(pixel_y < -16)
pixel_y += 32
new_y--
new_x = CLAMP(new_x, 0, world.maxx)
new_y = CLAMP(new_y, 0, world.maxy)
new_x = clamp(new_x, 0, world.maxx)
new_y = clamp(new_y, 0, world.maxy)
return locate(new_x, new_y, starting.z)
// Returns a list where [1] is all x values and [2] is all y values that overlap between the given pair of rectangles

View File

@@ -13,4 +13,4 @@ GLOBAL_VAR_INIT(glide_size_multiplier, 1.0)
/// Then that's multiplied by the global glide size multiplier. 1.25 by default feels pretty close to spot on. This is just to try to get byond to behave.
/// The whole result is then clamped to within the range above.
/// Not very readable but it works
#define DELAY_TO_GLIDE_SIZE(delay) (CLAMP(((32 / max((delay) / world.tick_lag, 1)) * GLOB.glide_size_multiplier), MIN_GLIDE_SIZE, MAX_GLIDE_SIZE))
#define DELAY_TO_GLIDE_SIZE(delay) (clamp(((32 / max((delay) / world.tick_lag, 1)) * GLOB.glide_size_multiplier), MIN_GLIDE_SIZE, MAX_GLIDE_SIZE))

View File

@@ -1,5 +1,5 @@
#define PROFILE_START ;PROFILE_STORE = list();PROFILE_SET;
#define PROFILE_STOP ;PROFILE_STORE = null;
#define LINE_PROFILE_START ;PROFILE_STORE = list();PROFILE_SET;
#define LINE_PROFILE_STOP ;PROFILE_STORE = null;
#define PROFILE_SET ;PROFILE_TIME = TICK_USAGE_REAL; PROFILE_LINE = __LINE__; PROFILE_FILE = __FILE__; PROFILE_SLEEPCHECK = world.time;
@@ -26,4 +26,4 @@
#define PROFILE_ITEM_LEN 2
#define PROFILE_ITEM_TIME 1
#define PROFILE_ITEM_COUNT 2
#define PROFILE_ITEM_COUNT 2

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, -7) ) )
#define IS_NORMAL_LIST(L) (GET_TYPEID("\ref[L]") == TYPEID_NORMAL_LIST)

View File

@@ -25,7 +25,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

@@ -455,7 +455,7 @@
var/list/result = list()
for(var/m in group)
var/mob/M = m
if(!M.key || !M.client || (ignore_category && GLOB.poll_ignore[ignore_category] && M.ckey in GLOB.poll_ignore[ignore_category]))
if(!M.key || !M.client || (ignore_category && GLOB.poll_ignore[ignore_category] && (M.ckey in GLOB.poll_ignore[ignore_category])))
continue
if(be_special_flag)
if(!(M.client.prefs) || !(be_special_flag in M.client.prefs.be_special))

View File

@@ -61,7 +61,7 @@
var/adjacencies = 0
var/atom/movable/AM
if(ismovableatom(A))
if(ismovable(A))
AM = A
if(AM.can_be_unanchored && !AM.anchored)
return 0

View File

@@ -976,7 +976,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)
@@ -1104,7 +1104,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

@@ -429,7 +429,7 @@ GLOBAL_LIST_EMPTY(species_list)
continue
if(M.stat != DEAD && !override)
continue
if(speaker_key && speaker_key in prefs.ignoring)
if(speaker_key && (speaker_key in prefs.ignoring))
continue
switch(message_type)

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

@@ -2,9 +2,9 @@
/proc/sanitize_frequency(frequency, free = FALSE)
. = round(frequency)
if(free)
. = CLAMP(frequency, MIN_FREE_FREQ, MAX_FREE_FREQ)
. = clamp(frequency, MIN_FREE_FREQ, MAX_FREE_FREQ)
else
. = CLAMP(frequency, MIN_FREQ, MAX_FREQ)
. = clamp(frequency, MIN_FREQ, MAX_FREQ)
if(!(. % 2)) // Ensure the last digit is an odd number
. += 1

View File

@@ -45,22 +45,22 @@
var/start = 1 + (text2ascii(color,1)==35)
var/len = length(color)
var/step_size = 1 + ((len+1)-start != desired_format)
var/char = ""
. = ""
for(var/i=start, i<=len, i+=step_size)
var/ascii = text2ascii(color,i)
switch(ascii)
for(var/i=start, i<=len, i+=length(char))
char = color[i]
switch(text2ascii(char))
if(48 to 57)
. += ascii2text(ascii) //numbers 0 to 9
. += char //numbers 0 to 9
if(97 to 102)
. += ascii2text(ascii) //letters a to f
. += char //letters a to f
if(65 to 70)
. += ascii2text(ascii+32) //letters A to F - translates to lowercase
. += lowertext(char) //letters A to F - translates to lowercase
else
break
if(length(.) != desired_format)
if(length_char(.) != desired_format)
if(default)
return default
return crunch + repeat_string(desired_format, "0")
@@ -68,7 +68,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)]"
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

@@ -8,6 +8,6 @@
lines += "[entry] => [num2text(data[STAT_ENTRY_TIME], 10)]ms ([data[STAT_ENTRY_COUNT]]) (avg:[num2text(data[STAT_ENTRY_TIME]/(data[STAT_ENTRY_COUNT] || 1), 99)])"
if (user)
user << browse("<ol><li>[lines.Join("</li><li>")]</li></ol>", "window=[url_encode("stats:[REF(stats)]")]")
user << browse("<html><head><meta charset='UTF-8'></head><body><ol><li>[lines.Join("</li><li>")]</li></ol></body></html>", "window=[url_encode("stats:[REF(stats)]")]")
. = lines.Join("\n")

View File

@@ -40,13 +40,19 @@
for(var/char in repl_chars)
var/index = findtext(t, char)
while(index)
t = copytext(t, 1, index) + repl_chars[char] + copytext(t, index+1)
index = findtext(t, char, index+1)
t = copytext(t, 1, index) + repl_chars[char] + copytext(t, index+length(char))
index = findtext(t, char, index+length(char))
return t
/proc/sanitize_filename(t)
return sanitize_simple(t, list("\n"="", "\t"="", "/"="", "\\"="", "?"="", "%"="", "*"="", ":"="", "|"="", "\""="", "<"="", ">"=""))
/proc/sanitize_name(t,list/repl_chars = null)
if(t == "space" || t == "floor" || t == "wall" || t == "r-wall" || t == "monkey" || t == "unknown" || t == "inactive ai")
alert("Invalid name.")
return ""
return sanitize(t)
//Runs byond's sanitization proc along-side sanitize_simple
/proc/sanitize(t,list/repl_chars = null)
return html_encode(sanitize_simple(t,repl_chars))
@@ -63,22 +69,28 @@
//Returns null if there is any bad text in the string
/proc/reject_bad_text(text, max_length=512)
if(length(text) > max_length)
return //message too long
var/non_whitespace = 0
for(var/i=1, i<=length(text), i++)
switch(text2ascii(text,i))
if(62,60,92,47)
return //rejects the text if it contains these bad characters: <, >, \ or /
if(127 to 255)
return //rejects weird letters like <20>
/proc/reject_bad_text(text, max_length = 512, ascii_only = TRUE)
var/char_count = 0
var/non_whitespace = FALSE
var/lenbytes = length(text)
var/char = ""
for(var/i = 1, i <= lenbytes, i += length(char))
char = text[i]
char_count++
if(char_count > max_length)
return
switch(text2ascii(char))
if(62, 60, 92, 47) // <, >, \, /
return
if(0 to 31)
return //more weird stuff
return
if(32)
continue //whitespace
continue
if(127 to INFINITY)
if(ascii_only)
return
else
non_whitespace = 1
non_whitespace = TRUE
if(non_whitespace)
return text //only accepts the text if it has some non-spaces
@@ -99,73 +111,87 @@
else
return trim(html_encode(name), max_length)
#define NO_CHARS_DETECTED 0
#define SPACES_DETECTED 1
#define SYMBOLS_DETECTED 2
#define NUMBERS_DETECTED 3
#define LETTERS_DETECTED 4
//Filters out undesirable characters from names
/proc/reject_bad_name(t_in, allow_numbers=0, max_length=MAX_NAME_LEN)
/proc/reject_bad_name(t_in, allow_numbers=FALSE, max_length=MAX_NAME_LEN, ascii_only = TRUE)
if(!t_in || length(t_in) > max_length)
return //Rejects the input if it is null or if it is longer then the max length allowed
var/number_of_alphanumeric = 0
var/last_char_group = 0
var/last_char_group = NO_CHARS_DETECTED
var/t_out = ""
var/t_len = length(t_in)
var/charcount = 0
var/char = ""
for(var/i=1, i<=length(t_in), i++)
var/ascii_char = text2ascii(t_in,i)
switch(ascii_char)
for(var/i=1, i<=t_len, i+=length(char))
char = t_in[i]
switch(text2ascii(char))
// A .. Z
if(65 to 90) //Uppercase Letters
t_out += ascii2text(ascii_char)
number_of_alphanumeric++
last_char_group = 4
last_char_group = LETTERS_DETECTED
// a .. z
if(97 to 122) //Lowercase Letters
if(last_char_group<2)
t_out += ascii2text(ascii_char-32) //Force uppercase first character
else
t_out += ascii2text(ascii_char)
if(last_char_group == NO_CHARS_DETECTED || last_char_group == SPACES_DETECTED || last_char_group == SYMBOLS_DETECTED) //start of a word
char = uppertext(char)
number_of_alphanumeric++
last_char_group = 4
last_char_group = LETTERS_DETECTED
// 0 .. 9
if(48 to 57) //Numbers
if(!last_char_group)
continue //suppress at start of string
if(!allow_numbers)
if(last_char_group == NO_CHARS_DETECTED || !allow_numbers) //suppress at start of string
continue
t_out += ascii2text(ascii_char)
number_of_alphanumeric++
last_char_group = 3
last_char_group = NUMBERS_DETECTED
// ' - .
if(39,45,46) //Common name punctuation
if(!last_char_group)
if(last_char_group == NO_CHARS_DETECTED)
continue
t_out += ascii2text(ascii_char)
last_char_group = 2
last_char_group = SYMBOLS_DETECTED
// ~ | @ : # $ % & * +
if(126,124,64,58,35,36,37,38,42,43) //Other symbols that we'll allow (mainly for AI)
if(!last_char_group)
continue //suppress at start of string
if(!allow_numbers)
continue
t_out += ascii2text(ascii_char)
last_char_group = 2
if(last_char_group == NO_CHARS_DETECTED || !allow_numbers) //suppress at start of string
continue
last_char_group = SYMBOLS_DETECTED
//Space
if(32)
if(last_char_group <= 1)
continue //suppress double-spaces and spaces at start of string
t_out += ascii2text(ascii_char)
last_char_group = 1
if(last_char_group == NO_CHARS_DETECTED || last_char_group == SPACES_DETECTED) //suppress double-spaces and spaces at start of string
continue
last_char_group = SPACES_DETECTED
if(127 to INFINITY)
if(ascii_only)
continue
last_char_group = SYMBOLS_DETECTED ////for now, we'll treat all non-ascii characters like symbols even though most are letters
else
return
continue
t_out += char
charcount++
if(charcount >= max_length)
break
if(number_of_alphanumeric < 2)
return //protects against tiny names like "A" and also names like "' ' ' ' ' ' ' '"
if(last_char_group == 1)
t_out = copytext(t_out,1,length(t_out)) //removes the last character (in this case a space)
if(last_char_group == SPACES_DETECTED)
t_out = copytext_char(t_out,1,-1) //removes the last character (in this case a space)
for(var/bad_name in list("space","floor","wall","r-wall","monkey","unknown","inactive ai")) //prevents these common metagamey names
if(cmptext(t_out,bad_name))
@@ -173,6 +199,13 @@
return t_out
#undef NO_CHARS_DETECTED
#undef SPACES_DETECTED
#undef NUMBERS_DETECTED
#undef LETTERS_DETECTED
//html_encode helper proc that returns the smallest non null of two numbers
//or 0 if they're both null (needed because of findtext returning 0 when a value is not present)
/proc/non_zero_min(a, b)
@@ -182,39 +215,6 @@
return a
return (a < b ? a : b)
/*
* Text searches
*/
//Checks the beginning of a string for a specified sub-string
//Returns the position of the substring or 0 if it was not found
/proc/dd_hasprefix(text, prefix)
var/start = 1
var/end = length(prefix) + 1
return findtext(text, prefix, start, end)
//Checks the beginning of a string for a specified sub-string. This proc is case sensitive
//Returns the position of the substring or 0 if it was not found
/proc/dd_hasprefix_case(text, prefix)
var/start = 1
var/end = length(prefix) + 1
return findtextEx(text, prefix, start, end)
//Checks the end of a string for a specified substring.
//Returns the position of the substring or 0 if it was not found
/proc/dd_hassuffix(text, suffix)
var/start = length(text) - length(suffix)
if(start)
return findtext(text, suffix, start, null)
return
//Checks the end of a string for a specified substring. This proc is case sensitive
//Returns the position of the substring or 0 if it was not found
/proc/dd_hassuffix_case(text, suffix)
var/start = length(text) - length(suffix)
if(start)
return findtextEx(text, suffix, start, null)
//Checks if any of a given list of needles is in the haystack
/proc/text_in_list(haystack, list/needle_list, start=1, end=0)
for(var/needle in needle_list)
@@ -229,23 +229,17 @@
return 1
return 0
//Adds 'u' number of zeros ahead of the text 't'
/proc/add_zero(t, u)
while (length(t) < u)
t = "0[t]"
return t
//Adds 'char' zeros ahead of 'text' until there are 'count' characters total
/proc/add_leading(text, count, char = " ")
var/charcount = count - length_char(text)
var/list/chars_to_add[max(charcount + 1, 0)]
return jointext(chars_to_add, char) + text
//Adds 'u' number of spaces ahead of the text 't'
/proc/add_lspace(t, u)
while(length(t) < u)
t = " [t]"
return t
//Adds 'u' number of spaces behind the text 't'
/proc/add_tspace(t, u)
while(length(t) < u)
t = "[t] "
return t
//Adds 'char' zeros behind 'text' until there are 'count' characters total
/proc/add_trailing(text, count, char = " ")
var/charcount = count - length_char(text)
var/list/chars_to_add[max(charcount + 1, 0)]
return text + jointext(chars_to_add, char)
//Returns a string with reserved characters and spaces before the first letter removed
/proc/trim_left(text)
@@ -265,36 +259,16 @@
//Returns a string with reserved characters and spaces before the first word and after the last word removed.
/proc/trim(text, max_length)
if(max_length)
text = copytext(text, 1, max_length)
text = copytext_char(text, 1, max_length)
return trim_left(trim_right(text))
//Returns a string with the first element of the string capitalized.
/proc/capitalize(t as text)
return uppertext(copytext(t, 1, 2)) + copytext(t, 2)
. = t
//Centers text by adding spaces to either side of the string.
/proc/dd_centertext(message, length)
var/new_message = message
var/size = length(message)
var/delta = length - size
if(size == length)
return new_message
if(size > length)
return copytext(new_message, 1, length + 1)
if(delta == 1)
return new_message + " "
if(delta % 2)
new_message = " " + new_message
delta--
var/spaces = add_lspace("",delta/2-1)
return spaces + new_message + spaces
//Limits the length of the text. Note: MAX_MESSAGE_LEN and MAX_NAME_LEN are widely used for this purpose
/proc/dd_limittext(message, length)
var/size = length(message)
if(size <= length)
return message
return copytext(message, 1, length + 1)
if(t)
. = t[1]
return uppertext(.) + copytext(t, 1 + length(.))
/proc/stringmerge(text,compare,replace = "*")
@@ -302,20 +276,27 @@
//is in the other string at the same spot (assuming it is not a replace char).
//This is used for fingerprints
var/newtext = text
if(length(text) != length(compare))
return 0
for(var/i = 1, i < length(text), i++)
var/a = copytext(text,i,i+1)
var/b = copytext(compare,i,i+1)
var/text_it = 1 //iterators
var/comp_it = 1
var/newtext_it = 1
var/text_length = length(text)
var/comp_length = length(compare)
while(comp_it <= comp_length && text_it <= text_length)
var/a = text[text_it]
var/b = compare[comp_it]
//if it isn't both the same letter, or if they are both the replacement character
//(no way to know what it was supposed to be)
if(a != b)
if(a == replace) //if A is the replacement char
newtext = copytext(newtext,1,i) + b + copytext(newtext, i+1)
newtext = copytext(newtext, 1, newtext_it) + b + copytext(newtext, newtext_it + length(newtext[newtext_it]))
else if(b == replace) //if B is the replacement char
newtext = copytext(newtext,1,i) + a + copytext(newtext, i+1)
newtext = copytext(newtext, 1, newtext_it) + a + copytext(newtext, newtext_it + length(newtext[newtext_it]))
else //The lists disagree, Uh-oh!
return 0
text_it += length(a)
comp_it += length(b)
newtext_it += length(newtext[newtext_it])
return newtext
/proc/stringpercent(text,character = "*")
@@ -324,16 +305,21 @@
if(!text || !character)
return 0
var/count = 0
for(var/i = 1, i <= length(text), i++)
var/a = copytext(text,i,i+1)
if(a == character)
var/lentext = length(text)
var/letter = ""
for(var/i = 1, i <= lentext, i += length(letter))
letter = text[i]
if(letter == character)
count++
return count
/proc/reverse_text(text = "")
var/new_text = ""
for(var/i = length(text); i > 0; i--)
new_text += copytext(text, i, i+1)
var/lentext = length(text)
var/letter = ""
for(var/i = 1, i <= lentext, i += length(letter))
letter = text[i]
new_text = letter + new_text
return new_text
GLOBAL_LIST_INIT(zero_character_only, list("0"))
@@ -356,15 +342,6 @@ GLOBAL_LIST_INIT(binary, list("0","1"))
/proc/random_color()
return random_string(6, GLOB.hex_characters)
/proc/add_zero2(t, u)
var/temp1
while (length(t) < u)
t = "0[t]"
temp1 = t
if (length(t) > u)
temp1 = copytext(t,2,u+1)
return temp1
//merges non-null characters (3rd argument) from "from" into "into". Returns result
//e.g. into = "Hello World"
// from = "Seeya______"
@@ -377,41 +354,49 @@ GLOBAL_LIST_INIT(binary, list("0","1"))
into = ""
if(!istext(from))
from = ""
var/null_ascii = istext(null_char) ? text2ascii(null_char,1) : null_char
var/previous = 0
var/null_ascii = istext(null_char) ? text2ascii(null_char, 1) : null_char
var/copying_into = FALSE
var/char = ""
var/start = 1
var/end = length(into) + 1
for(var/i=1, i<end, i++)
var/ascii = text2ascii(from, i)
if(ascii == null_ascii)
if(previous != 1)
. += copytext(from, start, i)
start = i
previous = 1
var/end_from = length(from)
var/end_into = length(into)
var/into_it = 1
var/from_it = 1
while(from_it <= end_from && into_it <= end_into)
char = from[from_it]
if(text2ascii(char) == null_ascii)
if(!copying_into)
. += copytext(from, start, from_it)
start = into_it
copying_into = TRUE
else
if(previous != 0)
. += copytext(into, start, i)
start = i
previous = 0
if(copying_into)
. += copytext(into, start, into_it)
start = from_it
copying_into = FALSE
into_it += length(into[into_it])
from_it += length(char)
if(previous == 0)
. += copytext(from, start, end)
if(copying_into)
. += copytext(into, start)
else
. += copytext(into, start, end)
. += copytext(from, start, from_it)
if(into_it <= end_into)
. += copytext(into, into_it)
//finds the first occurrence of one of the characters from needles argument inside haystack
//it may appear this can be optimised, but it really can't. findtext() is so much faster than anything you can do in byondcode.
//stupid byond :(
/proc/findchar(haystack, needles, start=1, end=0)
var/temp
var/char = ""
var/len = length(needles)
for(var/i=1, i<=len, i++)
temp = findtextEx(haystack, ascii2text(text2ascii(needles,i)), start, end) //Note: ascii2text(text2ascii) is faster than copytext()
if(temp)
end = temp
return end
for(var/i = 1, i <= len, i += length(char))
char = needles[i]
. = findtextEx(haystack, char, start, end)
if(.)
return
return 0
/proc/parsemarkdown_basic_step1(t, limited=FALSE)
if(length(t) <= 0)
@@ -569,23 +554,28 @@ GLOBAL_LIST_INIT(binary, list("0","1"))
return t
#define string2charlist(string) (splittext(string, regex("(.)")) - splittext(string, ""))
/proc/text2charlist(text)
var/char = ""
var/lentext = length(text)
. = list()
for(var/i = 1, i <= lentext, i += length(char))
char = text[i]
. += char
/proc/rot13(text = "")
var/list/textlist = string2charlist(text)
var/list/result = list()
for(var/c in textlist)
var/ca = text2ascii(c)
if(ca >= text2ascii("a") && ca <= text2ascii("m"))
ca += 13
else if(ca >= text2ascii("n") && ca <= text2ascii("z"))
ca -= 13
else if(ca >= text2ascii("A") && ca <= text2ascii("M"))
ca += 13
else if(ca >= text2ascii("N") && ca <= text2ascii("Z"))
ca -= 13
result += ascii2text(ca)
return jointext(result, "")
var/lentext = length(text)
var/char = ""
var/ascii = 0
. = ""
for(var/i = 1, i <= lentext, i += length(char))
char = text[i]
ascii = text2ascii(char)
switch(ascii)
if(65 to 77, 97 to 109) // A to M, a to am
ascii += 13
if(78 to 90, 110 to 122) //N to Z, n to z
ascii -= 13
. += ascii2text(ascii)
//Takes a list of values, sanitizes it down for readability and character count,
//then exports it as a json file at data/npc_saves/[filename].json.
@@ -597,7 +587,8 @@ GLOBAL_LIST_INIT(binary, list("0","1"))
return
//Regular expressions are, as usual, absolute magic
var/regex/all_invalid_symbols = new("\[^ -~]+")
//Any characters outside of 32 (space) to 126 (~) because treating things you don't understand as "magic" is really stupid
var/regex/all_invalid_symbols = new(@"[^ -~]{1}")
var/list/accepted = list()
for(var/string in proposed)
@@ -605,34 +596,44 @@ GLOBAL_LIST_INIT(binary, list("0","1"))
continue
var/buffer = ""
var/early_culling = TRUE
for(var/pos = 1, pos <= length(string), pos++)
var/let = copytext(string, pos, (pos + 1) % length(string))
if(early_culling && !findtext(let,GLOB.is_alphanumeric))
var/lentext = length(string)
var/let = ""
for(var/pos = 1, pos <= lentext, pos += length(let))
let = string[pos]
if(!findtext(let, GLOB.is_alphanumeric))
continue
early_culling = FALSE
buffer += let
if(!findtext(buffer,GLOB.is_alphanumeric))
buffer = copytext(string, pos)
break
if(early_culling) //Never found any letters! Bail!
continue
var/punctbuffer = ""
var/cutoff = length(buffer)
for(var/pos = length(buffer), pos >= 0, pos--)
var/let = copytext(buffer, pos, (pos + 1) % length(buffer))
if(findtext(let,GLOB.is_alphanumeric))
var/cutoff = 0
lentext = length_char(buffer)
for(var/pos = 1, pos <= lentext, pos++)
let = copytext_char(buffer, -pos, -pos + 1)
if(!findtext(let, GLOB.is_punctuation)) //This won't handle things like Nyaaaa!~ but that's fine
break
if(findtext(let,GLOB.is_punctuation))
punctbuffer = let + punctbuffer //Note this isn't the same thing as using +=
cutoff = pos
punctbuffer += let
cutoff += length(let)
if(punctbuffer) //We clip down excessive punctuation to get the letter count lower and reduce repeats. It's not perfect but it helps.
var/exclaim = FALSE
var/question = FALSE
var/periods = 0
for(var/pos = length(punctbuffer), pos >= 0, pos--)
var/punct = copytext(punctbuffer, pos, (pos + 1) % length(punctbuffer))
if(!exclaim && findtext(punct,"!"))
lentext = length(punctbuffer)
for(var/pos = 1, pos <= lentext, pos += length(let))
let = punctbuffer[pos]
if(!exclaim && findtext(let, "!"))
exclaim = TRUE
if(!question && findtext(punct,"?"))
if(question)
break
if(!question && findtext(let, "?"))
question = TRUE
if(!exclaim && !question && findtext(punct,"."))
if(exclaim)
break
if(!exclaim && !question && findtext(let, ".")) //? and ! take priority over periods
periods += 1
if(exclaim)
if(question)
@@ -641,15 +642,13 @@ GLOBAL_LIST_INIT(binary, list("0","1"))
punctbuffer = "!"
else if(question)
punctbuffer = "?"
else if(periods)
if(periods > 1)
punctbuffer = "..."
else
punctbuffer = "" //Grammer nazis be damned
buffer = copytext(buffer, 1, cutoff) + punctbuffer
if(!findtext(buffer,GLOB.is_alphanumeric))
continue
if(!buffer || length(buffer) > 280 || length(buffer) <= cullshort || buffer in accepted)
else if(periods > 1)
punctbuffer = "..."
else
punctbuffer = "" //Grammer nazis be damned
buffer = copytext(buffer, 1, -cutoff) + punctbuffer
lentext = length_char(buffer)
if(!buffer || lentext > 280 || lentext <= cullshort || (buffer in accepted))
continue
accepted += buffer
@@ -686,7 +685,7 @@ GLOBAL_LIST_INIT(binary, list("0","1"))
var/leng = length(string)
var/next_space = findtext(string, " ", next_backslash + 1)
var/next_space = findtext(string, " ", next_backslash + length(string[next_backslash]))
if(!next_space)
next_space = leng - next_backslash
@@ -694,8 +693,8 @@ GLOBAL_LIST_INIT(binary, list("0","1"))
return string
var/base = next_backslash == 1 ? "" : copytext(string, 1, next_backslash)
var/macro = lowertext(copytext(string, next_backslash + 1, next_space))
var/rest = next_backslash > leng ? "" : copytext(string, next_space + 1)
var/macro = lowertext(copytext(string, next_backslash + length(string[next_backslash]), next_space))
var/rest = next_backslash > leng ? "" : copytext(string, next_space + length(string[next_space]))
//See https://secure.byond.com/docs/ref/info.html#/DM/text/macros
switch(macro)
@@ -771,38 +770,35 @@ GLOBAL_LIST_INIT(binary, list("0","1"))
return uppertext(pick(GLOB.alphabet))
/proc/unintelligize(message)
var/prefix=copytext(message,1,2)
var/regex/word_boundaries = regex(@"\b[\S]+\b", "g")
var/prefix = message[1]
if(prefix == ";")
message = copytext(message,2)
else if(prefix in list(":","#"))
prefix += copytext(message,2,3)
message = copytext(message,3)
message = copytext(message, 1 + length(prefix))
else if(prefix in list(":", "#"))
prefix += message[1 + length(prefix)]
message = copytext(message, length(prefix))
else
prefix=""
prefix = ""
var/list/words = splittext(message," ")
var/list/rearranged = list()
for(var/i=1;i<=words.len;i++)
var/cword = pick(words)
words.Remove(cword)
var/suffix = copytext(cword,length(cword)-1,length(cword))
while(length(cword)>0 && suffix in list(".",",",";","!",":","?"))
cword = copytext(cword,1 ,length(cword)-1)
suffix = copytext(cword,length(cword)-1,length(cword) )
while(word_boundaries.Find(message))
var/cword = word_boundaries.match
if(length(cword))
rearranged += cword
message = "[prefix][jointext(rearranged," ")]"
. = message
shuffle_inplace(rearranged)
return "[prefix][jointext(rearranged, " ")]"
/proc/readable_corrupted_text(text)
var/list/corruption_options = list("..", "£%", "~~\"", "!!", "*", "^", "$!", "-", "}", "?")
var/corrupted_text = ""
var/lentext = length(text)
var/letter = ""
// Have every letter have a chance of creating corruption on either side
// Small chance of letters being removed in place of corruption - still overall readable
for(var/letter_index = 1; letter_index <= length(text); letter_index++)
var/letter = text[letter_index]
for(var/letter_index = 1, letter_index <= lentext, letter_index += length(letter))
letter = text[letter_index]
if (prob(15))
corrupted_text += pick(corruption_options)

View File

@@ -532,17 +532,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
@@ -595,27 +595,3 @@
return "turf"
else //regex everything else (works for /proc too)
return lowertext(replacetext("[the_type]", "[type2parent(the_type)]/", ""))
/proc/strtohex(str)
if(!istext(str)||!str)
return
var/r
var/c
for(var/i = 1 to length(str))
c= text2ascii(str,i)
r+= num2hex(c)
return r
// Decodes hex to raw byte string.
// If safe=TRUE, returns null on incorrect input strings instead of CRASHing
/proc/hextostr(str, safe=FALSE)
if(!istext(str)||!str)
return
var/r
var/c
for(var/i = 1 to length(str)/2)
c = hex2num(copytext(str,i*2-1,i*2+1), safe)
if(isnull(c))
return null
r += ascii2text(c)
return r

View File

@@ -6,25 +6,16 @@
//Inverts the colour of an HTML string
/proc/invertHTML(HTMLstring)
if (!( istext(HTMLstring) ))
if(!istext(HTMLstring))
CRASH("Given non-text argument!")
return
else
if (length(HTMLstring) != 7)
CRASH("Given non-HTML argument!")
return
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
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)
@@ -41,7 +32,7 @@
else if(dx<0)
.+=360
/proc/Get_Pixel_Angle(var/y, var/x)//for getting the angle when animating something's pixel_x and pixel_y
/proc/Get_Pixel_Angle(y, x)//for getting the angle when animating something's pixel_x and pixel_y
if(!y)
return (x>=0)?90:270
.=arctan(x/y)
@@ -184,15 +175,15 @@ Turf and target are separate in case you want to teleport some distance from a t
//Returns whether or not a player is a guest using their ckey as an input
/proc/IsGuestKey(key)
if (findtext(key, "Guest-", 1, 7) != 1) //was findtextEx
return 0
return FALSE
var/i, ch, len = length(key)
for (i = 7, i <= len, ++i)
for (i = 7, i <= len, ++i) //we know the first 6 chars are Guest-
ch = text2ascii(key, i)
if (ch < 48 || ch > 57)
return 0
return 1
if (ch < 48 || ch > 57) //0-9
return FALSE
return TRUE
//Generalised helper proc for letting mobs rename themselves. Used to be clname() and ainame()
/mob/proc/apply_pref_name(role, client/C)
@@ -281,7 +272,7 @@ Turf and target are separate in case you want to teleport some distance from a t
var/list/borgs = active_free_borgs()
if(borgs.len)
if(user)
. = input(user,"Unshackled cyborg signals detected:", "Cyborg Selection", borgs[1]) in borgs
. = input(user,"Unshackled cyborg signals detected:", "Cyborg Selection", borgs[1]) in sortList(borgs)
else
. = pick(borgs)
return .
@@ -290,7 +281,7 @@ Turf and target are separate in case you want to teleport some distance from a t
var/list/ais = active_ais()
if(ais.len)
if(user)
. = input(user,"AI signals detected:", "AI Selection", ais[1]) in ais
. = input(user,"AI signals detected:", "AI Selection", ais[1]) in sortList(ais)
else
. = pick(ais)
return .
@@ -367,12 +358,7 @@ Turf and target are separate in case you want to teleport some distance from a t
return "[round((powerused * 0.000000001),0.0001)] GW"
// Format an energy value in J, kJ, MJ, or GJ. 1W = 1J/s.
/proc/DisplayEnergy(units)
// APCs process every (SSmachines.wait * 0.1) seconds, and turn 1 W of
// excess power into GLOB.CELLRATE energy units when charging cells.
// With the current configuration of wait=20 and CELLRATE=0.002, this
// means that one unit is 1 kJ.
units *= SSmachines.wait * 0.1 / GLOB.CELLRATE
/proc/DisplayJoules(units)
if (units < 1000) // Less than a kJ
return "[round(units, 0.1)] J"
else if (units < 1000000) // Less than a MJ
@@ -381,6 +367,14 @@ Turf and target are separate in case you want to teleport some distance from a t
return "[round(units * 0.000001, 0.001)] MJ"
return "[round(units * 0.000000001, 0.0001)] GJ"
// Format an energy value measured in Power Cell units.
/proc/DisplayEnergy(units)
// APCs process every (SSmachines.wait * 0.1) seconds, and turn 1 W of
// excess power into GLOB.CELLRATE energy units when charging cells.
// With the current configuration of wait=20 and CELLRATE=0.002, this
// means that one unit is 1 kJ.
return DisplayJoules(units * SSmachines.wait * 0.1 / GLOB.CELLRATE)
/proc/get_mob_by_ckey(key)
if(!key)
return
@@ -451,16 +445,6 @@ Turf and target are separate in case you want to teleport some distance from a t
var/y = min(world.maxy, max(1, A.y + dy))
return locate(x,y,A.z)
#if DM_VERSION > 513
#warn 513 is definitely stable now, remove this
#endif
#if DM_VERSION < 513
/proc/arctan(x)
var/y=arcsin(x/sqrt(1+x*x))
return y
#endif
/*
Gets all contents of contents and returns them all in a list.
*/
@@ -801,7 +785,7 @@ GLOBAL_LIST_INIT(WALLITEMS_INVERSE, typecacheof(list(
/obj/structure/light_construct, /obj/machinery/light)))
/proc/gotwallitem(loc, dir, var/check_external = 0)
/proc/gotwallitem(loc, dir, check_external = 0)
var/locdir = get_step(loc, dir)
for(var/obj/O in loc)
if(is_type_in_typecache(O, GLOB.WALLITEMS) && check_external != 2)
@@ -884,8 +868,8 @@ GLOBAL_LIST_INIT(WALLITEMS_INVERSE, typecacheof(list(
tX = splittext(tX[1], ":")
tX = tX[1]
var/list/actual_view = getviewsize(C ? C.view : world.view)
tX = CLAMP(origin.x + text2num(tX) - round(actual_view[1] / 2) - 1, 1, world.maxx)
tY = CLAMP(origin.y + text2num(tY) - round(actual_view[2] / 2) - 1, 1, world.maxy)
tX = clamp(origin.x + text2num(tX) - round(actual_view[1] / 2) - 1, 1, world.maxx)
tY = clamp(origin.y + text2num(tY) - round(actual_view[2] / 2) - 1, 1, world.maxy)
return locate(tX, tY, tZ)
/proc/screen_loc2turf(text, turf/origin, client/C)
@@ -898,8 +882,8 @@ GLOBAL_LIST_INIT(WALLITEMS_INVERSE, typecacheof(list(
tX = text2num(tX[2])
tZ = origin.z
var/list/actual_view = getviewsize(C ? C.view : world.view)
tX = CLAMP(origin.x + round(actual_view[1] / 2) - tX, 1, world.maxx)
tY = CLAMP(origin.y + round(actual_view[2] / 2) - tY, 1, world.maxy)
tX = clamp(origin.x + round(actual_view[1] / 2) - tX, 1, world.maxx)
tY = clamp(origin.y + round(actual_view[2] / 2) - tY, 1, world.maxy)
return locate(tX, tY, tZ)
/proc/IsValidSrc(datum/D)
@@ -1164,7 +1148,7 @@ proc/pick_closest_path(value, list/matches = get_fancy_list_of_atom_types())
if(matches.len==1)
chosen = matches[1]
else
chosen = input("Select a type", "Pick Type", matches[1]) as null|anything in matches
chosen = input("Select a type", "Pick Type", matches[1]) as null|anything in sortList(matches)
if(!chosen)
return
chosen = matches[chosen]
@@ -1264,7 +1248,7 @@ GLOBAL_REAL_VAR(list/stack_trace_storage)
GLOBAL_DATUM_INIT(dview_mob, /mob/dview, new)
//Version of view() which ignores darkness, because BYOND doesn't have it (I actually suggested it but it was tagged redundant, BUT HEARERS IS A T- /rant).
/proc/dview(var/range = world.view, var/center, var/invis_flags = 0)
/proc/dview(range = world.view, center, invis_flags = 0)
if(!center)
return
@@ -1395,7 +1379,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

@@ -32,11 +32,11 @@
#endif
//Update this whenever you need to take advantage of more recent byond features
#define MIN_COMPILER_VERSION 512
#define MIN_COMPILER_VERSION 513
#if DM_VERSION < MIN_COMPILER_VERSION
//Don't forget to update this part
#error Your version of BYOND is too out-of-date to compile this project. Go to https://secure.byond.com/download and update.
#error You need version 512 or higher
#error You need version 513 or higher
#endif
//Additional code for the above flags.

View File

@@ -59,8 +59,6 @@
if(controlled_mech) //Are we piloting a mech? Placed here so the modifiers are not overridden.
controlled_mech.click_action(A, src, params) //Override AI normal click behavior.
return
return
if(modifiers["shift"])
ShiftClickOn(A)
return

View File

@@ -102,8 +102,8 @@
add_overlay(standard_background)
/obj/screen/movable/pic_in_pic/proc/set_view_size(width, height, do_refresh = TRUE)
width = CLAMP(width, 0, max_dimensions)
height = CLAMP(height, 0, max_dimensions)
width = clamp(width, 0, max_dimensions)
height = clamp(height, 0, max_dimensions)
src.width = width
src.height = height

View File

@@ -47,7 +47,7 @@
/obj/screen/plane_master/floor/backdrop(mob/mymob)
filters = list()
if(istype(mymob) && mymob.eye_blurry)
filters += GAUSSIAN_BLUR(CLAMP(mymob.eye_blurry*0.1,0.6,3))
filters += GAUSSIAN_BLUR(clamp(mymob.eye_blurry*0.1,0.6,3))
/obj/screen/plane_master/game_world
name = "game world plane master"
@@ -60,7 +60,7 @@
if(istype(mymob) && mymob.client && mymob.client.prefs && mymob.client.prefs.ambientocclusion)
filters += AMBIENT_OCCLUSION
if(istype(mymob) && mymob.eye_blurry)
filters += GAUSSIAN_BLUR(CLAMP(mymob.eye_blurry*0.1,0.6,3))
filters += GAUSSIAN_BLUR(clamp(mymob.eye_blurry*0.1,0.6,3))
/obj/screen/plane_master/lighting
name = "lighting plane master"

View File

@@ -133,9 +133,9 @@
/obj/item/proc/get_clamped_volume()
if(w_class)
if(force)
return CLAMP((force + w_class) * 4, 30, 100)// Add the item's force to its weight class and multiply by 4, then clamp the value between 30 and 100
return clamp((force + w_class) * 4, 30, 100)// Add the item's force to its weight class and multiply by 4, then clamp the value between 30 and 100
else
return CLAMP(w_class * 6, 10, 100) // Multiply the item's weight class by 6, then clamp the value between 10 and 100
return clamp(w_class * 6, 10, 100) // Multiply the item's weight class by 6, then clamp the value between 10 and 100
/mob/living/proc/send_item_attack_message(obj/item/I, mob/living/user, hit_area)
var/message_verb = "attacked"

View File

@@ -8,7 +8,7 @@
return // seems legit.
// Things you might plausibly want to follow
if(ismovableatom(A))
if(ismovable(A))
ManualFollow(A)
// Otherwise jump

View File

@@ -98,7 +98,7 @@
return FALSE
var/temp = text2num(trim(str_val))
if(!isnull(temp))
config_entry_value = CLAMP(integer ? round(temp) : temp, min_val, max_val)
config_entry_value = clamp(integer ? round(temp) : temp, min_val, max_val)
if(config_entry_value != temp && !(datum_flags & DF_VAR_EDITED))
log_config("Changing [name] from [temp] to [config_entry_value]!")
return TRUE
@@ -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

@@ -108,13 +108,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
@@ -122,7 +122,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)
@@ -287,7 +287,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, " ")
@@ -296,7 +296,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

@@ -186,7 +186,7 @@ SUBSYSTEM_DEF(demo)
loc_string = "null"
if(isturf(M.loc))
loc_string = "[M.x],[M.y],[M.z]"
else if(ismovableatom(M.loc))
else if(ismovable(M.loc))
loc_string = "\ref[M.loc]"
M.demo_last_loc = M.loc
var/appearance_string = "="
@@ -215,7 +215,7 @@ SUBSYSTEM_DEF(demo)
var/loc_string = "null"
if(isturf(M.loc))
loc_string = "[M.x],[M.y],[M.z]"
else if(ismovableatom(M.loc))
else if(ismovable(M.loc))
loc_string = "\ref[M.loc]"
M.demo_last_appearance = M.appearance
new_updates += "\ref[M] [loc_string] [encode_appearance(M.appearance)]"

View File

@@ -110,7 +110,7 @@ SUBSYSTEM_DEF(economy)
D.adjust_money(medical_cash)
if(ishostile(m))
var/mob/living/simple_animal/hostile/H = m
if(H.stat == DEAD && H.z in SSmapping.levels_by_trait(ZTRAIT_STATION))
if(H.stat == DEAD && (H.z in SSmapping.levels_by_trait(ZTRAIT_STATION)))
dead_monsters++
CHECK_TICK
var/living_ratio = alive_crew / crew

View File

@@ -119,7 +119,7 @@ SUBSYSTEM_DEF(job)
if(flag && (!(flag in player.client.prefs.be_special)))
JobDebug("FOC flag failed, Player: [player], Flag: [flag], ")
continue
if(player.mind && job.title in player.mind.restricted_roles)
if(player.mind && (job.title in player.mind.restricted_roles))
JobDebug("FOC incompatible with antagonist role, Player: [player]")
continue
// yogs start - Donor features, quiet round
@@ -160,7 +160,7 @@ SUBSYSTEM_DEF(job)
JobDebug("GRJ player not enough xp, Player: [player]")
continue
if(player.mind && job.title in player.mind.restricted_roles)
if(player.mind && (job.title in player.mind.restricted_roles))
JobDebug("GRJ incompatible with antagonist role, Player: [player], Job: [job.title]")
continue
@@ -348,7 +348,7 @@ SUBSYSTEM_DEF(job)
JobDebug("DO player not enough xp, Player: [player], Job:[job.title]")
continue
if(player.mind && job.title in player.mind.restricted_roles)
if(player.mind && (job.title in player.mind.restricted_roles))
JobDebug("DO incompatible with antagonist role, Player: [player], Job:[job.title]")
continue

View File

@@ -39,34 +39,34 @@ SUBSYSTEM_DEF(pai)
switch(option)
if("name")
t = input("Enter a name for your pAI", "pAI Name", candidate.name) as text
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(t),1,MAX_NAME_LEN)
candidate.name = t
if("desc")
t = input("Enter a description for your pAI", "pAI Description", candidate.description) as message
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
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
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)
@@ -90,6 +90,7 @@ SUBSYSTEM_DEF(pai)
var/dat = ""
dat += "<HTML><HEAD><meta charset='UTF-8'></HEAD><BODY>"
dat += {"
<style type="text/css">
@@ -127,6 +128,8 @@ SUBSYSTEM_DEF(pai)
dat += "<a href='byond://?src=[REF(src)];option=save;new=1;candidate=[REF(candidate)]'>Save Personality</a><br>"
dat += "<a href='byond://?src=[REF(src)];option=load;new=1;candidate=[REF(candidate)]'>Load Personality</a><br>"
dat += "</BODY></HTML>"
M << browse(dat, "window=paiRecruit")
/datum/controller/subsystem/pai/proc/spam_again()
@@ -154,7 +157,7 @@ SUBSYSTEM_DEF(pai)
for(var/datum/paiCandidate/c in SSpai.candidates)
available.Add(check_ready(c))
var/dat = ""
dat += "<HTML><HEAD><meta charset='UTF-8'></HEAD><BODY>"
dat += {"
<style type="text/css">
@@ -186,6 +189,8 @@ SUBSYSTEM_DEF(pai)
dat += "</table>"
dat += "</BODY></HTML>"
user << browse(dat, "window=findPai")
/datum/paiCandidate

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

@@ -180,7 +180,6 @@ SUBSYSTEM_DEF(shuttle)
resolve this problem by loading an emergency shuttle template \
manually, and then calling register() on the mobile docking port. \
Good luck.")
return
emergency = backup_shuttle
var/srd = CONFIG_GET(number/shuttle_refuel_delay)
if(world.time - SSticker.round_start_time < srd)

View File

@@ -159,7 +159,7 @@ SUBSYSTEM_DEF(timer)
if (timer.timeToRun < head_offset)
bucket_resolution = null //force bucket recreation
CRASH("[i] Invalid timer state: Timer in long run queue with a time to run less then head_offset. [get_timer_debug_string(timer)] world.time: [world.time], head_offset: [head_offset], practical_offset: [practical_offset]")
stack_trace("[i] Invalid timer state: Timer in long run queue with a time to run less then head_offset. [get_timer_debug_string(timer)] world.time: [world.time], head_offset: [head_offset], practical_offset: [practical_offset]")
if (timer.callBack && !timer.spent)
timer.callBack.InvokeAsync()
@@ -171,7 +171,7 @@ SUBSYSTEM_DEF(timer)
if (timer.timeToRun < head_offset + TICKS2DS(practical_offset-1))
bucket_resolution = null //force bucket recreation
CRASH("[i] Invalid timer state: Timer in long run queue that would require a backtrack to transfer to short run queue. [get_timer_debug_string(timer)] world.time: [world.time], head_offset: [head_offset], practical_offset: [practical_offset]")
stack_trace("[i] Invalid timer state: Timer in long run queue that would require a backtrack to transfer to short run queue. [get_timer_debug_string(timer)] world.time: [world.time], head_offset: [head_offset], practical_offset: [practical_offset]")
if (timer.callBack && !timer.spent)
timer.callBack.InvokeAsync()
spent += timer

View File

@@ -56,7 +56,6 @@ SUBSYSTEM_DEF(weather)
break
if (!ispath(weather_datum_type, /datum/weather))
CRASH("run_weather called with invalid weather_datum_type: [weather_datum_type || "null"]")
return
if (isnull(z_levels))
z_levels = SSmapping.levels_by_trait(initial(weather_datum_type.target_trait))
@@ -64,7 +63,6 @@ SUBSYSTEM_DEF(weather)
z_levels = list(z_levels)
else if (!islist(z_levels))
CRASH("run_weather called with invalid z_levels: [z_levels || "null"]")
return
var/datum/weather/W = new weather_datum_type(z_levels)
W.telegraph()

View File

@@ -150,7 +150,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

@@ -199,13 +199,16 @@
var/list/new_message = list()
for(var/word in message_split)
var/suffix = copytext(word,-1)
// Check if we have a suffix and break it out of the word
if(suffix in list("." , "," , ";" , "!" , ":" , "?"))
word = copytext(word,1,-1)
else
suffix = ""
var/suffix = ""
var/suffix_foundon = 0
for(var/potential_suffix in list(".", ",", ";", "!", ":", "?"))
suffix_foundon = findtext(word, potential_suffix, -length(potential_suffix))
if(suffix_foundon)
suffix = potential_suffix
break
if(suffix_foundon)
word = copytext(word, 1, suffix_foundon)
word = html_decode(word)
@@ -216,11 +219,12 @@
new_message += pick("uh","erm")
break
else
var/list/charlist = string2charlist(word) // Stupid shit code
shuffle_inplace(charlist)
var/list/charlist = text2charlist(word) // Stupid shit code
charlist.len = round(charlist.len * 0.5,1)
new_message += html_encode(jointext(charlist,"")) + suffix
shuffle_inplace(charlist)
new_message += jointext(charlist,"") + suffix
message = jointext(new_message, " ")
speech_args[SPEECH_MESSAGE] = trim(message)
speech_args[SPEECH_MESSAGE] = trim(message)

View File

@@ -71,7 +71,7 @@
return {"<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<meta http-equiv="Content-Type" content="text/html; charset='UTF-8'">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<head>
[head_content]

View File

@@ -10,7 +10,7 @@
var/regex/R
/datum/component/beetlejuice/Initialize()
if(!ismovableatom(parent))
if(!ismovable(parent))
return COMPONENT_INCOMPATIBLE
first_heard = list()
@@ -57,4 +57,4 @@
var/atom/movable/AM = parent
do_teleport(AM,get_turf(target))
active = FALSE
addtimer(VARSET_CALLBACK(src, active, TRUE), cooldown)
addtimer(VARSET_CALLBACK(src, active, TRUE), cooldown)

View File

@@ -2,7 +2,7 @@
dupe_mode = COMPONENT_DUPE_UNIQUE_PASSARGS
/datum/component/cleaning/Initialize()
if(!ismovableatom(parent))
if(!ismovable(parent))
return COMPONENT_INCOMPATIBLE
RegisterSignal(parent, list(COMSIG_MOVABLE_MOVED), .proc/Clean)

View File

@@ -3,7 +3,7 @@
var/list/say_lines
/datum/component/edit_complainer/Initialize(list/text)
if(!ismovableatom(parent))
if(!ismovable(parent))
return COMPONENT_INCOMPATIBLE
var/static/list/default_lines = list(

View File

@@ -54,7 +54,7 @@
/datum/fantasy_affix/pyromantic/apply(datum/component/fantasy/comp, newName)
var/obj/item/master = comp.parent
comp.appliedComponents += master.AddComponent(/datum/component/igniter, CLAMP(comp.quality, 1, 10))
comp.appliedComponents += master.AddComponent(/datum/component/igniter, clamp(comp.quality, 1, 10))
return "pyromantic [newName]"
/datum/fantasy_affix/vampiric
@@ -65,4 +65,4 @@
/datum/fantasy_affix/vampiric/apply(datum/component/fantasy/comp, newName)
var/obj/item/master = comp.parent
comp.appliedComponents += master.AddComponent(/datum/component/lifesteal, comp.quality)
return "vampiric [newName]"
return "vampiric [newName]"

View File

@@ -13,7 +13,7 @@
expire_time = world.time + expire_in
QDEL_IN(src, expire_in)
if(!ismovableatom(parent))
if(!ismovable(parent))
return COMPONENT_INCOMPATIBLE
RegisterSignal(parent, COMSIG_COMPONENT_CLEAN_ACT, .proc/clean)
RegisterSignal(parent, COMSIG_MOVABLE_BUCKLE, .proc/try_infect_buckle)

View File

@@ -32,7 +32,7 @@
do_knockback(target, null, angle2dir(Angle))
/datum/component/knockback/proc/do_knockback(atom/target, mob/thrower, throw_dir)
if(!ismovableatom(target) || throw_dir == null)
if(!ismovable(target) || throw_dir == null)
return
var/atom/movable/throwee = target
if(throwee.anchored && !throw_anchored)
@@ -41,4 +41,4 @@
throw_dir = turn(throw_dir, 180)
throw_distance *= -1
var/atom/throw_target = get_edge_target_turf(throwee, throw_dir)
throwee.safe_throw_at(throw_target, throw_distance, 1, thrower)
throwee.safe_throw_at(throw_target, throw_distance, 1, thrower)

View File

@@ -2,7 +2,7 @@
if(!isatom(parent))
return COMPONENT_INCOMPATIBLE
RegisterSignal(parent, COMSIG_PARENT_EXAMINE, .proc/examine)
if(ismovableatom(parent))
if(ismovable(parent))
RegisterSignal(parent, COMSIG_MOVABLE_CROSSED, .proc/crossed_react)
RegisterSignal(parent, COMSIG_MOVABLE_UNCROSSED, .proc/uncrossed_react)
for(var/i in get_turf(parent))

View File

@@ -14,8 +14,8 @@
var/x = target.x
var/y = target.y
var/z = target.z
var/turf/southwest = locate(CLAMP(x - (direction & WEST ? range : 0), 1, world.maxx), CLAMP(y - (direction & SOUTH ? range : 0), 1, world.maxy), CLAMP(z, 1, world.maxz))
var/turf/northeast = locate(CLAMP(x + (direction & EAST ? range : 0), 1, world.maxx), CLAMP(y + (direction & NORTH ? range : 0), 1, world.maxy), CLAMP(z, 1, world.maxz))
var/turf/southwest = locate(clamp(x - (direction & WEST ? range : 0), 1, world.maxx), clamp(y - (direction & SOUTH ? range : 0), 1, world.maxy), clamp(z, 1, world.maxz))
var/turf/northeast = locate(clamp(x + (direction & EAST ? range : 0), 1, world.maxx), clamp(y + (direction & NORTH ? range : 0), 1, world.maxy), clamp(z, 1, world.maxz))
//holder.vis_contents += block(southwest, northeast) // This doesnt work because of beta bug memes
for(var/i in block(southwest, northeast))
holder.vis_contents += i

View File

@@ -205,7 +205,7 @@
/datum/component/mood/proc/setSanity(amount, minimum=SANITY_INSANE, maximum=SANITY_NEUTRAL)
var/mob/living/owner = parent
amount = CLAMP(amount, minimum, maximum)
amount = clamp(amount, minimum, maximum)
if(amount == sanity)
return
// If we're out of the acceptable minimum-maximum range move back towards it in steps of 0.5

View File

@@ -154,7 +154,7 @@
return (nanite_volume > 0)
/datum/component/nanites/proc/adjust_nanites(datum/source, amount)
nanite_volume = CLAMP(nanite_volume + amount, 0, max_nanites)
nanite_volume = clamp(nanite_volume + amount, 0, max_nanites)
if(nanite_volume <= 0) //oops we ran out
qdel(src)
@@ -166,7 +166,7 @@
if(remove || stealth)
return //bye icon
var/nanite_percent = (nanite_volume / max_nanites) * 100
nanite_percent = CLAMP(CEILING(nanite_percent, 10), 10, 100)
nanite_percent = clamp(CEILING(nanite_percent, 10), 10, 100)
holder.icon_state = "nanites[nanite_percent]"
/datum/component/nanites/proc/on_emp(datum/source, severity)
@@ -220,16 +220,16 @@
return FALSE
/datum/component/nanites/proc/set_volume(datum/source, amount)
nanite_volume = CLAMP(amount, 0, max_nanites)
nanite_volume = clamp(amount, 0, max_nanites)
/datum/component/nanites/proc/set_max_volume(datum/source, amount)
max_nanites = max(1, max_nanites)
/datum/component/nanites/proc/set_cloud(datum/source, amount)
cloud_id = CLAMP(amount, 0, 100)
cloud_id = clamp(amount, 0, 100)
/datum/component/nanites/proc/set_safety(datum/source, amount)
safety_threshold = CLAMP(amount, 0, max_nanites)
safety_threshold = clamp(amount, 0, max_nanites)
/datum/component/nanites/proc/set_regen(datum/source, amount)
regen_rate = amount

View File

@@ -21,7 +21,7 @@
/datum/component/orbiter/RegisterWithParent()
var/atom/target = parent
while(ismovableatom(target))
while(ismovable(target))
RegisterSignal(target, COMSIG_MOVABLE_MOVED, .proc/move_react)
target = target.loc
@@ -29,7 +29,7 @@
/datum/component/orbiter/UnregisterFromParent()
var/atom/target = parent
while(ismovableatom(target))
while(ismovable(target))
UnregisterSignal(target, COMSIG_MOVABLE_MOVED)
UnregisterSignal(target, COMSIG_MOVABLE_UPDATE_GLIDE_SIZE)
target = target.loc
@@ -82,7 +82,7 @@
if(ismob(orbiter))
var/mob/M = orbiter
M.updating_glide_size = FALSE
if(ismovableatom(parent))
if(ismovable(parent))
var/atom/movable/AM = parent
orbiter.glide_size = AM.glide_size
@@ -122,12 +122,12 @@
// These are prety rarely activated, how often are you following something in a bag?
if(oldloc && !isturf(oldloc)) // We used to be registered to it, probably
var/atom/target = oldloc
while(ismovableatom(target))
while(ismovable(target))
UnregisterSignal(target, COMSIG_MOVABLE_MOVED)
target = target.loc
if(orbited?.loc && orbited.loc != newturf) // We want to know when anything holding us moves too
var/atom/target = orbited.loc
while(ismovableatom(target))
while(ismovable(target))
RegisterSignal(target, COMSIG_MOVABLE_MOVED, .proc/move_react, TRUE)
target = target.loc

View File

@@ -11,7 +11,7 @@
var/turn_connects = TRUE
/datum/component/plumbing/Initialize(start=TRUE, _turn_connects=TRUE) //turn_connects for wheter or not we spin with the object to change our pipes
if(parent && !ismovableatom(parent))
if(parent && !ismovable(parent))
return COMPONENT_INCOMPATIBLE
var/atom/movable/AM = parent
if(!AM.reagents)
@@ -170,4 +170,4 @@
/datum/component/plumbing/tank
demand_connects = WEST
supply_connects = EAST
supply_connects = EAST

View File

@@ -22,7 +22,7 @@
var/del_on_unbuckle_all = FALSE
/datum/component/riding/Initialize()
if(!ismovableatom(parent))
if(!ismovable(parent))
return COMPONENT_INCOMPATIBLE
RegisterSignal(parent, COMSIG_MOVABLE_BUCKLE, .proc/vehicle_mob_buckle)
RegisterSignal(parent, COMSIG_MOVABLE_UNBUCKLE, .proc/vehicle_mob_unbuckle)
@@ -315,7 +315,6 @@
for(var/obj/item/riding_offhand/O in user.contents)
if(O.parent != AM)
CRASH("RIDING OFFHAND ON WRONG MOB")
continue
if(O.selfdeleting)
continue
else

View File

@@ -14,7 +14,7 @@
var/default_rotation_direction = ROTATION_CLOCKWISE
/datum/component/simple_rotation/Initialize(rotation_flags = NONE ,can_user_rotate,can_be_rotated,after_rotation)
if(!ismovableatom(parent))
if(!ismovable(parent))
return COMPONENT_INCOMPATIBLE
//throw if no rotation direction is specificed ?

View File

@@ -17,7 +17,7 @@
if(!isatom(parent))
return COMPONENT_INCOMPATIBLE
RegisterSignal(parent, list(COMSIG_ATOM_ENTERED, COMSIG_ATOM_BLOB_ACT, COMSIG_ATOM_HULK_ATTACK, COMSIG_PARENT_ATTACKBY), .proc/play_squeak)
if(ismovableatom(parent))
if(ismovable(parent))
RegisterSignal(parent, list(COMSIG_MOVABLE_BUMP, COMSIG_MOVABLE_IMPACT), .proc/play_squeak)
RegisterSignal(parent, COMSIG_MOVABLE_CROSSED, .proc/play_squeak_crossed)
RegisterSignal(parent, COMSIG_MOVABLE_DISPOSING, .proc/disposing_react)
@@ -89,4 +89,4 @@
/datum/component/squeak/proc/holder_dir_change(datum/source, old_dir, new_dir)
//If the dir changes it means we're going through a bend in the pipes, let's pretend we bumped the wall
if(old_dir != new_dir)
play_squeak()
play_squeak()

View File

@@ -5,7 +5,7 @@
var/allow_death = FALSE
/datum/component/stationloving/Initialize(inform_admins = FALSE, allow_death = FALSE)
if(!ismovableatom(parent))
if(!ismovable(parent))
return COMPONENT_INCOMPATIBLE
RegisterSignal(parent, list(COMSIG_MOVABLE_Z_CHANGED), .proc/check_in_bounds)
RegisterSignal(parent, list(COMSIG_MOVABLE_SECLUDED_LOCATION), .proc/relocate)

View File

@@ -333,8 +333,8 @@
numbered_contents = _process_numerical_display()
adjusted_contents = numbered_contents.len
var/columns = CLAMP(max_items, 1, screen_max_columns)
var/rows = CLAMP(CEILING(adjusted_contents / columns, 1), 1, screen_max_rows)
var/columns = clamp(max_items, 1, screen_max_columns)
var/rows = clamp(CEILING(adjusted_contents / columns, 1), 1, screen_max_rows)
standard_orient_objs(rows, columns, numbered_contents)
//This proc draws out the inventory and places the items on it. It uses the standard position.

View File

@@ -19,7 +19,6 @@
var/datum/component/wet_floor/WF = newcomp //Lets make an assumption
if(WF.gc()) //See if it's even valid, still. Also does LAZYLEN and stuff for us.
CRASH("Wet floor component tried to inherit another, but the other was able to garbage collect while being inherited! What a waste of time!")
return
for(var/i in WF.time_left_list)
add_wet(text2num(i), WF.time_left_list[i])
@@ -178,7 +177,7 @@
/datum/component/wet_floor/proc/_do_add_wet(type, duration_minimum, duration_add, duration_maximum)
var/time = 0
if(LAZYACCESS(time_left_list, "[type]"))
time = CLAMP(LAZYACCESS(time_left_list, "[type]") + duration_add, duration_minimum, duration_maximum)
time = clamp(LAZYACCESS(time_left_list, "[type]") + duration_add, duration_minimum, duration_maximum)
else
time = min(duration_minimum, duration_maximum)
LAZYSET(time_left_list, "[type]", time)

View File

@@ -47,7 +47,7 @@
addtimer(CALLBACK(src, .proc/charge), charge_rate)
/datum/action/innate/dash/proc/charge()
current_charges = CLAMP(current_charges + 1, 0, max_charges)
current_charges = clamp(current_charges + 1, 0, max_charges)
holder.update_action_buttons_icon()
if(recharge_sound)
playsound(dashing_item, recharge_sound, 50, 1)

View File

@@ -134,11 +134,9 @@
if(!islist(jsonlist))
if(!istext(jsonlist))
CRASH("Invalid JSON")
return
jsonlist = json_decode(jsonlist)
if(!islist(jsonlist))
CRASH("Invalid JSON")
return
if(!jsonlist["DATUM_TYPE"])
return
if(!ispath(jsonlist["DATUM_TYPE"]))

View File

@@ -222,6 +222,7 @@
var/html = {"
<html>
<head>
<meta charset='UTF-8'>
<title>[title]</title>
<style>
body {

View File

@@ -235,10 +235,10 @@
else
visibility_flags &= ~HIDDEN_SCANNER
SetSpread(CLAMP(2 ** (properties["transmittable"] - symptoms.len), DISEASE_SPREAD_BLOOD, DISEASE_SPREAD_AIRBORNE))
SetSpread(clamp(2 ** (properties["transmittable"] - symptoms.len), DISEASE_SPREAD_BLOOD, DISEASE_SPREAD_AIRBORNE))
permeability_mod = max(CEILING(0.4 * properties["transmittable"], 1), 1)
cure_chance = 15 - CLAMP(properties["resistance"], -5, 5) // can be between 10 and 20
cure_chance = 15 - clamp(properties["resistance"], -5, 5) // can be between 10 and 20
stage_prob = max(properties["stage_rate"], 2)
SetSeverity(properties["severity"])
GenerateCure(properties)
@@ -293,7 +293,7 @@
// Will generate a random cure, the more resistance the symptoms have, the harder the cure.
/datum/disease/advance/proc/GenerateCure()
if(properties && properties.len)
var/res = CLAMP(properties["resistance"] - (symptoms.len / 2), 1, advance_cures.len)
var/res = clamp(properties["resistance"] - (symptoms.len / 2), 1, advance_cures.len)
if(res == oldres)
return
cures = list(pick(advance_cures[res]))

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

@@ -6,7 +6,7 @@
var/capacity
/datum/ductnet/proc/add_duct(obj/machinery/duct/D)
if(!D || D in ducts)
if(!D || (D in ducts))
return
ducts += D
D.duct = src

View File

@@ -122,14 +122,14 @@ GLOBAL_LIST_EMPTY(explosions)
if(dist <= round(max_range + world.view - 2, 1))
M.playsound_local(epicenter, null, 100, 1, frequency, falloff = 5, S = explosion_sound)
if(baseshakeamount > 0)
shake_camera(M, 25, CLAMP(baseshakeamount, 0, 10))
shake_camera(M, 25, clamp(baseshakeamount, 0, 10))
// You hear a far explosion if you're outside the blast radius. Small bombs shouldn't be heard all over the station.
else if(dist <= far_dist)
var/far_volume = CLAMP(far_dist, 30, 50) // Volume is based on explosion size and dist
var/far_volume = clamp(far_dist, 30, 50) // Volume is based on explosion size and dist
far_volume += (dist <= far_dist * 0.5 ? 50 : 0) // add 50 volume if the mob is pretty close to the explosion
M.playsound_local(epicenter, null, far_volume, 1, frequency, falloff = 5, S = far_explosion_sound)
if(baseshakeamount > 0)
shake_camera(M, 10, CLAMP(baseshakeamount*0.25, 0, 2.5))
shake_camera(M, 10, clamp(baseshakeamount*0.25, 0, 2.5))
EX_PREPROCESS_CHECK_TICK
//postpone processing for a bit

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

@@ -257,8 +257,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

@@ -39,7 +39,7 @@ GLOBAL_LIST_INIT(huds, list(
/datum/atom_hud
var/list/atom/hudatoms = list() //list of all atoms which display this hud
var/list/mob/hudusers = list() //list with all mobs who can see the hud
var/list/hudusers = list() //list with all mobs who can see the hud
var/list/hud_icons = list() //these will be the indexes for the atom's hud_list
var/list/next_time_allowed = list() //mobs associated with the next time this hud can be added to them

View File

@@ -32,7 +32,7 @@
restraining = 0
streak = streak+element
if(length(streak) > max_streak_length)
streak = copytext(streak,2)
streak = copytext(streak, 1 + length(streak[1]))
return
/datum/martial_art/proc/basic_hit(mob/living/carbon/human/A,mob/living/carbon/human/D)

View File

@@ -102,7 +102,7 @@
"<span class='userdanger'>[A] slams your chest! You can't breathe!</span>")
playsound(get_turf(A), 'sound/effects/hit_punch.ogg', 50, 1, -1)
if(D.losebreath <= 10)
D.losebreath = CLAMP(D.losebreath + 5, 0, 10)
D.losebreath = clamp(D.losebreath + 5, 0, 10)
D.adjustOxyLoss(10)
log_combat(A, D, "quickchoked")
return 1
@@ -113,7 +113,7 @@
playsound(get_turf(A), 'sound/effects/hit_punch.ogg', 50, 1, -1)
D.apply_damage(5, A.dna.species.attack_type)
if(D.silent <= 10)
D.silent = CLAMP(D.silent + 10, 0, 10)
D.silent = clamp(D.silent + 10, 0, 10)
log_combat(A, D, "neck chopped")
return 1
@@ -206,4 +206,4 @@
heat_protection = HANDS
max_heat_protection_temperature = GLOVES_MAX_TEMP_PROTECT
resistance_flags = NONE
armor = list("melee" = 0, "bullet" = 0, "laser" = 0, "energy" = 0, "bomb" = 0, "bio" = 0, "rad" = 0, "fire" = 80, "acid" = 50)
armor = list("melee" = 0, "bullet" = 0, "laser" = 0, "energy" = 0, "bomb" = 0, "bio" = 0, "rad" = 0, "fire" = 80, "acid" = 50)

View File

@@ -46,7 +46,7 @@
var/linglink
var/datum/martial_art/martial_art
var/static/default_martial_art = new/datum/martial_art
var/miming = 0 // Mime's vow of silence
var/miming = FALSE // Mime's vow of silence
var/list/antag_datums
var/antag_hud_icon_state = null //this mind's ANTAG_HUD should have this icon_state
var/datum/atom_hud/antag/antag_hud = null //this mind's antag HUD
@@ -68,7 +68,7 @@
var/flavour_text = null
/datum/mind/New(var/key)
/datum/mind/New(key)
src.key = key
soulOwner = src
martial_art = default_martial_art
@@ -144,7 +144,9 @@
last_death = world.time
/datum/mind/proc/store_memory(new_text)
memory += "[new_text]<BR>"
var/newlength = length_char(memory) + length_char(new_text)
if (newlength > MAX_MESSAGE_LEN * 100)
memory = copytext_char(memory, -newlength-MAX_MESSAGE_LEN * 100)
/datum/mind/proc/wipe_memory()
memory = null
@@ -365,7 +367,8 @@
/datum/mind/proc/show_memory(mob/recipient, window=1)
if(!recipient)
recipient = current
var/output = "<B>[current.real_name]'s Memories:</B><br>"
var/output = ""
output += "<B>[current.real_name]'s Memories:</B><br>"
output += memory
@@ -387,6 +390,7 @@
output += "</ul>"
if(window)
output = "<HTML><HEAD><meta charset='UTF-8'></HEAD><BODY>" + output + "</BODY></HTML>"
recipient << browse(output,"window=memory")
else if(all_objectives.len || memory)
to_chat(recipient, "<i>[output]</i>")
@@ -407,13 +411,13 @@
A.admin_remove(usr)
if (href_list["role_edit"])
var/new_role = input("Select new role", "Assigned role", assigned_role) as null|anything in get_all_jobs()
var/new_role = input("Select new role", "Assigned role", assigned_role) as null|anything in sortList(get_all_jobs())
if (!new_role)
return
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
@@ -447,7 +451,7 @@
if(1)
target_antag = antag_datums[1]
else
var/datum/antagonist/target = input("Which antagonist gets the objective:", "Antagonist", "(new custom antag)") as null|anything in antag_datums + "(new custom antag)"
var/datum/antagonist/target = input("Which antagonist gets the objective:", "Antagonist", "(new custom antag)") as null|anything in sortList(antag_datums) + "(new custom antag)"
if (QDELETED(target))
return
else if(target == "(new custom antag)")
@@ -727,7 +731,7 @@
mind_initialize() //updates the mind (or creates and initializes one if one doesn't exist)
mind.active = 1 //indicates that the mind is currently synced with a client
/datum/mind/proc/has_martialart(var/string)
/datum/mind/proc/has_martialart(string)
if(martial_art && martial_art.id == string)
return martial_art
return FALSE

View File

@@ -157,7 +157,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

@@ -15,4 +15,4 @@ GLOBAL_REAL_VAR(PROFILE_TIME)
var/list/data = PROFILE_STORE[entry]
lines += "[entry] => [num2text(data[PROFILE_ITEM_TIME], 10)]ms ([data[PROFILE_ITEM_COUNT]]) (avg:[num2text(data[PROFILE_ITEM_TIME]/(data[PROFILE_ITEM_COUNT] || 1), 99)])"
user << browse("<ol><li>[lines.Join("</li><li>")]</li></ol>", "window=[url_encode(GUID())]")
user << browse("<HTML><HEAD><meta charset='UTF-8'></HEAD><BODY><ol><li>[lines.Join("</li><li>")]</li></ol></BODY></HTML>", "window=[url_encode(GUID())]")

View File

@@ -38,7 +38,7 @@
if (user.client)
user.client.images += bar
progress = CLAMP(progress, 0, goal)
progress = clamp(progress, 0, goal)
bar.icon_state = "prog_bar_[round(((progress / goal) * 100), 5)]"
if (!shown)
user.client.images += bar
@@ -64,4 +64,4 @@
qdel(bar)
. = ..()
#undef PROGRESSBAR_HEIGHT
#undef PROGRESSBAR_HEIGHT

View File

@@ -335,7 +335,7 @@
if(prob(severity * 0.15))
to_chat(owner, "<span class='sevtug[span_part]'>\"[text2ratvar(pick(mania_messages))]\"</span>")
owner.playsound_local(get_turf(motor), hum, severity, 1)
owner.adjust_drugginess(CLAMP(max(severity * 0.075, 1), 0, max(0, 50 - owner.druggy))) //7.5% of severity per second, minimum 1
owner.adjust_drugginess(clamp(max(severity * 0.075, 1), 0, max(0, 50 - owner.druggy))) //7.5% of severity per second, minimum 1
if(owner.hallucination < 50)
owner.hallucination = min(owner.hallucination + max(severity * 0.075, 1), 50) //7.5% of severity per second, minimum 1
if(owner.dizziness < 50)
@@ -842,4 +842,4 @@
name = "Broken Will"
desc = "..."
icon_state = "broken_will"
alerttooltipstyle = "alien" //yogs end
alerttooltipstyle = "alien" //yogs end

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

@@ -38,7 +38,6 @@
..()
if(!istype(holder, holder_type))
CRASH("Wire holder is not of the expected type!")
return
src.holder = holder
if(randomize)
@@ -124,7 +123,7 @@
return TRUE
/datum/wires/proc/is_dud(wire)
return dd_hasprefix(wire, WIRE_DUD_PREFIX)
return findtext(wire, WIRE_DUD_PREFIX, 1, length(WIRE_DUD_PREFIX) + 1)
/datum/wires/proc/is_dud_color(color)
return is_dud(get_wire(color))

View File

@@ -178,7 +178,7 @@
reagents = new()
reagents.reagent_list.Add(A)
reagents.conditional_update()
else if(ismovableatom(A))
else if(ismovable(A))
var/atom/movable/M = A
if(isliving(M.loc))
var/mob/living/L = M.loc

View File

@@ -149,7 +149,6 @@
return "health-85"
else
return "health-100"
return "0"
//HOOKS
@@ -302,7 +301,6 @@
return "crit"
else
return "dead"
return "dead"
//Sillycone hooks
/mob/living/silicon/proc/diag_hud_set_health()

View File

@@ -26,7 +26,7 @@
if (prob(meteorminutes/2))
wavetype = GLOB.meteors_catastrophic
var/ramp_up_final = CLAMP(round(meteorminutes/rampupdelta), 1, 10)
var/ramp_up_final = clamp(round(meteorminutes/rampupdelta), 1, 10)
spawn_meteors(ramp_up_final, wavetype)

View File

@@ -582,7 +582,7 @@ GLOBAL_LIST_EMPTY(possible_items)
else if(targetinfo.check_special_completion(I))//Returns 1 by default. Items with special checks will return 1 if the conditions are fulfilled.
return TRUE
if(targetinfo && I.type in targetinfo.altitems) //Ok, so you don't have the item. Do you have an alternative, at least?
if(targetinfo && (I.type in targetinfo.altitems)) //Ok, so you don't have the item. Do you have an alternative, at least?
if(targetinfo.check_special_completion(I))//Yeah, we do! Don't return 0 if we don't though - then you could fail if you had 1 item that didn't pass and got checked first!
return TRUE
return FALSE

View File

@@ -720,13 +720,13 @@
if("scan")
scan()
if("interior_pressure")
interior_pressure = CLAMP(text2num(params["pressure"]), 0, ONE_ATMOSPHERE)
interior_pressure = clamp(text2num(params["pressure"]), 0, ONE_ATMOSPHERE)
if("exterior_pressure")
exterior_pressure = CLAMP(text2num(params["pressure"]), 0, ONE_ATMOSPHERE)
exterior_pressure = clamp(text2num(params["pressure"]), 0, ONE_ATMOSPHERE)
if("depressurization_margin")
depressurization_margin = CLAMP(text2num(params["pressure"]), 0.15, 40)
depressurization_margin = clamp(text2num(params["pressure"]), 0.15, 40)
if("skip_delay")
skip_delay = CLAMP(text2num(params["skip_delay"]), 0, 1200)
skip_delay = clamp(text2num(params["skip_delay"]), 0, 1200)
update_icon(TRUE)
/obj/machinery/advanced_airlock_controller/proc/request_from_door(airlock)

View File

@@ -148,7 +148,7 @@
if(!request)
return
var/multiplier = text2num(params["multiplier"])
multiplier = CLAMP(multiplier,1,50)
multiplier = clamp(multiplier,1,50)
if((autoqueue.len + 1) < queue_max_len)
add_to_queue(request, multiplier) // Add item to queue for processing
else
@@ -161,7 +161,7 @@
if(!request)
return
var/multiplier = text2num(params["multiplier"])
multiplier = CLAMP(multiplier,1,50)
multiplier = clamp(multiplier,1,50)
make_item(request, multiplier)
processing_queue = FALSE
@@ -441,4 +441,4 @@
var/multiplier = being_built[2]
var/is_stack = (multiplier>1)
var/output = "[initial(D.name)][is_stack?" (x[multiplier])":null]"
return output
return output

View File

@@ -280,10 +280,10 @@
to_chat(AI, "<b>[U]</b> holds <a href='?_src_=usr;show_paper=1;'>\a [itemname]</a> up to one of your cameras ...")
else
to_chat(AI, "<b><a href='?src=[REF(AI)];track=[html_encode(U.name)]'>[U]</a></b> holds <a href='?_src_=usr;show_paper=1;'>\a [itemname]</a> up to one of your cameras ...")
AI.last_paper_seen = "<HTML><HEAD><TITLE>[itemname]</TITLE></HEAD><BODY><TT>[info]</TT></BODY></HTML>"
AI.last_paper_seen = "<HTML><HEAD><meta charset='UTF-8'><TITLE>[itemname]</TITLE></HEAD><BODY><TT>[info]</TT></BODY></HTML>"
else if (O.client && O.client.eye == src)
to_chat(O, "[U] holds \a [itemname] up to one of the cameras ...")
O << browse(text("<HTML><HEAD><TITLE>[]</TITLE></HEAD><BODY><TT>[]</TT></BODY></HTML>", itemname, info), text("window=[]", itemname))
O << browse(text("<HTML><HEAD><meta charset='UTF-8'><TITLE>[]</TITLE></HEAD><BODY><TT>[]</TT></BODY></HTML>", itemname, info), text("window=[]", itemname))
return
else if(istype(I, /obj/item/camera_bug))
@@ -423,14 +423,12 @@
for(var/obj/machinery/camera/C in oview(4, M))
if(C.can_use()) // check if camera disabled
return C
break
return null
/proc/near_range_camera(var/mob/M)
for(var/obj/machinery/camera/C in range(4, M))
if(C.can_use()) // check if camera disabled
return C
break
return null

View File

@@ -151,7 +151,7 @@
return
log_activity("changed greater than charge filter to \"[new_filter]\"")
if(new_filter)
new_filter = CLAMP(new_filter, 0, 100)
new_filter = clamp(new_filter, 0, 100)
playsound(src, 'sound/machines/terminal_prompt_confirm.ogg', 50, 0)
result_filters["Charge Above"] = new_filter
if(href_list["below_filter"])
@@ -161,7 +161,7 @@
return
log_activity("changed lesser than charge filter to \"[new_filter]\"")
if(new_filter)
new_filter = CLAMP(new_filter, 0, 100)
new_filter = clamp(new_filter, 0, 100)
playsound(src, 'sound/machines/terminal_prompt_confirm.ogg', 50, 0)
result_filters["Charge Below"] = new_filter
if(href_list["access_filter"])

View File

@@ -293,7 +293,7 @@ GLOBAL_LIST_EMPTY(atmos_air_controllers)
if("rate")
var/target = text2num(params["rate"])
if(!isnull(target))
target = CLAMP(target, 0, MAX_TRANSFER_RATE)
target = clamp(target, 0, MAX_TRANSFER_RATE)
signal.data += list("tag" = input_tag, "set_volume_rate" = target)
. = TRUE
if("output")
@@ -302,7 +302,7 @@ GLOBAL_LIST_EMPTY(atmos_air_controllers)
if("pressure")
var/target = text2num(params["pressure"])
if(!isnull(target))
target = CLAMP(target, 0, 4500)
target = clamp(target, 0, 4500)
signal.data += list("tag" = output_tag, "set_internal_pressure" = target)
. = TRUE
radio_connection.post_signal(src, signal, filter = RADIO_ATMOSIA)

View File

@@ -56,11 +56,9 @@
if (!network)
user.unset_machine()
CRASH("No camera network")
return
if (!(islist(network)))
user.unset_machine()
CRASH("Camera network is not a list")
return
if(..())
user.unset_machine()
return

View File

@@ -577,7 +577,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

@@ -437,7 +437,7 @@
var/dat = ""
if(SSshuttle.emergency.mode == SHUTTLE_CALL)
var/timeleft = SSshuttle.emergency.timeLeft()
dat += "<B>Emergency shuttle</B>\n<BR>\nETA: [timeleft / 60 % 60]:[add_zero(num2text(timeleft % 60), 2)]"
dat += "<B>Emergency shuttle</B>\n<BR>\nETA: [timeleft / 60 % 60]:[add_leading(num2text(timeleft % 60), 2, "0")]"
var/datum/browser/popup = new(user, "communications", "Communications Console", 400, 500)

View File

@@ -232,13 +232,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>"
@@ -472,7 +477,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
@@ -561,13 +566,13 @@
if("setbufferlabel")
var/text = sanitize(input(usr, "Input a new label:", "Input a Text", null) as text|null)
if(num && text)
num = CLAMP(num, 1, NUMBER_OF_BUFFERS)
num = clamp(num, 1, NUMBER_OF_BUFFERS)
var/list/buffer_slot = buffer[num]
if(istype(buffer_slot))
buffer_slot["label"] = text
if("setbuffer")
if(num && viable_occupant)
num = CLAMP(num, 1, NUMBER_OF_BUFFERS)
num = clamp(num, 1, NUMBER_OF_BUFFERS)
buffer[num] = list(
"label"="Buffer[num]:[viable_occupant.real_name]",
"UI"=viable_occupant.dna.uni_identity,
@@ -577,7 +582,7 @@
)
if("clearbuffer")
if(num)
num = CLAMP(num, 1, NUMBER_OF_BUFFERS)
num = clamp(num, 1, NUMBER_OF_BUFFERS)
var/list/buffer_slot = buffer[num]
if(istype(buffer_slot))
buffer_slot.Cut()
@@ -592,7 +597,7 @@
apply_buffer(SCANNER_ACTION_MIXED,num)
if("injector")
if(num && injectorready < world.time)
num = CLAMP(num, 1, NUMBER_OF_BUFFERS)
num = clamp(num, 1, NUMBER_OF_BUFFERS)
var/list/buffer_slot = buffer[num]
if(istype(buffer_slot))
var/obj/item/dnainjector/timed/I
@@ -619,11 +624,11 @@
injectorready = world.time + INJECTOR_TIMEOUT
if("loaddisk")
if(num && diskette && diskette.fields)
num = CLAMP(num, 1, NUMBER_OF_BUFFERS)
num = clamp(num, 1, NUMBER_OF_BUFFERS)
buffer[num] = diskette.fields.Copy()
if("savedisk")
if(num && diskette && !diskette.read_only)
num = CLAMP(num, 1, NUMBER_OF_BUFFERS)
num = clamp(num, 1, NUMBER_OF_BUFFERS)
var/list/buffer_slot = buffer[num]
if(istype(buffer_slot))
diskette.name = "data disk \[[buffer_slot["label"]]\]"
@@ -653,7 +658,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
@@ -661,12 +666,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"
@@ -759,7 +764,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()
@@ -853,7 +858,7 @@
return viable_occupant
/obj/machinery/computer/scan_consolenew/proc/apply_buffer(action,buffer_num)
buffer_num = CLAMP(buffer_num, 1, NUMBER_OF_BUFFERS)
buffer_num = clamp(buffer_num, 1, NUMBER_OF_BUFFERS)
var/list/buffer_slot = buffer[buffer_num]
var/mob/living/carbon/viable_occupant = get_viable_occupant()
if(istype(buffer_slot))

View File

@@ -108,7 +108,7 @@
new_goal = default_goal
if (new_goal > 1000)
to_chat(usr, "The entered amount of points is too large. Points have instead been set to the maximum allowed amount.")
id.goal = CLAMP(new_goal, 0, 1000) //maximum 1000 points
id.goal = clamp(new_goal, 0, 1000) //maximum 1000 points
if("toggle_open")
if(teleporter.locked)
to_chat(usr, "The teleporter is locked")

View File

@@ -178,7 +178,7 @@
if(!current_pad.teleporting)
var/new_x = input("Set the X offset (Horizontal)","X Offset", current_pad.x_offset) as null|num
if(!isnull(new_x))
new_x = CLAMP(new_x, current_pad.range * -1, current_pad.range)
new_x = clamp(new_x, current_pad.range * -1, current_pad.range)
. = TRUE
current_pad.x_offset = new_x
current_pad.update_indicator()
@@ -188,7 +188,7 @@
if(!current_pad.teleporting)
var/new_y = input("Set the Y offset (Vertical)","Y Offset", current_pad.y_offset) as null|num
if(!isnull(new_y))
new_y = CLAMP(new_y, current_pad.range * -1, current_pad.range)
new_y = clamp(new_y, current_pad.range * -1, current_pad.range)
. = TRUE
current_pad.y_offset = new_y
current_pad.update_indicator()
@@ -214,4 +214,4 @@
if("pull")
teleport(usr, current_pad, FALSE)
. = TRUE
. = TRUE
. = TRUE

View File

@@ -129,7 +129,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

View File

@@ -626,7 +626,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

@@ -33,7 +33,7 @@
to_chat(user, "<span class='notice'>You begin repairing [src]...</span>")
if(I.use_tool(src, user, 40, volume=40))
obj_integrity = CLAMP(obj_integrity + 20, 0, max_integrity)
obj_integrity = clamp(obj_integrity + 20, 0, max_integrity)
else
return ..()

View File

@@ -142,7 +142,7 @@
. /= 10
/obj/machinery/door_timer/proc/set_timer(value)
var/new_time = CLAMP(value,0,MAX_TIMER)
var/new_time = clamp(value,0,MAX_TIMER)
. = new_time == timer_duration //return 1 on no change
timer_duration = new_time
@@ -169,7 +169,7 @@
if(timing)
var/disp1 = id
var/time_left = time_left(seconds = TRUE)
var/disp2 = "[add_zero(num2text((time_left / 60) % 60),2)]:[add_zero(num2text(time_left % 60), 2)]"
var/disp2 = "[add_leading(num2text((time_left / 60) % 60), 2, "0")]:[add_leading(num2text(time_left % 60), 2, "0")]"
if(length(disp2) > CHARS_PER_LINE)
disp2 = "Error"
update_display(disp1, disp2)

View File

@@ -238,7 +238,10 @@
/obj/machinery/magnetic_controller/ui_interact(mob/user)
. = ..()
var/dat = "<B>Magnetic Control Console</B><BR><BR>"
var/dat = ""
dat += "<HTML><HEAD><meta charset='UTF-8'></HEAD><BODY>"
dat +="<B>Magnetic Control Console</B><BR><BR>"
if(!autolink)
dat += {"
Frequency: <a href='?src=[REF(src)];operation=setfreq'>[frequency]</a><br>
@@ -258,6 +261,7 @@
dat += "Path: {<a href='?src=[REF(src)];operation=setpath'>[path]</a>}<br>"
dat += "Moving: <a href='?src=[REF(src)];operation=togglemoving'>[moving ? "Enabled":"Disabled"]</a>"
dat += "</BODY></HTML>"
user << browse(dat, "window=magnet;size=400x500")
onclose(user, "magnet")
@@ -306,7 +310,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
@@ -368,13 +372,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

@@ -62,7 +62,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"
@@ -167,7 +167,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
updateDialog()

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()
@@ -514,8 +514,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
@@ -690,7 +688,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
@@ -831,7 +829,6 @@ GLOBAL_LIST_EMPTY(allCasters)
scanned_user = "[ai_user.name] ([ai_user.job])"
else
CRASH("Invalid user for this proc")
return
/obj/machinery/newscaster/proc/print_paper()
SSblackbox.record_feedback("amount", "newspapers_printed", 1)
@@ -901,6 +898,7 @@ GLOBAL_LIST_EMPTY(allCasters)
if(ishuman(user))
var/mob/living/carbon/human/human_user = user
var/dat
dat += "<HTML><HEAD><meta charset='UTF-8'></HEAD><BODY>"
pages = 0
switch(screen)
if(0) //Cover
@@ -973,6 +971,7 @@ GLOBAL_LIST_EMPTY(allCasters)
dat+="<BR><I>There is a small scribble near the end of this page... It reads: \"[scribble]\"</I>"
dat+= "<HR><DIV STYLE='float:left;'><A href='?src=[REF(src)];prev_page=1'>Previous Page</A></DIV>"
dat+="<BR><HR><div align='center'>[curr_page+1]</div>"
dat += "</BODY></HTML>"
human_user << browse(dat, "window=newspaper_main;size=300x400")
onclose(human_user, "newspaper_main")
else

View File

@@ -27,7 +27,7 @@
dat += "</ul>"
user << browse("<HEAD><TITLE>[src]</TITLE></HEAD><TT>[dat]</TT>", "window=pipedispenser")
user << browse("<HEAD><meta charset='UTF-8'><TITLE>[src]</TITLE></HEAD><TT>[dat]</TT>", "window=pipedispenser")
onclose(user, "pipedispenser")
return
@@ -55,9 +55,9 @@
new /obj/item/pipe_meter(loc)
wait = world.time + 15
if(href_list["layer_up"])
piping_layer = CLAMP(++piping_layer, PIPING_LAYER_MIN, PIPING_LAYER_MAX)
piping_layer = clamp(++piping_layer, PIPING_LAYER_MIN, PIPING_LAYER_MAX)
if(href_list["layer_down"])
piping_layer = CLAMP(--piping_layer, PIPING_LAYER_MIN, PIPING_LAYER_MAX)
piping_layer = clamp(--piping_layer, PIPING_LAYER_MIN, PIPING_LAYER_MAX)
return
/obj/machinery/pipedispenser/attackby(obj/item/W, mob/user, params)
@@ -131,7 +131,7 @@
dat += "</ul>"
user << browse("<HEAD><TITLE>[src]</TITLE></HEAD><TT>[dat]</TT>", "window=pipedispenser")
user << browse("<HEAD><meta charset='UTF-8'><TITLE>[src]</TITLE></HEAD><TT>[dat]</TT>", "window=pipedispenser")
return
@@ -182,7 +182,7 @@
<A href='?src=[REF(src)];tube=[TRANSIT_TUBE_POD]'>Transit Tube Pod</A><BR>
"}
user << browse("<HEAD><TITLE>[src]</TITLE></HEAD><TT>[dat]</TT>", "window=pipedispenser")
user << browse("<HEAD><meta charset='UTF-8'><TITLE>[src]</TITLE></HEAD><TT>[dat]</TT>", "window=pipedispenser")
return

View File

@@ -241,21 +241,21 @@ 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
screen = REQ_SCREEN_AUTHENTICATE
priority = CLAMP(text2num(href_list["priority"]), REQ_NORMAL_MESSAGE_PRIORITY, REQ_EXTREME_MESSAGE_PRIORITY)
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", message)),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)
priority = clamp(text2num(href_list["priority"]) || REQ_NORMAL_MESSAGE_PRIORITY, REQ_NORMAL_MESSAGE_PRIORITY, REQ_EXTREME_MESSAGE_PRIORITY)
else
message = ""
announceAuth = FALSE
@@ -327,7 +327,7 @@ GLOBAL_LIST_EMPTY(req_console_ckey_departments)
//Handle screen switching
if(href_list["setScreen"])
var/set_screen = CLAMP(text2num(href_list["setScreen"]) || 0, REQ_SCREEN_MAIN, REQ_SCREEN_ANNOUNCE)
var/set_screen = clamp(text2num(href_list["setScreen"]) || 0, REQ_SCREEN_MAIN, REQ_SCREEN_ANNOUNCE)
switch(set_screen)
if(REQ_SCREEN_MAIN)
to_department = ""
@@ -347,9 +347,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
. = ..()
@@ -398,7 +397,7 @@ GLOBAL_LIST_EMPTY(req_console_ckey_departments)
messages += "[header][sending]"
if(!silenced)
playsound(src, 'sound/machines/twobeep_high.ogg', 50, 1)
playsound(src, 'sound/machines/twobeep_high.ogg', 50, TRUE)
say(alert)
if(radio_freq)

View File

@@ -214,7 +214,7 @@
. = TRUE
if("set_nanite_cloud")
var/new_cloud = text2num(params["new_cloud"])
nanite_cloud = CLAMP(round(new_cloud, 1), 1, 100)
nanite_cloud = clamp(round(new_cloud, 1), 1, 100)
. = TRUE
//Some species are not scannable, like abductors (too unknown), androids (too artificial) or skeletons (too magic)
if("set_target_species")
@@ -227,7 +227,7 @@
"Starving",
"Obese"
)
if(new_nutrition && new_nutrition in nutrition_list)
if(new_nutrition && (new_nutrition in nutrition_list))
switch(new_nutrition)
if("Starving")
detect_nutrition = NUTRITION_LEVEL_STARVING

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