From e55da2f9582a48ead2e1c0f6dedac9e7abb9ff29 Mon Sep 17 00:00:00 2001 From: kevinz000 <2003111+kevinz000@users.noreply.github.com> Date: Sun, 27 Oct 2019 16:28:21 -0700 Subject: [PATCH 1/3] BYOND 513 --- code/__DEFINES/__513_compatibility.dm | 30 +++++++++++++++++++++++++++ code/__DEFINES/is_helpers.dm | 6 +----- code/__DEFINES/maths.dm | 10 +-------- code/__HELPERS/_lists.dm | 4 ++-- tgstation.dme | 1 + 5 files changed, 35 insertions(+), 16 deletions(-) create mode 100644 code/__DEFINES/__513_compatibility.dm diff --git a/code/__DEFINES/__513_compatibility.dm b/code/__DEFINES/__513_compatibility.dm new file mode 100644 index 0000000000..582fb6ee68 --- /dev/null +++ b/code/__DEFINES/__513_compatibility.dm @@ -0,0 +1,30 @@ + +#if DM_VERSION < 513 + +#define ismovableatom(A) ismovable(A) + +#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)) + +////////////////////////////////////////////////// + +#else + +#define ismovableatom(A) (istype(A, /atom/movable)) + +#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 diff --git a/code/__DEFINES/is_helpers.dm b/code/__DEFINES/is_helpers.dm index 9f69da0154..0dee8bd1e8 100644 --- a/code/__DEFINES/is_helpers.dm +++ b/code/__DEFINES/is_helpers.dm @@ -1,11 +1,7 @@ // simple is_type and similar inline helpers -#define islist(L) (istype(L, /list)) - #define in_range(source, user) (get_dist(source, user) <= 1 && (get_step(source, 0)?:z) == (get_step(user, 0)?:z)) -#define ismovableatom(A) (istype(A, /atom/movable)) - #define isatom(A) (isloc(A)) #define isweakref(D) (istype(D, /datum/weakref)) @@ -246,4 +242,4 @@ GLOBAL_LIST_INIT(glass_sheet_types, typecacheof(list( #define isblobmonster(O) (istype(O, /mob/living/simple_animal/hostile/blob)) -#define isshuttleturf(T) (length(T.baseturfs) && (/turf/baseturf_skipover/shuttle in T.baseturfs)) +#define isshuttleturf(T) (length(T.baseturfs) && (/turf/baseturf_skipover/shuttle in T.baseturfs)) \ No newline at end of file diff --git a/code/__DEFINES/maths.dm b/code/__DEFINES/maths.dm index 5bce51293f..ad93dd2d54 100644 --- a/code/__DEFINES/maths.dm +++ b/code/__DEFINES/maths.dm @@ -16,7 +16,6 @@ #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)) //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,17 +29,12 @@ // round() acts like floor(x, 1) by default but can't handle other values #define FLOOR(x, y) ( round((x) / (y)) * (y) ) -#define CLAMP(CLVALUE,CLMIN,CLMAX) ( max( (CLMIN), min((CLVALUE), (CLMAX)) ) ) - // 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 -#define TAN(x) (sin(x) / cos(x)) - // Cotangent #define COT(x) (1 / TAN(x)) @@ -50,8 +44,6 @@ // Cosecant #define CSC(x) (1 / sin(x)) -#define ATAN2(x, y) ( !(x) && !(y) ? 0 : (y) >= 0 ? arccos((x) / sqrt((x)*(x) + (y)*(y))) : -arccos((x) / sqrt((x)*(x) + (y)*(y))) ) - // Greatest Common Divisor - Euclid's algorithm /proc/Gcd(a, b) return b ? Gcd(b, (a) % (b)) : a @@ -207,4 +199,4 @@ #define LORENTZ_CUMULATIVE_DISTRIBUTION(x, y, s) ( (1/PI)*TORADIANS(arctan((x-y)/s)) + 1/2 ) #define RULE_OF_THREE(a, b, x) ((a*x)/b) -// ) +// ) \ No newline at end of file diff --git a/code/__HELPERS/_lists.dm b/code/__HELPERS/_lists.dm index fed283adcd..38b779427c 100644 --- a/code/__HELPERS/_lists.dm +++ b/code/__HELPERS/_lists.dm @@ -514,7 +514,7 @@ used_key_list[input_key] = 1 return input_key -#if DM_VERSION > 512 +#if DM_VERSION > 513 #error Remie said that lummox was adding a way to get a lists #error contents via list.values, if that is true remove this #error otherwise, update the version and bug lummox @@ -564,4 +564,4 @@ if(key in L1) L1[key] += other_value else - L1[key] = other_value + L1[key] = other_value \ No newline at end of file diff --git a/tgstation.dme b/tgstation.dme index 3daee9d346..548bbf2ffc 100755 --- a/tgstation.dme +++ b/tgstation.dme @@ -16,6 +16,7 @@ #include "_maps\_basemap.dm" #include "code\_compile_options.dm" #include "code\world.dm" +#include "code\__DEFINES\__513_compatibility.dm" #include "code\__DEFINES\_globals.dm" #include "code\__DEFINES\_protect.dm" #include "code\__DEFINES\_tick.dm" From dc0fa95bd9a750c489860723a564cc823f96e6b8 Mon Sep 17 00:00:00 2001 From: kevinz000 <2003111+kevinz000@users.noreply.github.com> Date: Sun, 27 Oct 2019 16:29:33 -0700 Subject: [PATCH 2/3] missed a spot --- code/__HELPERS/unsorted.dm | 4 ---- 1 file changed, 4 deletions(-) diff --git a/code/__HELPERS/unsorted.dm b/code/__HELPERS/unsorted.dm index ce294f3749..27b70d28c5 100644 --- a/code/__HELPERS/unsorted.dm +++ b/code/__HELPERS/unsorted.dm @@ -451,10 +451,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) -/proc/arctan(x) - var/y=arcsin(x/sqrt(1+x*x)) - return y - /* Gets all contents of contents and returns them all in a list. */ From 2a80c9a0a3154c89bd6c75fea5b214cb3e593b85 Mon Sep 17 00:00:00 2001 From: kevinz000 <2003111+kevinz000@users.noreply.github.com> Date: Sun, 27 Oct 2019 17:10:34 -0700 Subject: [PATCH 3/3] missed a spot redux --- code/__DEFINES/__513_compatibility.dm | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/code/__DEFINES/__513_compatibility.dm b/code/__DEFINES/__513_compatibility.dm index 582fb6ee68..12577fb68b 100644 --- a/code/__DEFINES/__513_compatibility.dm +++ b/code/__DEFINES/__513_compatibility.dm @@ -1,7 +1,7 @@ #if DM_VERSION < 513 -#define ismovableatom(A) ismovable(A) +#define ismovableatom(A) (istype(A, /atom/movable)) #define islist(L) (istype(L, /list)) @@ -13,11 +13,13 @@ #define TAN(x) (sin(x) / cos(x)) +#define arctan(x) (arcsin(x/sqrt(1+x*x))) + ////////////////////////////////////////////////// #else -#define ismovableatom(A) (istype(A, /atom/movable)) +#define ismovableatom(A) ismovable(A) #define CLAMP01(x) clamp(x, 0, 1)