From 436fb42f5eacbc735950504752a66daffebd80f5 Mon Sep 17 00:00:00 2001 From: spookydonut Date: Sat, 26 Oct 2019 15:56:54 +0800 Subject: [PATCH] Adds more 513 compat stuff (#47230) * Adds more 513 compat stuff * tan * ooops casing --- code/__DEFINES/is_helpers.dm | 6 ++++++ code/__DEFINES/maths.dm | 8 ++++++++ 2 files changed, 14 insertions(+) diff --git a/code/__DEFINES/is_helpers.dm b/code/__DEFINES/is_helpers.dm index fe19b6ca672..0e17b4d47bf 100644 --- a/code/__DEFINES/is_helpers.dm +++ b/code/__DEFINES/is_helpers.dm @@ -1,10 +1,16 @@ // 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)) diff --git a/code/__DEFINES/maths.dm b/code/__DEFINES/maths.dm index 5bce51293fe..f288b4abd4c 100644 --- a/code/__DEFINES/maths.dm +++ b/code/__DEFINES/maths.dm @@ -30,7 +30,11 @@ // 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))) ) @@ -39,7 +43,11 @@ #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))