From bcfe3e9851f8cd83dd0f89c736d9a2929b1d7310 Mon Sep 17 00:00:00 2001 From: spookerton Date: Thu, 31 Mar 2022 19:16:36 +0100 Subject: [PATCH] remove pre-513 compatibility bits --- code/__defines/__513_compatibility.dm | 29 ---- code/__defines/math.dm | 9 ++ code/_compatibility/509/JSON Reader.dm | 209 ------------------------- code/_compatibility/509/JSON Writer.dm | 62 -------- code/_compatibility/509/_JSON.dm | 14 -- code/_compatibility/509/text.dm | 6 - code/_compatibility/509/type2type.dm | 102 ------------ code/global.dm | 3 - polaris.dme | 6 - 9 files changed, 9 insertions(+), 431 deletions(-) delete mode 100644 code/__defines/__513_compatibility.dm delete mode 100644 code/_compatibility/509/JSON Reader.dm delete mode 100644 code/_compatibility/509/JSON Writer.dm delete mode 100644 code/_compatibility/509/_JSON.dm delete mode 100644 code/_compatibility/509/text.dm delete mode 100644 code/_compatibility/509/type2type.dm diff --git a/code/__defines/__513_compatibility.dm b/code/__defines/__513_compatibility.dm deleted file mode 100644 index 78583570ff..0000000000 --- a/code/__defines/__513_compatibility.dm +++ /dev/null @@ -1,29 +0,0 @@ -#if DM_VERSION < 513 - -#define ismovable(A) (istype(A, /atom/movable)) - -#define islist(L) (istype(L, /list)) - -#define CLAMP01(x) (CLAMP(x, 0, 1)) - -#define CLAMP(CLVALUE,CLMIN,CLMAX) ( max( (CLMIN), min((CLVALUE), (CLMAX)) ) ) - -#define ATAN2(x, y) ( !(x) && !(y) ? 0 : (y) >= 0 ? arccos((x) / sqrt((x)*(x) + (y)*(y))) : -arccos((x) / sqrt((x)*(x) + (y)*(y))) ) - -#define TAN(x) (sin(x) / cos(x)) - -#define arctan(x) (arcsin(x/sqrt(1+x*x))) - -////////////////////////////////////////////////// - -#else - -#define CLAMP01(x) clamp(x, 0, 1) - -#define CLAMP(CLVALUE, CLMIN, CLMAX) clamp(CLVALUE, CLMIN, CLMAX) - -#define TAN(x) tan(x) - -#define ATAN2(x, y) arctan(x, y) - -#endif \ No newline at end of file diff --git a/code/__defines/math.dm b/code/__defines/math.dm index 2053b762d2..02b1689ea7 100644 --- a/code/__defines/math.dm +++ b/code/__defines/math.dm @@ -9,6 +9,15 @@ #define SHORT_REAL_LIMIT 16777216 +#define CLAMP01(x) clamp(x, 0, 1) + +#define CLAMP(CLVALUE, CLMIN, CLMAX) clamp(CLVALUE, CLMIN, CLMAX) + +#define TAN(x) tan(x) + +#define ATAN2(x, y) arctan(x, y) + + //"fancy" math for calculating time in ms from tick_usage percentage and the length of ticks //percent_of_tick_used * (ticklag * 100(to convert to ms)) / 100(percent ratio) //collapsed to percent_of_tick_used * tick_lag diff --git a/code/_compatibility/509/JSON Reader.dm b/code/_compatibility/509/JSON Reader.dm deleted file mode 100644 index 18f739c5ef..0000000000 --- a/code/_compatibility/509/JSON Reader.dm +++ /dev/null @@ -1,209 +0,0 @@ -#if DM_VERSION < 510 - -json_token - var - value - New(v) - src.value = v - text - number - word - symbol - eof - -json_reader - var - list - string = list("'", "\"") - symbols = list("{", "}", "\[", "]", ":", "\"", "'", ",") - sequences = list("b" = 8, "t" = 9, "n" = 10, "f" = 12, "r" = 13) - tokens - json - i = 1 - - - proc - // scanner - ScanJson(json) - src.json = json - . = new/list() - src.i = 1 - while(src.i <= length(json)) - var/char = get_char() - if(is_whitespace(char)) - i++ - continue - if(string.Find(char)) - . += read_string(char) - else if(symbols.Find(char)) - . += new/json_token/symbol(char) - else if(is_digit(char)) - . += read_number() - else - . += read_word() - i++ - . += new/json_token/eof() - - read_word() - var/val = "" - while(i <= length(json)) - var/char = get_char() - if(is_whitespace(char) || symbols.Find(char)) - i-- // let scanner handle this character - return new/json_token/word(val) - val += char - i++ - - read_string(delim) - var - escape = FALSE - val = "" - while(++i <= length(json)) - var/char = get_char() - if(escape) - switch(char) - if("\\", "'", "\"", "/", "u") - val += char - else - // TODO: support octal, hex, unicode sequences - ASSERT(sequences.Find(char)) - val += ascii2text(sequences[char]) - else - if(char == delim) - return new/json_token/text(val) - else if(char == "\\") - escape = TRUE - else - val += char - CRASH("Unterminated string.") - - read_number() - var/val = "" - var/char = get_char() - while(is_digit(char) || char == "." || lowertext(char) == "e") - val += char - i++ - char = get_char() - i-- // allow scanner to read the first non-number character - return new/json_token/number(text2num(val)) - - check_char() - ASSERT(args.Find(get_char())) - - get_char() - return copytext(json, i, i+1) - - is_whitespace(char) - return char == " " || char == "\t" || char == "\n" || text2ascii(char) == 13 - - is_digit(char) - var/c = text2ascii(char) - return 48 <= c && c <= 57 || char == "+" || char == "-" - - - // parser - ReadObject(list/tokens) - src.tokens = tokens - . = new/list() - i = 1 - read_token("{", /json_token/symbol) - while(i <= tokens.len) - var/json_token/K = get_token() - check_type(/json_token/word, /json_token/text) - next_token() - read_token(":", /json_token/symbol) - - .[K.value] = read_value() - - var/json_token/S = get_token() - check_type(/json_token/symbol) - switch(S.value) - if(",") - next_token() - continue - if("}") - next_token() - return - else - die() - - get_token() - return tokens[i] - - next_token() - return tokens[++i] - - read_token(val, type) - var/json_token/T = get_token() - if(!(T.value == val && istype(T, type))) - CRASH("Expected '[val]', found '[T.value]'.") - next_token() - return T - - check_type(...) - var/json_token/T = get_token() - for(var/type in args) - if(istype(T, type)) - return - CRASH("Bad token type: [T.type].") - - check_value(...) - var/json_token/T = get_token() - ASSERT(args.Find(T.value)) - - read_key() - var/char = get_char() - if(char == "\"" || char == "'") - return read_string(char) - - read_value() - var/json_token/T = get_token() - switch(T.type) - if(/json_token/text, /json_token/number) - next_token() - return T.value - if(/json_token/word) - next_token() - switch(T.value) - if("true") - return TRUE - if("false") - return FALSE - if("null") - return null - if(/json_token/symbol) - switch(T.value) - if("\[") - return read_array() - if("{") - return ReadObject(tokens.Copy(i)) - die() - - read_array() - read_token("\[", /json_token/symbol) - . = new/list() - var/list/L = . - while(i <= tokens.len) - // Avoid using Add() or += in case a list is returned. - L.len++ - L[L.len] = read_value() - var/json_token/T = get_token() - check_type(/json_token/symbol) - switch(T.value) - if(",") - next_token() - continue - if("]") - next_token() - return - else - die() - next_token() - CRASH("Unterminated array.") - - - die(json_token/T) - if(!T) T = get_token() - CRASH("Unexpected token: [T.value].") - -#endif \ No newline at end of file diff --git a/code/_compatibility/509/JSON Writer.dm b/code/_compatibility/509/JSON Writer.dm deleted file mode 100644 index 80e4976687..0000000000 --- a/code/_compatibility/509/JSON Writer.dm +++ /dev/null @@ -1,62 +0,0 @@ -#if DM_VERSION < 510 - -json_writer - var - use_cache = 0 - - proc - WriteObject(list/L) - if(use_cache && L["__json_cache"]) - return L["__json_cache"] - - . = "{" - var/i = 1 - for(var/k in L) - var/val = L[k] - . += {"\"[k]\":[write(val)]"} - if(i++ < L.len) - . += "," - . += "}" - - write(val) - if(isnum(val)) - return num2text(val) - else if(isnull(val)) - return "null" - else if(istype(val, /list)) - if(is_associative(val)) - return WriteObject(val) - else - return write_array(val) - else - . += write_string("[val]") - - write_array(list/L) - . = "\[" - for(var/i = 1 to L.len) - . += write(L[i]) - if(i < L.len) - . += "," - . += "]" - - write_string(txt) - var/static/list/json_escape = list("\\" = "\\\\", "\"" = "\\\"", "\n" = "\\n") - for(var/targ in json_escape) - var/start = 1 - while(start <= length(txt)) - var/i = findtext(txt, targ, start) - if(!i) - break - var/lrep = length(json_escape[targ]) - txt = copytext(txt, 1, i) + json_escape[targ] + copytext(txt, i + length(targ)) - start = i + lrep - - return {""[txt]""} - - is_associative(list/L) - for(var/key in L) - // if the key is a list that means it's actually an array of lists (stupid Byond...) - if(!isnum(key) && !isnull(L[key]) && !istype(key, /list)) - return TRUE - -#endif \ No newline at end of file diff --git a/code/_compatibility/509/_JSON.dm b/code/_compatibility/509/_JSON.dm deleted file mode 100644 index 46f488ac56..0000000000 --- a/code/_compatibility/509/_JSON.dm +++ /dev/null @@ -1,14 +0,0 @@ -#if DM_VERSION < 510 -/* -n_Json v11.3.21 -*/ - -proc - json_decode(json) - var/static/json_reader/_jsonr = new() - return _jsonr.ReadObject(_jsonr.ScanJson(json)) - - json_encode(list/L) - var/static/json_writer/_jsonw = new() - return _jsonw.write(L) -#endif \ No newline at end of file diff --git a/code/_compatibility/509/text.dm b/code/_compatibility/509/text.dm deleted file mode 100644 index c22790ccb8..0000000000 --- a/code/_compatibility/509/text.dm +++ /dev/null @@ -1,6 +0,0 @@ -#if DM_VERSION < 510 - -/proc/replacetext(text, find, replacement) - return jointext(splittext(text, find), replacement) - -#endif \ No newline at end of file diff --git a/code/_compatibility/509/type2type.dm b/code/_compatibility/509/type2type.dm deleted file mode 100644 index 62d7a5e5c7..0000000000 --- a/code/_compatibility/509/type2type.dm +++ /dev/null @@ -1,102 +0,0 @@ -#if DM_VERSION < 510 -// Concatenates a list of strings into a single string. A seperator may optionally be provided. -/proc/jointext(list/ls, sep) - if (ls.len <= 1) // Early-out code for empty or singleton lists. - return ls.len ? ls[1] : "" - - var/l = ls.len // Made local for sanic speed. - var/i = 0 // Incremented every time a list index is accessed. - - if (sep <> null) - // Macros expand to long argument lists like so: sep, ls[++i], sep, ls[++i], sep, ls[++i], etc... - #define S1 sep, ls[++i] - #define S4 S1, S1, S1, S1 - #define S16 S4, S4, S4, S4 - #define S64 S16, S16, S16, S16 - - . = "[ls[++i]]" // Make sure the initial element is converted to text. - - // Having the small concatenations come before the large ones boosted speed by an average of at least 5%. - if (l-1 & 0x01) // 'i' will always be 1 here. - . = text("[][][]", ., S1) // Append 1 element if the remaining elements are not a multiple of 2. - if (l-i & 0x02) - . = text("[][][][][]", ., S1, S1) // Append 2 elements if the remaining elements are not a multiple of 4. - if (l-i & 0x04) - . = text("[][][][][][][][][]", ., S4) // And so on.... - if (l-i & 0x08) - . = text("[][][][][][][][][][][][][][][][][]", ., S4, S4) - if (l-i & 0x10) - . = text("[][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][]", ., S16) - if (l-i & 0x20) - . = text("[][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][]\ - [][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][]", ., S16, S16) - if (l-i & 0x40) - . = text("[][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][]\ - [][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][]\ - [][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][]\ - [][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][]", ., S64) - while (l > i) // Chomp through the rest of the list, 128 elements at a time. - . = text("[][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][]\ - [][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][]\ - [][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][]\ - [][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][]\ - [][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][]\ - [][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][]\ - [][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][]\ - [][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][]", ., S64, S64) - - #undef S64 - #undef S16 - #undef S4 - #undef S1 - else - // Macros expand to long argument lists like so: ls[++i], ls[++i], ls[++i], etc... - #define S1 ls[++i] - #define S4 S1, S1, S1, S1 - #define S16 S4, S4, S4, S4 - #define S64 S16, S16, S16, S16 - - . = "[ls[++i]]" // Make sure the initial element is converted to text. - - if (l-1 & 0x01) // 'i' will always be 1 here. - . += S1 // Append 1 element if the remaining elements are not a multiple of 2. - if (l-i & 0x02) - . = text("[][][]", ., S1, S1) // Append 2 elements if the remaining elements are not a multiple of 4. - if (l-i & 0x04) - . = text("[][][][][]", ., S4) // And so on... - if (l-i & 0x08) - . = text("[][][][][][][][][]", ., S4, S4) - if (l-i & 0x10) - . = text("[][][][][][][][][][][][][][][][][]", ., S16) - if (l-i & 0x20) - . = text("[][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][]", ., S16, S16) - if (l-i & 0x40) - . = text("[][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][]\ - [][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][]", ., S64) - while (l > i) // Chomp through the rest of the list, 128 elements at a time. - . = text("[][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][]\ - [][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][]\ - [][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][]\ - [][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][]", ., S64, S64) - - #undef S64 - #undef S16 - #undef S4 - #undef S1 - -// Converts a string into a list by splitting the string at each delimiter found. (discarding the seperator) -/proc/splittext(text, delimiter="\n") - var/delim_len = length(delimiter) - if (delim_len < 1) - return list(text) - - . = list() - var/last_found = 1 - var/found - - do - found = findtext(text, delimiter, last_found, 0) - . += copytext(text, last_found, found) - last_found = found + delim_len - while (found) -#endif \ No newline at end of file diff --git a/code/global.dm b/code/global.dm index f7ae9d6c96..c542121b44 100644 --- a/code/global.dm +++ b/code/global.dm @@ -1,7 +1,4 @@ //#define TESTING -#if DM_VERSION < 506 -#warn This compiler is out of date. You may experience issues with projectile animations. -#endif // Items that ask to be called every cycle. var/global/datum/datacore/data_core = null diff --git a/polaris.dme b/polaris.dme index a48906d045..40e268cca9 100644 --- a/polaris.dme +++ b/polaris.dme @@ -20,7 +20,6 @@ #include "code\stylesheet.dm" #include "code\world.dm" #include "code\__datastructures\globals.dm" -#include "code\__defines\__513_compatibility.dm" #include "code\__defines\_compile_options.dm" #include "code\__defines\_lists.dm" #include "code\__defines\_planes+layers.dm" @@ -86,11 +85,6 @@ #include "code\__defines\dcs\flags.dm" #include "code\__defines\dcs\helpers.dm" #include "code\__defines\dcs\signals.dm" -#include "code\_compatibility\509\_JSON.dm" -#include "code\_compatibility\509\JSON Reader.dm" -#include "code\_compatibility\509\JSON Writer.dm" -#include "code\_compatibility\509\text.dm" -#include "code\_compatibility\509\type2type.dm" #include "code\_global_vars\bitfields.dm" #include "code\_global_vars\misc.dm" #include "code\_global_vars\mobs.dm"