From 3a494e3a851d2e60400ae3cdc09b813ce7e72ea4 Mon Sep 17 00:00:00 2001 From: Putnam Date: Thu, 26 Mar 2020 19:50:13 -0700 Subject: [PATCH] Fixes an exploit involving WRAP. --- code/__DEFINES/maths.dm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/code/__DEFINES/maths.dm b/code/__DEFINES/maths.dm index 939f6698cb..b8a6ae1419 100644 --- a/code/__DEFINES/maths.dm +++ b/code/__DEFINES/maths.dm @@ -30,7 +30,7 @@ #define FLOOR(x, y) ( round((x) / (y)) * (y) ) // 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))) ) +#define WRAP(val, min, max) CLAMP(( min == max ? min : (val) - (round(((val) - (min))/((max) - (min))) * ((max) - (min))) ),min,max-1) // Real modulus that handles decimals #define MODULUS(x, y) ( (x) - (y) * round((x) / (y)) ) @@ -201,4 +201,4 @@ #define RULE_OF_THREE(a, b, x) ((a*x)/b) // ) -#define MANHATTAN_DISTANCE(a, b) (abs(a.x - b.x) + abs(a.y - b.y)) \ No newline at end of file +#define MANHATTAN_DISTANCE(a, b) (abs(a.x - b.x) + abs(a.y - b.y))