Nukes reverse_direction() in favor of REVERSE_DIR define (#25550)

* same taste, twice the speed

* pain
This commit is contained in:
chuga-git
2024-06-06 03:18:48 +00:00
committed by GitHub
parent 854978fb7f
commit 66f18ffc74
16 changed files with 19 additions and 35 deletions
+3
View File
@@ -28,3 +28,6 @@
#define IS_DIR_DIAGONAL(dir) (dir & (dir - 1))
/// returns TRUE if direction is cardinal and false if not
#define IS_DIR_CARDINAL(dir) (!IS_DIR_DIAGONAL(dir))
/// Inverse direction, taking into account UP|DOWN if necessary.
#define REVERSE_DIR(dir) ( ((dir & 85) << 1) | ((dir & 170) >> 1) )
+1 -1
View File
@@ -362,7 +362,7 @@ DEFINE_BITFIELD(smoothing_junction, list(
icon_state = "[base_icon_state]-[smoothing_junction]-d"
if(!fixed_underlay && new_junction != .) // Mutable underlays?
var/junction_dir = reverse_ndir(smoothing_junction)
var/turned_adjacency = reverse_direction(junction_dir)
var/turned_adjacency = REVERSE_DIR(junction_dir)
var/turf/neighbor_turf = get_step(src, turned_adjacency & (NORTH|SOUTH))
var/mutable_appearance/underlay_appearance = mutable_appearance(layer = TURF_LAYER, plane = FLOOR_PLANE)
if(neighbor_turf && (!neighbor_turf.get_smooth_underlay_icon(underlay_appearance, src, turned_adjacency) || neighbor_turf.density)) //dense turfs are unwanted for underlays
-19
View File
@@ -1143,25 +1143,6 @@ GLOBAL_LIST_INIT(can_embed_types, typecacheof(list(
if(is_type_in_typecache(W, GLOB.can_embed_types))
return TRUE
/proc/reverse_direction(dir)
switch(dir)
if(NORTH)
return SOUTH
if(NORTHEAST)
return SOUTHWEST
if(EAST)
return WEST
if(SOUTHEAST)
return NORTHWEST
if(SOUTH)
return NORTH
if(SOUTHWEST)
return NORTHEAST
if(WEST)
return EAST
if(NORTHWEST)
return SOUTHEAST
/*
Checks if that loc and dir has a item on the wall
*/
+1 -1
View File
@@ -135,7 +135,7 @@
/obj/machinery/door/window/unrestricted_side(mob/M)
var/mob_dir = get_dir(src, M)
if(mob_dir == 0) // If the mob is inside the tile
mob_dir = reverse_direction(dir) // Set it to the inside direction of the windoor
mob_dir = REVERSE_DIR(dir) // Set it to the inside direction of the windoor
return mob_dir & unres_sides
@@ -23,7 +23,7 @@
/obj/item/tank/jetpack/on_mob_move(direction, mob/user)
if(on)
var/turf/T = get_step(src, reverse_direction(direction))
var/turf/T = get_step(src, REVERSE_DIR(direction))
if(!has_gravity(T))
new /obj/effect/particle_effect/ion_trails(T, direction)
@@ -50,7 +50,7 @@
tube_dirs = list(NORTH, SOUTH)
if(WEST)
tube_dirs = list(NORTH, SOUTH)
boarding_dir = reverse_direction(dir)
boarding_dir = REVERSE_DIR(dir)
/obj/structure/transit_tube/station/should_stop_pod(obj/structure/transit_tube_pod/pod, from_dir)
for(var/atom/atom in pod.contents)
@@ -209,7 +209,7 @@
/obj/structure/transit_tube/station/reverse/init_tube_dirs()
tube_dirs = list(turn(dir, -90))
boarding_dir = reverse_direction(dir)
boarding_dir = REVERSE_DIR(dir)
/obj/structure/transit_tube/station/reverse/flipped
icon_state = "closed_terminus1"
@@ -285,7 +285,7 @@
/obj/structure/transit_tube/station/dispenser/reverse/init_tube_dirs()
tube_dirs = list(turn(dir, -90))
boarding_dir = reverse_direction(dir)
boarding_dir = REVERSE_DIR(dir)
/obj/structure/transit_tube/station/dispenser/reverse/flipped
icon_state = "open_terminusdispenser1"
@@ -91,7 +91,7 @@
var/move_result = move_animation(current_move_anim_mode)
if(isnull(move_result))
if(isnull(current_tube) || (!(dir in current_tube.directions()) && !(reverse_direction(dir) in current_tube.directions())))
if(isnull(current_tube) || (!(dir in current_tube.directions()) && !(REVERSE_DIR(dir) in current_tube.directions())))
outside_tube()
return PROCESS_KILL
+1 -1
View File
@@ -146,7 +146,7 @@
if(itercount > 100)
stack_trace("SPACE Z-TRANSIT ERROR: [A] encountered a possible infinite loop while traveling through z-levels.")
break
var/turf/target_turf = get_step(current_pull.pulledby.loc, reverse_direction(current_pull.pulledby.dir)) || current_pull.pulledby.loc
var/turf/target_turf = get_step(current_pull.pulledby.loc, REVERSE_DIR(current_pull.pulledby.dir)) || current_pull.pulledby.loc
ADD_TRAIT(current_pull, TRAIT_CURRENTLY_Z_MOVING, ROUNDSTART_TRAIT)
current_pull.forceMove(target_turf)
REMOVE_TRAIT(current_pull, TRAIT_CURRENTLY_Z_MOVING, ROUNDSTART_TRAIT)
@@ -248,7 +248,7 @@
// - V - Attacker facing south
// - - -
// Victim at 135 or more degrees of where the victim is facing.
if(attacker_dir & reverse_direction(attacker_to_victim))
if(attacker_dir & REVERSE_DIR(attacker_to_victim))
return DEVIATION_FULL
// - - -
// # V # Attacker facing south
@@ -120,7 +120,7 @@
// On both tiles
for(var/obj/structure/window/reinforced/mazeglass/W in T3)
if(W.dir == reverse_direction(text2num(D)))
if(W.dir == REVERSE_DIR(text2num(D)))
qdel(W)
// Mark as visited
@@ -68,7 +68,7 @@
var/turf/T3 = unvisited_neighbours["[D]"] // Pick random dir turf
// Remove the color between the two
var/turf/T4 = get_step(T3, reverse_direction(text2num(D)))
var/turf/T4 = get_step(T3, REVERSE_DIR(text2num(D)))
T4?.color = MAZEGEN_TURF_CELL
// Mark as visited
+1 -1
View File
@@ -244,7 +244,7 @@
/obj/item/mod/control/on_mob_move(direction, mob/user)
if(!jetpack_active || !isturf(user.loc))
return
var/turf/T = get_step(src, reverse_direction(direction))
var/turf/T = get_step(src, REVERSE_DIR(direction))
if(!has_gravity(T))
new /obj/effect/particle_effect/ion_trails(T, direction)
+1 -1
View File
@@ -41,7 +41,7 @@
// if 2fast, throw the person, otherwise they just slide off, if there's reasonable speed at all
if(speed && A.move_resist < INFINITY)
var/dist = max(throw_dist * speed / MAX_SPEED, 1)
A.throw_at(get_distant_turf(get_turf(src), reverse_direction(dir), dist), A.throw_range, A.throw_speed, src, 1)
A.throw_at(get_distant_turf(get_turf(src), REVERSE_DIR(dir), dist), A.throw_range, A.throw_speed, src, 1)
/obj/machinery/power/treadmill/process()
if(!anchored)
+1 -1
View File
@@ -159,7 +159,7 @@
tempDir = EAST
if(NORTHWEST, SOUTHWEST)
tempDir = WEST
var/turf/tempLoc = get_step(src, reverse_direction(tempDir))
var/turf/tempLoc = get_step(src, REVERSE_DIR(tempDir))
if(isspaceturf(tempLoc))
to_chat(user, "<span class='warning'>You can't build a terminal on space.</span>")
return
@@ -417,7 +417,7 @@
playsound(human_owner, 'sound/goonstation/items/hypo.ogg', 80, TRUE)
var/obj/item/telegraph_vial = new /obj/item/qani_laaca_telegraph(get_turf(owner))
var/turf/turf_we_throw_at = get_edge_target_turf(owner, reverse_direction(owner.dir))
var/turf/turf_we_throw_at = get_edge_target_turf(owner, REVERSE_DIR(owner.dir))
telegraph_vial.throw_at(turf_we_throw_at, 5, 1)
// Safety net in case the injection amount doesn't get reset. Apparently it happened to someone in a round.
+1 -1
View File
@@ -137,7 +137,7 @@
if(!direction) // cable direction = 0, which means its a node
return TRUE
var/turf/potential_cable_turf = get_step(origin_turf, direction)
var/reversed_direction = reverse_direction(direction)
var/reversed_direction = REVERSE_DIR(direction)
for(var/obj/structure/cable/other_cable in potential_cable_turf.contents)
if(reversed_direction == other_cable.d1 || reversed_direction == other_cable.d2)
return TRUE