[MIRROR] Implements usage of the REVERSE_DIR macro throughout the code. [MDB IGNORE] (#22743)

* Implements usage of the REVERSE_DIR macro throughout the code. (#77122)

## About The Pull Request
Replaces a ton of `turn(dir, 180)` calls with the aforementioned macro.

## Why It's Good For The Game
Afaik, `REVERSE_DIR` was coded to be faster than the classic `turn(dir,
180)` call, being a simple set of binary operations. To sum it up, micro
optimization.

## Changelog

N/A

* Implements usage of the REVERSE_DIR macro throughout the code.

---------

Co-authored-by: Ghom <42542238+Ghommie@users.noreply.github.com>
This commit is contained in:
SkyratBot
2023-07-28 14:32:01 -04:00
committed by GitHub
co-authored by Ghom
parent 5a49aaf8f6
commit 7b4237c692
65 changed files with 108 additions and 111 deletions
+12
View File
@@ -13,6 +13,18 @@
/// West direction as a string "[8]"
#define TEXT_WEST "[WEST]"
//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))
/// Inverse direction, taking into account UP|DOWN if necessary.
#define REVERSE_DIR(dir) ( ((dir & 85) << 1) | ((dir & 170) >> 1) )
-15
View File
@@ -255,20 +255,6 @@ GLOBAL_LIST_INIT(bitflags, list(1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 204
// This skillchip is incompatible with other skillchips from the incompatible_category list.
#define SKILLCHIP_RESTRICTED_CATEGORIES (1<<1)
//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)
#define MAX_BITFIELD_SIZE 24
/// 33554431 (2^24 - 1) is the maximum value our bitflags can reach.
@@ -286,7 +272,6 @@ GLOBAL_LIST_INIT(bitflags, list(1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 204
/// Used to prevent important slowdowns from being abused by drugs like kronkaine
#define IGNORE_SLOWDOWNS (1<<4)
// Spacevine-related flags
/// Is the spacevine / flower bud heat resistant
#define SPACEVINE_HEAT_RESISTANT (1 << 0)
+2 -2
View File
@@ -30,9 +30,9 @@ GLOBAL_LIST_INIT(typecache_powerfailure_safe_areas, typecacheof(/area/station/en
if(!checkT)
continue
checked_turfs[sourceT] |= dir
checked_turfs[checkT] |= turn(dir, 180)
checked_turfs[checkT] |= REVERSE_DIR(dir)
.[sourceT] |= dir
.[checkT] |= turn(dir, 180)
.[checkT] |= REVERSE_DIR(dir)
if(break_if_found[checkT.type] || break_if_found[checkT.loc.type])
return FALSE
var/static/list/cardinal_cache = list("[NORTH]"=TRUE, "[EAST]"=TRUE, "[SOUTH]"=TRUE, "[WEST]"=TRUE)
+3 -3
View File
@@ -85,7 +85,7 @@ xxx xxx xxx
for(var/dir in cardinals)
var/left = turn(dir, 90)
var/right = turn(dir, -90)
var/opposite = turn(dir, 180)
var/opposite = REVERSE_DIR(dir)
// Need to encode diagonals here because it's possible, even if it is always false
var/list/acceptable_adjacents = new /list(largest_dir)
// Alright, what directions are acceptable to us
@@ -123,7 +123,7 @@ xxx xxx xxx
#define CAN_DIAGONAL_SMOOTH(border_obj, target, direction) (\
(target.smoothing_flags & SMOOTH_BORDER_OBJECT) ? \
GLOB.adjacent_direction_lookup[border_obj.dir][direction + 1]?[target.dir] : \
(GLOB.adjacent_direction_lookup[border_obj.dir][direction + 1]) ? turn(direction, 180) : NONE \
(GLOB.adjacent_direction_lookup[border_obj.dir][direction + 1]) ? REVERSE_DIR(direction) : NONE \
)
#define DEFAULT_UNDERLAY_ICON 'icons/turf/floors.dmi'
@@ -412,7 +412,7 @@ xxx xxx xxx
break set_adj_in_dir; \
/// Check that non border objects use to smooth against border objects
/// Returns true if the smooth is acceptable, FALSE otherwise
#define BITMASK_ON_BORDER_CHECK(target, direction) (!(target.smoothing_flags & SMOOTH_BORDER_OBJECT) || CAN_DIAGONAL_SMOOTH(target, src, turn(direction, 180)))
#define BITMASK_ON_BORDER_CHECK(target, direction) (!(target.smoothing_flags & SMOOTH_BORDER_OBJECT) || CAN_DIAGONAL_SMOOTH(target, src, REVERSE_DIR(direction)))
#define BORDER_FOUND(target, direction, direction_flag) new_junction |= CAN_DIAGONAL_SMOOTH(src, target, direction)
// Border objects require an object as context, so we need a dummy. I'm sorry
+2 -2
View File
@@ -217,7 +217,7 @@
for(var/obj/machinery/duct/duct in get_step(parent, direction))
if(!(duct.duct_layer & ducting_layer))
continue
duct.remove_connects(turn(direction, 180))
duct.remove_connects(REVERSE_DIR(direction))
duct.neighbours.Remove(parent)
duct.update_appearance()
@@ -302,7 +302,7 @@
/datum/component/plumbing/proc/direct_connect(datum/component/plumbing/plumbing, dir)
if(!plumbing.active)
return
var/opposite_dir = turn(dir, 180)
var/opposite_dir = REVERSE_DIR(dir)
if(plumbing.demand_connects & opposite_dir && supply_connects & dir || plumbing.supply_connects & opposite_dir && demand_connects & dir) //make sure we arent connecting two supplies or demands
var/datum/ductnet/net = new()
net.add_plumber(src, dir)
+2 -2
View File
@@ -142,11 +142,11 @@
var/side_dir = hyperloop.direction - direction
if(is_tile_solid(get_step(clinger, side_dir)))
hyperloop.direction = direction + turn(side_dir, 180) //We're bumping a wall to the side, so switch to the other side_dir (yes this adds pingpong protocol)
hyperloop.direction = direction + REVERSE_DIR(side_dir) //We're bumping a wall to the side, so switch to the other side_dir (yes this adds pingpong protocol)
return
//Get the directions from the side of our current drift direction (so if we have drift south, get all cardinals and remove north and south, leaving only east and west)
var/side_dirs = shuffle(GLOB.cardinals - direction - turn(direction, 180))
var/side_dirs = shuffle(GLOB.cardinals - direction - REVERSE_DIR(direction))
//We check if one side is solid
if(!is_tile_solid(get_step(clinger, side_dirs[1])))
@@ -59,7 +59,7 @@
affected_mob.emote("sneeze")
to_chat(affected_mob, span_userdanger("You are launched violently backwards by an all-mighty sneeze!"))
var/sneeze_distance = rand(2,4) //twice as far as a normal baseball bat strike will fling you
var/turf/target = get_ranged_target_turf(affected_mob, turn(affected_mob.dir, 180), sneeze_distance)
var/turf/target = get_ranged_target_turf(affected_mob, REVERSE_DIR(affected_mob.dir), sneeze_distance)
affected_mob.throw_at(target, sneeze_distance, rand(1,4)) //with the wounds update, sneezing at 7 speed was causing peoples bones to spontaneously explode, turning cartoonish sneezing into a nightmarishly lethal GBS 2.0 outbreak
else if(COOLDOWN_FINISHED(src, sneeze_cooldown) || !COOLDOWN_FINISHED(src, sneeze_cooldown) && prob(60) && !off_cooldown_sneezed)
affected_mob.emote("sneeze")
+1 -1
View File
@@ -67,7 +67,7 @@
if(throwee.anchored && !throw_anchored)
return
if(throw_distance < 0)
throw_dir = turn(throw_dir, 180)
throw_dir = REVERSE_DIR(throw_dir)
throw_distance *= -1
var/atom/throw_target = get_edge_target_turf(throwee, throw_dir)
throwee.safe_throw_at(throw_target, throw_distance, 1, thrower, gentle = throw_gentle)
+1 -1
View File
@@ -131,7 +131,7 @@
/datum/merger/proc/check_turf(turf/location, list/found_turfs, asking_from)
var/found_something = FALSE
// if asking_from is invalid (like if it's 0), we get a random output. that's bad, let's check for falsyness
var/us_to_them = asking_from && turn(asking_from, 180)
var/us_to_them = asking_from && REVERSE_DIR(asking_from)
if(found_turfs[location])
found_turfs[location][MERGE_TURF_PACKET_DIR] |= us_to_them
+1 -1
View File
@@ -90,7 +90,7 @@
owner.emote("cough")
if(GET_MUTATION_POWER(src) > 1)
var/cough_range = GET_MUTATION_POWER(src) * 4
var/turf/target = get_ranged_target_turf(owner, turn(owner.dir, 180), cough_range)
var/turf/target = get_ranged_target_turf(owner, REVERSE_DIR(owner.dir), cough_range)
owner.throw_at(target, cough_range, GET_MUTATION_POWER(src))
/datum/mutation/human/paranoia
+1 -1
View File
@@ -67,7 +67,7 @@
// When casting, throw the caster backwards a few tiles.
var/original_dir = living_cast_on.dir
living_cast_on.throw_at(
get_edge_target_turf(living_cast_on, turn(living_cast_on.dir, 180)),
get_edge_target_turf(living_cast_on, REVERSE_DIR(living_cast_on.dir)),
range = self_throw_range,
speed = 2,
gentle = TRUE,
+1 -1
View File
@@ -148,7 +148,7 @@
if(WIRE_UNRESTRICTED_EXIT) // Pulse to switch the direction around by 180 degrees (North goes to South, East goes to West, vice-versa)
if(!A.unres_sensor) //only works if the "sensor" is installed (a variable that we assign to the door either upon creation of a door with unrestricted directions or if an unrestricted helper is added to a door in mapping)
return
A.unres_sides = DIRFLIP(A.unres_sides)
A.unres_sides = REVERSE_DIR(A.unres_sides)
A.update_appearance()
/obj/machinery/door/airlock/proc/reset_ai_wire()
+1 -1
View File
@@ -1010,7 +1010,7 @@
*/
/atom/proc/hitby_react(atom/movable/harmed_atom)
if(harmed_atom && isturf(harmed_atom.loc))
step(harmed_atom, turn(harmed_atom.dir, 180))
step(harmed_atom, REVERSE_DIR(harmed_atom.dir))
///Handle the atom being slipped over
/atom/proc/handle_slip(mob/living/carbon/slipped_carbon, knockdown_amount, obj/slipping_object, lube, paralyze, force_drop)
+1 -1
View File
@@ -417,7 +417,7 @@
/obj/machinery/door/window/unrestricted_side(mob/opener)
if(get_turf(opener) == loc)
return turn(dir,180) & unres_sides
return REVERSE_DIR(dir) & unres_sides
return ..()
/obj/machinery/door/window/try_to_crowbar(obj/item/I, mob/user, forced = FALSE)
+1 -1
View File
@@ -154,7 +154,7 @@ Buildable meters
do_a_flip()
/obj/item/pipe/proc/do_a_flip()
setDir(turn(dir, -180))
setDir(REVERSE_DIR(dir))
/obj/item/pipe/trinary/flippable/do_a_flip()
setDir(turn(dir, flipped ? 45 : -45))
+1 -1
View File
@@ -368,7 +368,7 @@
var/turf/T = loc
var/obj/machinery/power/shieldwallgen/G
var/steps = 0
var/opposite_direction = turn(direction, 180)
var/opposite_direction = REVERSE_DIR(direction)
for(var/i in 1 to shield_range) //checks out to 8 tiles away for another generator
T = get_step(T, direction)
+2 -2
View File
@@ -205,10 +205,10 @@
if(user.buckled && isobj(user.buckled) && !user.buckled.anchored)
var/obj/B = user.buckled
var/movementdirection = turn(direction,180)
var/movementdirection = REVERSE_DIR(direction)
addtimer(CALLBACK(src, TYPE_PROC_REF(/obj/item/extinguisher, move_chair), B, movementdirection), 1)
else
user.newtonian_move(turn(direction, 180))
user.newtonian_move(REVERSE_DIR(direction))
//Get all the turfs that can be shot at
var/turf/T = get_turf(target)
+1 -1
View File
@@ -208,7 +208,7 @@
return //If we've run out, display message and exit
else
last = null
last = loaded.place_turf(get_turf(src), user, turn(user.dir, 180))
last = loaded.place_turf(get_turf(src), user, REVERSE_DIR(user.dir))
is_empty(user) //If we've run out, display message
update_appearance()
+1 -1
View File
@@ -785,7 +785,7 @@ for further reading, please see: https://github.com/tgstation/tgstation/pull/301
angle = 270
if(target.dir & turn(target_to_user, 270))
angle = 90
if(target.dir & turn(target_to_user, 180))
if(target.dir & REVERSE_DIR(target_to_user))
angle = 180
if(target.dir & target_to_user)
angle = 360
+1 -1
View File
@@ -28,7 +28,7 @@
playsound(src, P.hitsound, 50, TRUE)
var/damage
if(!QDELETED(src)) //Bullet on_hit effect might have already destroyed this object
damage = take_damage(P.damage * P.demolition_mod, P.damage_type, P.armor_flag, 0, turn(P.dir, 180), P.armour_penetration)
damage = take_damage(P.damage * P.demolition_mod, P.damage_type, P.armor_flag, 0, REVERSE_DIR(P.dir), P.armour_penetration)
if(P.suppressed != SUPPRESSED_VERY)
visible_message(span_danger("[src] is hit by \a [P][damage ? "" : ", without leaving a mark"]!"), null, null, COMBAT_MESSAGE_RANGE)
+1 -1
View File
@@ -343,7 +343,7 @@ GLOBAL_LIST_EMPTY(objects_by_id_tag)
/obj/handle_ricochet(obj/projectile/P)
. = ..()
if(. && receive_ricochet_damage_coeff)
take_damage(P.damage * receive_ricochet_damage_coeff, P.damage_type, P.armor_flag, 0, turn(P.dir, 180), P.armour_penetration) // pass along receive_ricochet_damage_coeff damage to the structure for the ricochet
take_damage(P.damage * receive_ricochet_damage_coeff, P.damage_type, P.armor_flag, 0, REVERSE_DIR(P.dir), P.armour_penetration) // pass along receive_ricochet_damage_coeff damage to the structure for the ricochet
/// Handles exposing an object to reagents.
/obj/expose_reagents(list/reagents, datum/reagents/source, methods=TOUCH, volume_modifier=1, show_message=TRUE)
+1 -1
View File
@@ -140,7 +140,7 @@ LINEN BINS
// double check the canUseTopic args to make sure it's correct
if(!istype(user) || !user.can_perform_action(src, NEED_DEXTERITY))
return
dir = turn(dir, 180)
dir = REVERSE_DIR(dir)
/obj/item/bedsheet/blue
icon_state = "sheetblue"
+1 -1
View File
@@ -34,7 +34,7 @@
/// We're offset back into the wall, account for that
/obj/structure/fireplace/get_light_offset()
var/list/hand_back = ..()
var/list/dir_offset = dir2offset(turn(dir, 180))
var/list/dir_offset = dir2offset(REVERSE_DIR(dir))
hand_back[1] += dir_offset[1] * 0.5
hand_back[2] += dir_offset[2] * 0.5
return hand_back
@@ -182,7 +182,7 @@
tube_dirs = list(NORTH, SOUTH)
if(WEST)
tube_dirs = list(NORTH, SOUTH)
boarding_dir = turn(dir, 180)
boarding_dir = REVERSE_DIR(dir)
/obj/structure/transit_tube/station/flipped
@@ -212,7 +212,7 @@
tube_dirs = list(SOUTH)
if(WEST)
tube_dirs = list(NORTH)
boarding_dir = turn(dir, 180)
boarding_dir = REVERSE_DIR(dir)
/obj/structure/transit_tube/station/reverse/flipped
icon_state = "closed_terminus1"
@@ -291,7 +291,7 @@
tube_dirs = list(SOUTH)
if(WEST)
tube_dirs = list(NORTH)
boarding_dir = turn(dir, 180)
boarding_dir = REVERSE_DIR(dir)
/obj/structure/transit_tube/station/dispenser/reverse/flipped
icon_state = "open_terminusdispenser1"
@@ -61,7 +61,7 @@
/obj/structure/transit_tube/proc/has_entrance(from_dir)
from_dir = turn(from_dir, 180)
from_dir = REVERSE_DIR(from_dir)
for(var/direction in tube_dirs)
if(direction == from_dir)
@@ -154,7 +154,7 @@
var/obj/structure/transit_tube/TT = locate(/obj/structure/transit_tube) in loc
//landed on a turf without transit tube or not in our direction
if(!TT || (!(dir in TT.tube_dirs) && !(turn(dir,180) in TT.tube_dirs)))
if(!TT || (!(dir in TT.tube_dirs) && !(REVERSE_DIR(dir) in TT.tube_dirs)))
outside_tube()
/obj/structure/transit_tube_pod/proc/outside_tube()
@@ -187,7 +187,7 @@
for(var/obj/structure/transit_tube/station/station in loc)
if(station.pod_moving)
return
if(direction == turn(station.boarding_dir,180))
if(direction == REVERSE_DIR(station.boarding_dir))
if(station.open_status == STATION_TUBE_OPEN)
user.forceMove(loc)
update_appearance()
+1 -1
View File
@@ -44,7 +44,7 @@
return
if(!carbon_mob.density)
return
var/turf/checked_turf = get_step(carbon_mob, turn(carbon_mob.dir, 180))
var/turf/checked_turf = get_step(carbon_mob, REVERSE_DIR(carbon_mob.dir))
if(checked_turf == src)
carbon_mob.start_leaning(src)
+1 -1
View File
@@ -37,7 +37,7 @@
SIGNAL_HANDLER
if(enterer && !HAS_TRAIT(enterer, TRAIT_HYPERSPACED))
enterer.AddComponent(/datum/component/shuttle_cling, turn(dir, 180))
enterer.AddComponent(/datum/component/shuttle_cling, REVERSE_DIR(dir))
/turf/open/space/transit/proc/initialize_drifting_but_from_initialize(atom/movable/location, atom/movable/enterer, mapload)
SIGNAL_HANDLER
+1 -1
View File
@@ -142,7 +142,7 @@
for (var/S in SSshuttle.stationary_docking_ports)
var/obj/docking_port/stationary/SM = S
if (SM.shuttle_id == "emergency_home")
var/new_dir = turn(SM.dir, 180)
var/new_dir = REVERSE_DIR(SM.dir)
SM.forceMove(get_ranged_target_turf(SM, new_dir, crash_strength))
break
+1 -1
View File
@@ -126,7 +126,7 @@ GLOBAL_LIST_EMPTY(dirty_vars)
if(!(locate(/obj/structure/grille) in T))
var/window_check = 0
for(var/obj/structure/window/W in T)
if (W.dir == turn(C1.dir,180) || (W.dir in list(NORTHEAST,SOUTHEAST,NORTHWEST,SOUTHWEST)) )
if (W.dir == REVERSE_DIR(C1.dir) || (W.dir in list(NORTHEAST,SOUTHEAST,NORTHWEST,SOUTHWEST)) )
window_check = 1
break
if(!window_check)
@@ -16,7 +16,7 @@
initialize_directions = EAST|WEST
/obj/machinery/atmospherics/components/binary/get_node_connects()
return list(turn(dir, 180), dir)
return list(REVERSE_DIR(dir), dir)
/**
* Used by binary devices to set what the offset will be for each layer, called in update_icon_nopipes()
@@ -468,7 +468,7 @@
if(moderator_list[/datum/gas/bz] < (150 / power_level))
return
var/obj/machinery/hypertorus/corner/picked_corner = pick(corners)
picked_corner.loc.fire_nuclear_particle(turn(picked_corner.dir, 180))
picked_corner.loc.fire_nuclear_particle(REVERSE_DIR(picked_corner.dir))
/obj/machinery/atmospherics/components/unary/hypertorus/core/proc/check_lightning_arcs(moderator_list)
if(power_level < 4)
@@ -181,7 +181,7 @@
/obj/machinery/hypertorus/interface/multitool_act(mob/living/user, obj/item/I)
. = ..()
var/turf/T = get_step(src,turn(dir,180))
var/turf/T = get_step(src,REVERSE_DIR(dir))
var/obj/machinery/atmospherics/components/unary/hypertorus/core/centre = locate() in T
if(!centre || !centre.check_part_connectivity())
@@ -38,7 +38,7 @@
corners |= object
continue
if(get_step(object,turn(object.dir,180)) != loc)
if(get_step(object,REVERSE_DIR(object.dir)) != loc)
. = FALSE
if(istype(object,/obj/machinery/hypertorus/interface))
@@ -53,7 +53,7 @@
if(object.panel_open)
. = FALSE
if(get_step(object,turn(object.dir,180)) != loc)
if(get_step(object,REVERSE_DIR(object.dir)) != loc)
. = FALSE
if(istype(object,/obj/machinery/atmospherics/components/unary/hypertorus/fuel_input))
@@ -101,7 +101,7 @@
cut_overlays()
var/mutable_appearance/pipe_appearance1 = mutable_appearance('icons/obj/pipes_n_cables/pipe_underlays.dmi', "intact_[dir]_[piping_layer]", layer = GAS_SCRUBBER_LAYER)
pipe_appearance1.color = COLOR_LIME
var/mutable_appearance/pipe_appearance2 = mutable_appearance('icons/obj/pipes_n_cables/pipe_underlays.dmi', "intact_[turn(dir, 180)]_[piping_layer]", layer = GAS_SCRUBBER_LAYER)
var/mutable_appearance/pipe_appearance2 = mutable_appearance('icons/obj/pipes_n_cables/pipe_underlays.dmi', "intact_[REVERSE_DIR(dir)]_[piping_layer]", layer = GAS_SCRUBBER_LAYER)
pipe_appearance2.color = COLOR_MOSTLY_PURE_RED
. += pipe_appearance1
. += pipe_appearance2
@@ -40,13 +40,13 @@ Housekeeping and pipe network stuff
//Node 3 is rest output
//If we flip the filter, 1 and 3 shall exchange positions
var/node1_connect = turn(dir, -180)
var/node1_connect = REVERSE_DIR(dir)
var/node2_connect = turn(dir, -90)
var/node3_connect = dir
if(flipped)
node1_connect = turn(node1_connect, 180)
node3_connect = turn(node3_connect, 180)
node1_connect = REVERSE_DIR(node1_connect)
node3_connect = REVERSE_DIR(node3_connect)
return list(node1_connect, node2_connect, node3_connect)
@@ -38,7 +38,7 @@
var/obj/machinery/atmospherics/components/unary/heat_exchanger/partner = partner_ref?.resolve()
if(!partner)
partner_ref = null
var/partner_connect = turn(dir,180)
var/partner_connect = REVERSE_DIR(dir)
for(var/obj/machinery/atmospherics/components/unary/heat_exchanger/target in get_step(src,partner_connect))
if(target.dir & get_dir(src,target))
@@ -23,7 +23,7 @@
initialize_directions = WEST|EAST
/obj/machinery/atmospherics/pipe/heat_exchanging/junction/get_node_connects()
return list(turn(dir, 180), dir)
return list(REVERSE_DIR(dir), dir)
/obj/machinery/atmospherics/pipe/heat_exchanging/junction/is_connectable(obj/machinery/atmospherics/target, given_layer, he_type_check)
if(dir == get_dir(target, src))
@@ -84,7 +84,7 @@
nodes = list()
for(var/iter in PIPING_LAYER_MIN to PIPING_LAYER_MAX)
var/obj/machinery/atmospherics/foundfront = find_connecting(dir, iter)
var/obj/machinery/atmospherics/foundback = find_connecting(turn(dir, 180), iter)
var/obj/machinery/atmospherics/foundback = find_connecting(REVERSE_DIR(dir), iter)
front_nodes += foundfront
back_nodes += foundback
if(foundfront && !QDELETED(foundfront))
+1 -1
View File
@@ -48,7 +48,7 @@
return
if(bananium.use_amount_mat(material_per_banana, /datum/material/bananium))
new banana_type(get_step(src, turn(wearer.dir, 180))) //honk
new banana_type(get_step(src, REVERSE_DIR(wearer.dir))) //honk
return
toggle_clowning_action()
@@ -23,7 +23,7 @@
/datum/round_event/immovable_rod/start()
var/startside = pick(GLOB.cardinals)
var/turf/end_turf = get_edge_target_turf(get_random_station_turf(), turn(startside, 180))
var/turf/end_turf = get_edge_target_turf(get_random_station_turf(), REVERSE_DIR(startside))
var/turf/start_turf = spaceDebrisStartLoc(startside, end_turf.z)
var/atom/rod = new /obj/effect/immovablerod(start_turf, end_turf, special_target, force_looping)
announce_to_ghosts(rod)
@@ -99,7 +99,7 @@
// If they don't, we'll make them wrap all the way around to the other side of the grid
for(var/direction in GLOB.cardinals)
var/dir = "[direction]"
var/inverse = "[turn(direction, 180)]"
var/inverse = "[REVERSE_DIR(direction)]"
for(var/datum/space_level/level as anything in transition_levels)
// If we have something in this dir that isn't just us, continue on
if(level.neigbours[dir] && level.neigbours[dir] != level)
+1 -1
View File
@@ -404,7 +404,7 @@
if((machine_stat & NOPOWER))
return
var/image/ore_input = image(icon='icons/obj/doors/airlocks/station/overlays.dmi', icon_state="unres_[input_dir]")
var/image/ore_output = image(icon='icons/obj/doors/airlocks/station/overlays.dmi', icon_state="unres_[turn(input_dir, 180)]")
var/image/ore_output = image(icon='icons/obj/doors/airlocks/station/overlays.dmi', icon_state="unres_[REVERSE_DIR(input_dir)]")
switch(input_dir)
if(NORTH)
@@ -360,7 +360,7 @@
break
if(target_turf != target_shove_turf && !directional_blocked) //Make sure that we don't run the exact same check twice on the same tile
for(var/obj/obj_content in target_shove_turf)
if(obj_content.flags_1 & ON_BORDER_1 && obj_content.dir == turn(shove_dir, 180) && obj_content.density)
if(obj_content.flags_1 & ON_BORDER_1 && obj_content.dir == REVERSE_DIR(shove_dir) && obj_content.density)
directional_blocked = TRUE
break
+1 -1
View File
@@ -1040,7 +1040,7 @@
else if(newdir == (EAST|WEST))
newdir = EAST
if((newdir in GLOB.cardinals) && (prob(50)))
newdir = turn(get_dir(target_turf, start), 180)
newdir = REVERSE_DIR(get_dir(target_turf, start))
if(!blood_exists)
new /obj/effect/decal/cleanable/trail_holder(start, get_static_viruses())
+5 -5
View File
@@ -77,15 +77,15 @@
var/dir_1 = 0
var/dir_2 = 0
if(i == 1)
dir_2 = turn(angle2dir(get_angle(path[i+1], current_turf)), 180)
dir_2 = REVERSE_DIR(angle2dir(get_angle(path[i+1], current_turf)))
else if(i == length(path))
dir_2 = turn(angle2dir(get_angle(path[i-1], current_turf)), 180)
dir_2 = REVERSE_DIR(angle2dir(get_angle(path[i-1], current_turf)))
else
dir_1 = turn(angle2dir(get_angle(path[i+1], current_turf)), 180)
dir_2 = turn(angle2dir(get_angle(path[i-1], current_turf)), 180)
dir_1 = REVERSE_DIR(angle2dir(get_angle(path[i+1], current_turf)))
dir_2 = REVERSE_DIR(angle2dir(get_angle(path[i-1], current_turf)))
if(dir_1 > dir_2)
dir_1 = dir_2
dir_2 = turn(angle2dir(get_angle(path[i+1], current_turf)), 180)
dir_2 = REVERSE_DIR(angle2dir(get_angle(path[i+1], current_turf)))
path_image.icon_state = "[dir_1]-[dir_2]"
client.images += path_image
client.navigation_images += path_image
+2 -2
View File
@@ -165,7 +165,7 @@
var/atom/movable/P = mob.pulling
if(P && !ismob(P) && P.density)
mob.setDir(turn(mob.dir, 180))
mob.setDir(REVERSE_DIR(mob.dir))
/**
* Checks to see if you're being grabbed and if so attempts to break it
@@ -301,7 +301,7 @@
// last pushoff exists for one reason
// to ensure pushing a mob doesn't just lead to it considering us as backup, and failing
last_pushoff = world.time
if(backup.newtonian_move(turn(movement_dir, 180), instant = TRUE)) //You're pushing off something movable, so it moves
if(backup.newtonian_move(REVERSE_DIR(movement_dir), instant = TRUE)) //You're pushing off something movable, so it moves
// We set it down here so future calls to Process_Spacemove by the same pair in the same tick don't lead to fucky
backup.last_pushoff = world.time
to_chat(src, span_info("You push off of [backup] to propel yourself."))
+4 -4
View File
@@ -86,7 +86,7 @@ All the important duct code:
///connect to a duct
/obj/machinery/duct/proc/connect_duct(obj/machinery/duct/other, direction)
var/opposite_dir = turn(direction, 180)
var/opposite_dir = REVERSE_DIR(direction)
if(!active || !other.active)
return
@@ -128,7 +128,7 @@ All the important duct code:
///connect to a plumbing object
/obj/machinery/duct/proc/connect_plumber(datum/component/plumbing/plumbing, direction)
var/opposite_dir = turn(direction, 180)
var/opposite_dir = REVERSE_DIR(direction)
if(!(duct_layer & plumbing.ducting_layer))
return FALSE
@@ -182,7 +182,7 @@ All the important duct code:
if(!(other in neighbours))
neighbours[other] = direction
if(!(src in other.neighbours))
other.neighbours[src] = turn(direction, 180)
other.neighbours[src] = REVERSE_DIR(direction)
///remove all our neighbours, and remove us from our neighbours aswell
/obj/machinery/duct/proc/lose_neighbours()
@@ -212,7 +212,7 @@ All the important duct code:
for(var/direction in GLOB.cardinals)
if(direction & connects)
for(var/obj/machinery/duct/other in get_step(src, direction))
if((turn(direction, 180) & other.connects) && other.active)
if((REVERSE_DIR(direction) & other.connects) && other.active)
adjacents += other
return adjacents
+3 -3
View File
@@ -106,7 +106,7 @@ GLOBAL_LIST_INIT(wire_node_generating_types, typecacheof(list(/obj/structure/gri
var/obj/machinery/power/smes/S = locate(/obj/machinery/power/smes) in TB
if(S && (!S.terminal || S.terminal == search_parent))
continue
var/inverse = turn(check_dir, 180)
var/inverse = REVERSE_DIR(check_dir)
for(var/obj/structure/cable/C in TB)
if(C.cable_layer & cable_layer)
linked_dirs |= check_dir
@@ -122,7 +122,7 @@ GLOBAL_LIST_INIT(wire_node_generating_types, typecacheof(list(/obj/structure/gri
///Clear the linked indicator bitflags
/obj/structure/cable/proc/Disconnect_cable()
for(var/check_dir in GLOB.cardinals)
var/inverse = turn(check_dir, 180)
var/inverse = REVERSE_DIR(check_dir)
if(linked_dirs & check_dir)
var/TB = get_step(loc, check_dir)
for(var/obj/structure/cable/C in TB)
@@ -274,7 +274,7 @@ GLOBAL_LIST_INIT(wire_node_generating_types, typecacheof(list(/obj/structure/gri
// merge with the powernets of power objects in the given direction
/obj/structure/cable/proc/mergeConnectedNetworks(direction)
var/inverse_dir = (!direction)? 0 : turn(direction, 180) //flip the direction, to match with the source position on its turf
var/inverse_dir = (!direction)? 0 : REVERSE_DIR(direction) //flip the direction, to match with the source position on its turf
var/turf/TB = get_step(src, direction)
+3 -3
View File
@@ -112,7 +112,7 @@
RegisterSignal(SSdcs, COMSIG_GLOB_GREY_TIDE_LIGHT, PROC_REF(grey_tide)) //Only put the signal on station lights
// Light projects out backwards from the dir of the light
set_light(l_dir = turn(dir, 180))
set_light(l_dir = REVERSE_DIR(dir))
RegisterSignal(src, COMSIG_LIGHT_EATER_ACT, PROC_REF(on_light_eater))
AddElement(/datum/element/atmos_sensitive, mapload)
return INITIALIZE_HINT_LATELOAD
@@ -137,14 +137,14 @@
/obj/machinery/light/setDir(newdir)
. = ..()
set_light(l_dir = turn(dir, 180))
set_light(l_dir = REVERSE_DIR(dir))
// If we're adjacent to the source, we make this sorta indentation for our light to ensure it stays lit (and to make distances look right)
// By shifting the light position we use forward a bit, towards something that isn't off by 0.5 from being in angle
// Because angle calculation is kinda harsh it's hard to find a happy point between fulldark and fullbright for the corners behind the light. this is good enough tho
/obj/machinery/light/get_light_offset()
var/list/hand_back = ..()
var/list/dir_offset = dir2offset(turn(dir, 180))
var/list/dir_offset = dir2offset(REVERSE_DIR(dir))
hand_back[1] += dir_offset[1] * 0.5
hand_back[2] += dir_offset[2] * 0.5
return hand_back
+1 -1
View File
@@ -384,7 +384,7 @@ By design, d1 is the smallest direction and d2 is the highest
// pipe_cleaner is pointing at us, we're standing on an open tile
// so create a stub pointing at the clicked pipe_cleaner on our tile
var/fdirn = turn(dirn, 180) // the opposite direction
var/fdirn = REVERSE_DIR(dirn) // the opposite direction
for(var/obj/structure/pipe_cleaner/LC in U) // check to make sure there's not a pipe_cleaner there already
if(LC.d1 == fdirn || LC.d2 == fdirn)
+2 -2
View File
@@ -51,7 +51,7 @@
for(var/d in GLOB.cardinals)
var/turf/T = get_step(src, d)
for(var/obj/machinery/power/terminal/term in T)
if(term && term.dir == turn(d, 180))
if(term && term.dir == REVERSE_DIR(d))
terminal = term
break dir_loop
@@ -97,7 +97,7 @@
terminal = null
var/turf/T = get_step(src, dir)
for(var/obj/machinery/power/terminal/term in T)
if(term && term.dir == turn(dir, 180))
if(term && term.dir == REVERSE_DIR(dir))
terminal = term
terminal.master = src
to_chat(user, span_notice("Terminal found."))
+5 -5
View File
@@ -257,7 +257,7 @@
compressor_work = 0
compressor_pressure = MINIMUM_TURBINE_PRESSURE
if(QDELETED(input_turf))
input_turf = get_step(loc, turn(dir, 180))
input_turf = get_step(loc, REVERSE_DIR(dir))
var/datum/gas_mixture/input_turf_mixture = input_turf.return_air()
if(!input_turf_mixture)
@@ -452,19 +452,19 @@
//locate compressor & turbine, when checking we simply check to see if they are still there
if(!check_only)
compressor = locate(/obj/machinery/power/turbine/inlet_compressor) in get_step(src, turn(dir, 180))
compressor = locate(/obj/machinery/power/turbine/inlet_compressor) in get_step(src, REVERSE_DIR(dir))
turbine = locate(/obj/machinery/power/turbine/turbine_outlet) in get_step(src, dir)
//maybe look for them the other way around. we want the rotor to allign with them either way for player convinience
if(!compressor && !turbine)
compressor = locate(/obj/machinery/power/turbine/inlet_compressor) in get_step(src, dir)
turbine = locate(/obj/machinery/power/turbine/turbine_outlet) in get_step(src, turn(dir, 180))
turbine = locate(/obj/machinery/power/turbine/turbine_outlet) in get_step(src, REVERSE_DIR(dir))
//sanity checks for compressor
if(QDELETED(compressor))
feedback(user, "missing compressor!")
return (all_parts_connected = FALSE)
if(compressor.dir != dir && compressor.dir != turn(dir, 180)) //make sure it's not perpendicular to the rotor
if(compressor.dir != dir && compressor.dir != REVERSE_DIR(dir)) //make sure it's not perpendicular to the rotor
feedback(user, "compressor not aligned with rotor!")
return (all_parts_connected = FALSE)
if(!compressor.can_connect)
@@ -478,7 +478,7 @@
if(QDELETED(turbine))
feedback(user, "missing turbine!")
return (all_parts_connected = FALSE)
if(turbine.dir != dir && turbine.dir != turn(dir, 180))
if(turbine.dir != dir && turbine.dir != REVERSE_DIR(dir))
feedback(user, "turbine not aligned with rotor!")
return (all_parts_connected = FALSE)
if(!turbine.can_connect)
+1 -1
View File
@@ -577,7 +577,7 @@
var/turf/T = get_turf(user)
process_fire(user, user, FALSE, null, BODY_ZONE_HEAD)
user.visible_message(span_suicide("[user] blows [user.p_their()] brain[user.p_s()] out with [src]!"))
var/turf/target = get_ranged_target_turf(user, turn(user.dir, 180), BRAINS_BLOWN_THROW_RANGE)
var/turf/target = get_ranged_target_turf(user, REVERSE_DIR(user.dir), BRAINS_BLOWN_THROW_RANGE)
B.Remove(user)
B.forceMove(T)
var/datum/callback/gibspawner = CALLBACK(GLOBAL_PROC, GLOBAL_PROC_REF(spawn_atom_to_turf), /obj/effect/gibspawner/generic, B, 1, FALSE, user)
+1 -1
View File
@@ -136,7 +136,7 @@ GLOBAL_LIST_EMPTY(conveyors_by_id)
if(QDELETED(valid))
continue
neighbors["[direction]"] = TRUE
valid.neighbors["[DIRFLIP(direction)]"] = TRUE
valid.neighbors["[REVERSE_DIR(direction)]"] = TRUE
RegisterSignal(valid, COMSIG_MOVABLE_MOVED, PROC_REF(nearby_belt_changed), override=TRUE)
RegisterSignal(valid, COMSIG_QDELETING, PROC_REF(nearby_belt_changed), override=TRUE)
valid.RegisterSignal(src, COMSIG_MOVABLE_MOVED, PROC_REF(nearby_belt_changed), override=TRUE)
@@ -83,7 +83,7 @@
if(initialize_dirs & DISP_DIR_RIGHT)
dpdir |= turn(dir, -90)
if(initialize_dirs & DISP_DIR_FLIP)
dpdir |= turn(dir, 180)
dpdir |= REVERSE_DIR(dir)
return dpdir
/obj/structure/disposalconstruct/proc/AfterRotation(mob/user, degrees)
+1 -1
View File
@@ -168,7 +168,7 @@
if(!T)
return null
var/fdir = turn(dir, 180) // flip the movement direction
var/fdir = REVERSE_DIR(dir) // flip the movement direction
for(var/obj/structure/disposalpipe/P in T)
if(fdir & P.dpdir) // find pipe direction mask that matches flipped dir
if(QDELING(P))
+3 -3
View File
@@ -49,7 +49,7 @@
if(initialize_dirs & DISP_DIR_RIGHT)
dpdir |= turn(dir, -90)
if(initialize_dirs & DISP_DIR_FLIP)
dpdir |= turn(dir, 180)
dpdir |= REVERSE_DIR(dir)
AddElement(/datum/element/undertile, TRAIT_T_RAY_VISIBLE)
if(isturf(loc))
@@ -85,7 +85,7 @@
// returns the direction of the next pipe object, given the entrance dir
// by default, returns the bitmask of remaining directions
/obj/structure/disposalpipe/proc/nextdir(obj/structure/disposalholder/H)
return dpdir & (~turn(H.dir, 180))
return dpdir & (~REVERSE_DIR(H.dir))
// transfer the holder through this pipe segment
// overridden for special behaviour
@@ -210,7 +210,7 @@
// if coming in from secondary dirs, then next is primary dir
// if coming in from primary dir, then next is equal chance of other dirs
/obj/structure/disposalpipe/junction/nextdir(obj/structure/disposalholder/H)
var/flipdir = turn(H.dir, 180)
var/flipdir = REVERSE_DIR(H.dir)
if(flipdir != dir) // came from secondary dir, so exit through primary
return dir
@@ -7,7 +7,7 @@
initialize_dirs = DISP_DIR_RIGHT | DISP_DIR_FLIP
/obj/structure/disposalpipe/sorting/nextdir(obj/structure/disposalholder/H)
var/sortdir = dpdir & ~(dir | turn(dir, 180))
var/sortdir = dpdir & ~(dir | REVERSE_DIR(dir))
if(H.dir != sortdir) // probably came from the negdir
if(check_sorting(H)) // if destination matches filtered type...
return sortdir // exit through sortdirection
@@ -86,7 +86,7 @@
return TRUE
/obj/machinery/atmospherics/components/binary/circulator/get_node_connects()
return list(turn(dir, 180), dir) // airs[2] is input which is facing dir, airs[1] is output which is facing the other side of dir
return list(REVERSE_DIR(dir), dir) // airs[2] is input which is facing dir, airs[1] is output which is facing the other side of dir
/obj/machinery/atmospherics/components/binary/tank_compressor/screwdriver_act(mob/living/user, obj/item/tool)
if(active || inserted_tank)
@@ -263,7 +263,7 @@
/obj/machinery/atmospherics/components/binary/tank_compressor/update_overlays()
. = ..()
. += get_pipe_image(icon, "[base_icon_state]-pipe", dir, COLOR_VIBRANT_LIME, piping_layer)
. += get_pipe_image(icon, "[base_icon_state]-pipe", turn(dir, 180), COLOR_RED, piping_layer)
. += get_pipe_image(icon, "[base_icon_state]-pipe", REVERSE_DIR(dir), COLOR_RED, piping_layer)
if(!istype(inserted_tank))
. += mutable_appearance(icon, "[base_icon_state]-doors",)
if(panel_open)
+1 -1
View File
@@ -49,7 +49,7 @@
rotation = SIMPLIFY_DEGREES(rotation)
if(!movement_direction)
movement_direction = turn(preferred_direction, 180)
movement_direction = REVERSE_DIR(preferred_direction)
var/list/moved_atoms = list() //Everything not a turf that gets moved in the shuttle
var/list/areas_to_move = list() //unique assoc list of areas on turfs being moved
@@ -426,8 +426,8 @@
/obj/item/mecha_parts/mecha_equipment/thrusters/proc/generate_effect(movement_dir)
var/obj/effect/particle_effect/E = new effect_type(get_turf(chassis))
E.dir = turn(movement_dir, 180)
step(E, turn(movement_dir, 180))
E.dir = REVERSE_DIR(movement_dir)
step(E, REVERSE_DIR(movement_dir))
QDEL_IN(E, 5)
@@ -43,7 +43,7 @@
/obj/item/mecha_parts/mecha_equipment/weapon/action(mob/source, atom/target, list/modifiers)
if(!action_checks(target))
return FALSE
var/newtonian_target = turn(chassis.dir,180)
var/newtonian_target = REVERSE_DIR(chassis.dir)
. = ..()//start the cooldown early because of sleeps
for(var/i in 1 to projectiles_per_shot)
if(energy_drain && !chassis.has_charge(energy_drain))//in case we run out of energy mid-burst, such as emp
@@ -44,7 +44,7 @@
if(!istype(backup) || !movement_dir || backup.anchored || continuous_move) //get_spacemove_backup() already checks if a returned turf is solid, so we can just go
return TRUE
last_pushoff = world.time
if(backup.newtonian_move(turn(movement_dir, 180), instant = TRUE))
if(backup.newtonian_move(REVERSE_DIR(movement_dir), instant = TRUE))
backup.last_pushoff = world.time
step_silent = TRUE
if(return_drivers())
+1 -1
View File
@@ -115,7 +115,7 @@
grinding_mulitipler = 2
victim.Knockdown(4 * grinding_mulitipler SECONDS)
else
var/backdir = turn(dir, 180)
var/backdir = REVERSE_DIR(dir)
step(src, backdir)
rider.spin(4, 1)