Skip to content

Commit

Permalink
initial
Browse files Browse the repository at this point in the history
  • Loading branch information
Doubleumc committed May 9, 2024
1 parent 92655a0 commit 94174c5
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 12 deletions.
7 changes: 0 additions & 7 deletions code/__DEFINES/_math.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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) )

Expand Down
6 changes: 3 additions & 3 deletions code/__HELPERS/_time.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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":""]"
Expand Down
2 changes: 1 addition & 1 deletion code/modules/shuttle/docking.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion code/modules/vehicles/hardpoints/hardpoint.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 94174c5

Please sign in to comment.