diff --git a/code/__DEFINES/flags.dm b/code/__DEFINES/flags.dm index d24591c1c99..4cf19b1be17 100644 --- a/code/__DEFINES/flags.dm +++ b/code/__DEFINES/flags.dm @@ -191,3 +191,17 @@ GLOBAL_LIST_INIT(bitflags, list(1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 204 // This skillchip is incompatible with the Chameleon skillchip and cannot be copied. // If you want to blacklist an abstract path such a /obj/item/skillchip/job then look at the blacklist in /datum/action/item_action/chameleon/change/skillchip #define SKILLCHIP_CHAMELEON_INCOMPATIBLE (1<<2) + +//dir macros +///Returns true if the dir is diagonal, false otherwise +#define ISDIAGONALDIR(d) (d&(d-1)) +///True if the dir is north or south, false therwise +#define NSCOMPONENT(d) (d&(NORTH|SOUTH)) +///True if the dir is east/west, false otherwise +#define EWCOMPONENT(d) (d&(EAST|WEST)) +///Flips the dir for north/south directions +#define NSDIRFLIP(d) (d^(NORTH|SOUTH)) +///Flips the dir for east/west directions +#define EWDIRFLIP(d) (d^(EAST|WEST)) +///Turns the dir by 180 degrees +#define DIRFLIP(d) turn(d, 180) diff --git a/code/__HELPERS/unsorted.dm b/code/__HELPERS/unsorted.dm index 1c4ba96947f..afb75cf1668 100644 --- a/code/__HELPERS/unsorted.dm +++ b/code/__HELPERS/unsorted.dm @@ -359,7 +359,7 @@ Turf and target are separate in case you want to teleport some distance from a t x = world.maxx else if(direction & WEST) x = 1 - if(direction in GLOB.diagonals) //let's make sure it's accurately-placed for diagonals + if(ISDIAGONALDIR(direction)) //let's make sure it's accurately-placed for diagonals var/lowest_distance_to_map_edge = min(abs(x - A.x), abs(y - A.y)) return get_ranged_target_turf(A, direction, lowest_distance_to_map_edge) return locate(x,y,A.z) diff --git a/code/game/machinery/pipe/construction.dm b/code/game/machinery/pipe/construction.dm index 66b196c192f..2541d2e3e7b 100644 --- a/code/game/machinery/pipe/construction.dm +++ b/code/game/machinery/pipe/construction.dm @@ -119,7 +119,7 @@ Buildable meters /obj/item/pipe/trinary/flippable/fixed_dir() . = dir - if(dir in GLOB.diagonals) + if(ISDIAGONALDIR(dir)) . = turn(dir, 45) /obj/item/pipe/attack_self(mob/user) diff --git a/code/game/objects/effects/temporary_visuals/miscellaneous.dm b/code/game/objects/effects/temporary_visuals/miscellaneous.dm index 37dc0c01981..2b2af0b9a1f 100644 --- a/code/game/objects/effects/temporary_visuals/miscellaneous.dm +++ b/code/game/objects/effects/temporary_visuals/miscellaneous.dm @@ -7,7 +7,7 @@ var/splatter_type = "splatter" /obj/effect/temp_visual/dir_setting/bloodsplatter/Initialize(mapload, set_dir) - if(set_dir in GLOB.diagonals) + if(ISDIAGONALDIR(set_dir)) icon_state = "[splatter_type][pick(1, 2, 6)]" else icon_state = "[splatter_type][pick(3, 4, 5)]" diff --git a/code/game/objects/items/RPD.dm b/code/game/objects/items/RPD.dm index c71e8548763..e07a083f39a 100644 --- a/code/game/objects/items/RPD.dm +++ b/code/game/objects/items/RPD.dm @@ -123,7 +123,7 @@ GLOBAL_LIST_INIT(transit_tube_recipes, list( var/i = 0 for(var/dir in dirs) var/numdir = text2num(dir) - var/flipped = ((dirtype == PIPE_TRIN_M) || (dirtype == PIPE_UNARY_FLIPPABLE)) && (numdir in GLOB.diagonals) + var/flipped = ((dirtype == PIPE_TRIN_M) || (dirtype == PIPE_UNARY_FLIPPABLE)) && (ISDIAGONALDIR(numdir)) row["previews"] += list(list("selected" = (numdir == selected_dir), "dir" = dir2text(numdir), "dir_name" = dirs[dir], "icon_state" = icon_state, "flipped" = flipped)) if(i++ || dirtype == PIPE_ONEDIR) rows += list(row) diff --git a/code/game/objects/structures/transit_tubes/transit_tube.dm b/code/game/objects/structures/transit_tubes/transit_tube.dm index 13d662f7981..2669d12f1b5 100644 --- a/code/game/objects/structures/transit_tubes/transit_tube.dm +++ b/code/game/objects/structures/transit_tubes/transit_tube.dm @@ -130,7 +130,7 @@ /obj/structure/transit_tube/proc/generate_tube_overlays() for(var/direction in tube_dirs) - if(direction in GLOB.diagonals) + if(ISDIAGONALDIR(direction)) if(direction & NORTH) create_tube_overlay(direction ^ 3, NORTH) diff --git a/code/modules/atmospherics/machinery/pipes/heat_exchange/simple.dm b/code/modules/atmospherics/machinery/pipes/heat_exchange/simple.dm index c5304c3416e..7e1014a45a5 100644 --- a/code/modules/atmospherics/machinery/pipes/heat_exchange/simple.dm +++ b/code/modules/atmospherics/machinery/pipes/heat_exchange/simple.dm @@ -15,7 +15,7 @@ pipe_state = "he" /obj/machinery/atmospherics/pipe/heat_exchanging/simple/SetInitDirections() - if(dir in GLOB.diagonals) + if(ISDIAGONALDIR(dir)) initialize_directions = dir return switch(dir) diff --git a/code/modules/atmospherics/machinery/pipes/simple.dm b/code/modules/atmospherics/machinery/pipes/simple.dm index 0450c7eebcb..2ee4c28fb86 100644 --- a/code/modules/atmospherics/machinery/pipes/simple.dm +++ b/code/modules/atmospherics/machinery/pipes/simple.dm @@ -18,7 +18,7 @@ pipe_state = "simple" /obj/machinery/atmospherics/pipe/simple/SetInitDirections() - if(dir in GLOB.diagonals) + if(ISDIAGONALDIR(dir)) initialize_directions = dir return switch(dir) diff --git a/code/modules/mob/living/simple_animal/bot/bot.dm b/code/modules/mob/living/simple_animal/bot/bot.dm index 866b5536e33..c6ad63a609b 100644 --- a/code/modules/mob/living/simple_animal/bot/bot.dm +++ b/code/modules/mob/living/simple_animal/bot/bot.dm @@ -1041,7 +1041,7 @@ Pass a positive integer as an argument to override a bot's default speed. var/turf/prevprevT = path[i - 2] var/prevDir = get_dir(prevprevT, prevT) var/mixDir = direction|prevDir - if(mixDir in GLOB.diagonals) + if(ISDIAGONALDIR(mixDir)) prevI.dir = mixDir if(prevDir & (NORTH|SOUTH)) var/matrix/ntransform = matrix() diff --git a/code/modules/mob/living/simple_animal/hostile/hostile.dm b/code/modules/mob/living/simple_animal/hostile/hostile.dm index cf1aaa19609..78cfbb89214 100644 --- a/code/modules/mob/living/simple_animal/hostile/hostile.dm +++ b/code/modules/mob/living/simple_animal/hostile/hostile.dm @@ -456,7 +456,7 @@ EscapeConfinement() var/dir_to_target = get_dir(targets_from, target) var/dir_list = list() - if(dir_to_target in GLOB.diagonals) //it's diagonal, so we need two directions to hit + if(ISDIAGONALDIR(dir_to_target)) //it's diagonal, so we need two directions to hit for(var/direction in GLOB.cardinals) if(direction & dir_to_target) dir_list += direction diff --git a/code/modules/projectiles/projectile/special/hallucination.dm b/code/modules/projectiles/projectile/special/hallucination.dm index 6cff523dc4f..918ce629ebc 100644 --- a/code/modules/projectiles/projectile/special/hallucination.dm +++ b/code/modules/projectiles/projectile/special/hallucination.dm @@ -66,7 +66,7 @@ return var/splatter_icon_state - if(set_dir in GLOB.diagonals) + if(ISDIAGONALDIR(set_dir)) splatter_icon_state = "splatter[pick(1, 2, 6)]" else splatter_icon_state = "splatter[pick(3, 4, 5)]" diff --git a/code/modules/recycling/conveyor2.dm b/code/modules/recycling/conveyor2.dm index a0ba085e18c..63d1c874f35 100644 --- a/code/modules/recycling/conveyor2.dm +++ b/code/modules/recycling/conveyor2.dm @@ -31,7 +31,7 @@ GLOBAL_LIST_EMPTY(conveyors_by_id) /obj/machinery/conveyor/inverted/Initialize(mapload) . = ..() - if(mapload && !(dir in GLOB.diagonals)) + if(mapload && !(ISDIAGONALDIR(dir))) log_mapping("[src] at [AREACOORD(src)] spawned without using a diagonal dir. Please replace with a normal version.") // Auto conveyour is always on unless unpowered diff --git a/code/modules/recycling/disposal/construction.dm b/code/modules/recycling/disposal/construction.dm index a548e699b6a..334988b9b23 100644 --- a/code/modules/recycling/disposal/construction.dm +++ b/code/modules/recycling/disposal/construction.dm @@ -71,7 +71,7 @@ var/initialize_dirs = initial(temp.initialize_dirs) var/dpdir = NONE - if(dir in GLOB.diagonals) // Bent pipes + if(ISDIAGONALDIR(dir)) // Bent pipes return dir if(initialize_dirs != DISP_DIR_NONE) @@ -93,7 +93,7 @@ if(rotation_type == ROTATION_FLIP) var/obj/structure/disposalpipe/temp = pipe_type if(initial(temp.flip_type)) - if(dir in GLOB.diagonals) // Fix RPD-induced diagonal turning + if(ISDIAGONALDIR(dir)) // Fix RPD-induced diagonal turning setDir(turn(dir, 45)) pipe_type = initial(temp.flip_type) update_icon() diff --git a/code/modules/recycling/disposal/pipe.dm b/code/modules/recycling/disposal/pipe.dm index 720c29a0ff5..da2b326c61a 100644 --- a/code/modules/recycling/disposal/pipe.dm +++ b/code/modules/recycling/disposal/pipe.dm @@ -29,7 +29,7 @@ else stored = new /obj/structure/disposalconstruct(src, null , SOUTH , FALSE , src) - if(dir in GLOB.diagonals) // Bent pipes already have all the dirs set + if(ISDIAGONALDIR(dir)) // Bent pipes already have all the dirs set initialize_dirs = NONE if(initialize_dirs != DISP_DIR_NONE)