From 94174c5867f8fcbfa88bbf4e1261b3b1952fa806 Mon Sep 17 00:00:00 2001 From: Doubleumc Date: Wed, 8 May 2024 22:53:32 -0400 Subject: [PATCH] initial --- code/__DEFINES/_math.dm | 7 ------- code/__HELPERS/_time.dm | 6 +++--- code/modules/shuttle/docking.dm | 2 +- code/modules/vehicles/hardpoints/hardpoint.dm | 2 +- 4 files changed, 5 insertions(+), 12 deletions(-) diff --git a/code/__DEFINES/_math.dm b/code/__DEFINES/_math.dm index d7c068237987..873254bf47a5 100644 --- a/code/__DEFINES/_math.dm +++ b/code/__DEFINES/_math.dm @@ -19,19 +19,12 @@ // round() acts like floor(x, 1) by default but can't handle other values #define FLOOR(x, y) ( round((x) / (y)) * (y) ) -// Real modulus that handles decimals -#define MODULUS(x, y) ( (x) - (y) * round((x) / (y)) ) - // Returns true if val is from min to max, inclusive. #define ISINRANGE(val, min, max) ((min) <= (val) && (val) <= (max)) // Same as above, exclusive. #define ISINRANGE_EX(val, min, max) ((min) < (val) && (val) < (max)) -// Will filter out extra rotations and negative rotations -// E.g: 540 becomes 180. -180 becomes 180. -#define SIMPLIFY_DEGREES(degrees) (MODULUS((degrees), 360)) - /// Gets the sign of x, returns -1 if negative, 0 if 0, 1 if positive #define SIGN(x) ( ((x) > 0) - ((x) < 0) ) diff --git a/code/__HELPERS/_time.dm b/code/__HELPERS/_time.dm index 733ca659501b..97e039fa7876 100644 --- a/code/__HELPERS/_time.dm +++ b/code/__HELPERS/_time.dm @@ -92,21 +92,21 @@ GLOBAL_VAR_INIT(rollovercheck_last_timeofday, 0) if(second < 60) return "[second] second[(second != 1)? "s":""]" var/minute = Floor(second / 60) - second = FLOOR(MODULUS(second, 60), round_seconds_to) + second = FLOOR(second %% 60, round_seconds_to) var/secondT if(second) secondT = " and [second] second[(second != 1)? "s":""]" if(minute < 60) return "[minute] minute[(minute != 1)? "s":""][secondT]" var/hour = Floor(minute / 60) - minute = MODULUS(minute, 60) + minute = minute %% 60 var/minuteT if(minute) minuteT = " and [minute] minute[(minute != 1)? "s":""]" if(hour < 24) return "[hour] hour[(hour != 1)? "s":""][minuteT][secondT]" var/day = Floor(hour / 24) - hour = MODULUS(hour, 24) + hour = hour %% 24 var/hourT if(hour) hourT = " and [hour] hour[(hour != 1)? "s":""]" diff --git a/code/modules/shuttle/docking.dm b/code/modules/shuttle/docking.dm index 63e220deadc6..bb9feeb3c04e 100644 --- a/code/modules/shuttle/docking.dm +++ b/code/modules/shuttle/docking.dm @@ -41,7 +41,7 @@ rotation = dir2angle(new_dock.dir)-dir2angle(dir) if ((rotation % 90) != 0) rotation += (rotation % 90) //diagonal rotations not allowed, round up - rotation = SIMPLIFY_DEGREES(rotation) + rotation = rotation %% 360 if(!movement_direction) movement_direction = turn(preferred_direction, 180) diff --git a/code/modules/vehicles/hardpoints/hardpoint.dm b/code/modules/vehicles/hardpoints/hardpoint.dm index 9b69308a47a0..a402df12441e 100644 --- a/code/modules/vehicles/hardpoints/hardpoint.dm +++ b/code/modules/vehicles/hardpoints/hardpoint.dm @@ -696,7 +696,7 @@ if(muzzle_turf == target_turf) return FALSE - var/angle_diff = SIMPLIFY_DEGREES(dir2angle(dir) - Get_Angle(muzzle_turf, target_turf)) + var/angle_diff = (dir2angle(dir) - Get_Angle(muzzle_turf, target_turf)) %% 360 if(angle_diff < -180) angle_diff += 360 else if(angle_diff > 180)