Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactored directionals #20082

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions aurorastation.dme
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@
#include "code\_globalvars\edible.dm"
#include "code\_globalvars\logging.dm"
#include "code\_globalvars\tgui.dm"
#include "code\_globalvars\lists\mapping.dm"
#include "code\_globalvars\lists\mobs.dm"
#include "code\_onclick\adjacent.dm"
#include "code\_onclick\ai.dm"
Expand Down
4 changes: 2 additions & 2 deletions code/ZAS/Fire.dm
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ If it gains pressure too slowly, it may leak or just rupture instead of explodin
A.fire_act(air_contents.temperature, air_contents.volume)

//spread
for(var/direction in GLOB.cardinal)
for(var/direction in GLOB.cardinals)
var/turf/simulated/enemy_tile = get_step(my_tile, direction)

if(istype(enemy_tile))
Expand Down Expand Up @@ -202,7 +202,7 @@ If it gains pressure too slowly, it may leak or just rupture instead of explodin
qdel(src)
return

set_dir(pick(GLOB.cardinal))
set_dir(pick(GLOB.cardinals))

var/datum/gas_mixture/air_contents = loc.return_air()
color = fire_color(air_contents.temperature)
Expand Down
4 changes: 2 additions & 2 deletions code/ZAS/Turf.dm
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@

var/connected_dirs
GET_ZONE_NEIGHBOURS(T, connected_dirs)
if(connected_dirs && (dir & GLOB.reverse_dir[connected_dirs]) == dir)
if(connected_dirs && (dir & REVERSE_DIR(connected_dirs)) == dir)
. &= ~dir //they are, so unflag the cardinals in question

//it is safe to remove src from the zone if all cardinals are connected by corner turfs
Expand Down Expand Up @@ -179,7 +179,7 @@
if(istype(unsim, /turf/simulated))

var/turf/simulated/sim = unsim
sim.open_directions |= GLOB.reverse_dir[d]
sim.open_directions |= REVERSE_DIR(d)

if(TURF_HAS_VALID_ZONE(sim))
//Might have assigned a zone, since this happens for each direction.
Expand Down
8 changes: 0 additions & 8 deletions code/__DEFINES/global.dm
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,6 @@ GLOBAL_LIST_EMPTY(tdomeobserve)
GLOBAL_LIST_EMPTY(tdomeadmin)
GLOBAL_LIST_EMPTY(ninjastart)

GLOBAL_LIST_INIT(cardinal, list(NORTH, SOUTH, EAST, WEST))
GLOBAL_LIST_INIT(cornerdirs, list(NORTHWEST, SOUTHEAST, NORTHEAST, SOUTHWEST))
GLOBAL_LIST_INIT(alldirs, list(NORTH, SOUTH, EAST, WEST, NORTHEAST, NORTHWEST, SOUTHEAST, SOUTHWEST))
GLOBAL_LIST_INIT(reverse_dir, list( // reverse_dir[dir] = reverse of dir
2, 1, 3, 8, 10, 9, 11, 4, 6, 5, 7, 12, 14, 13, 15, 32, 34, 33, 35, 40, 42,
41, 43, 36, 38, 37, 39, 44, 46, 45, 47, 16, 18, 17, 19, 24, 26, 25, 27, 20, 22, 21,
23, 28, 30, 29, 31, 48, 50, 49, 51, 56, 58, 57, 59, 52, 54, 53, 55, 60, 62, 61, 63
))
GLOBAL_LIST_INIT(all_days, list("Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"))

GLOBAL_LIST_EMPTY(combatlog)
Expand Down
2 changes: 1 addition & 1 deletion code/__DEFINES/misc.dm
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ example:
CALCULATE_NEIGHBORS(src, result, T, isopenturf(T))
*/
#define CALCULATE_NEIGHBORS(ORIGIN, VAR, TVAR, FUNC) \
for (var/_tdir in GLOB.cardinal) { \
for (var/_tdir in GLOB.cardinals) { \
TVAR = get_step(ORIGIN, _tdir); \
if ((TVAR) && (FUNC)) { \
VAR |= 1 << _tdir; \
Expand Down
6 changes: 3 additions & 3 deletions code/__HELPERS/game.dm
Original file line number Diff line number Diff line change
Expand Up @@ -209,13 +209,13 @@
return mixedcolor

/**
* Gets the highest and lowest pressures from the tiles in GLOB.cardinal directions
* Gets the highest and lowest pressures from the tiles in GLOB.cardinals directions
* around us, then checks the difference.
*/
/proc/getOPressureDifferential(var/turf/loc)
var/minp=16777216;
var/maxp=0;
for(var/dir in GLOB.cardinal)
for(var/dir in GLOB.cardinals)
var/turf/simulated/T=get_turf(get_step(loc,dir))
var/cp=0
if(T && istype(T) && T.zone)
Expand All @@ -236,7 +236,7 @@

/proc/getCardinalAirInfo(var/turf/loc, var/list/stats=list("temperature"))
var/list/temps = new/list(4)
for(var/dir in GLOB.cardinal)
for(var/dir in GLOB.cardinals)
var/direction
switch(dir)
if(NORTH)
Expand Down
2 changes: 1 addition & 1 deletion code/__HELPERS/icon_smoothing.dm
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
else
var/atom/movable/AM

for(var/direction in GLOB.cardinal)
for(var/direction in GLOB.cardinals)
AM = find_type_in_direction(src, direction)
if(AM == NULLTURF_BORDER)
if((smoothing_flags & SMOOTH_BORDER))
Expand Down
19 changes: 0 additions & 19 deletions code/__HELPERS/unsorted.dm
Original file line number Diff line number Diff line change
Expand Up @@ -1031,25 +1031,6 @@ var/global/list/common_tools = list(
surgery_attempt = SURGERY_IGNORE //hit yourself if you're not lying
return surgery_attempt

/proc/reverse_direction(var/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
*/
Expand Down
94 changes: 94 additions & 0 deletions code/_globalvars/lists/mapping.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
GLOBAL_LIST_INIT(cardinals, list(
NORTH,
SOUTH,
EAST,
WEST,
))
GLOBAL_LIST_INIT(cardinals_multiz, list(
NORTH,
SOUTH,
EAST,
WEST,
UP,
DOWN,
))
GLOBAL_LIST_INIT(diagonals, list(
NORTHEAST,
NORTHWEST,
SOUTHEAST,
SOUTHWEST,
))
GLOBAL_LIST_INIT(corners_multiz, list(
UP|NORTHEAST,
UP|NORTHWEST,
UP|SOUTHEAST,
UP|SOUTHWEST,
DOWN|NORTHEAST,
DOWN|NORTHWEST,
DOWN|SOUTHEAST,
DOWN|SOUTHWEST,
))
GLOBAL_LIST_INIT(diagonals_multiz, list(
NORTHEAST,
NORTHWEST,
SOUTHEAST,
SOUTHWEST,

UP|NORTH,
UP|SOUTH,
UP|EAST,
UP|WEST,
UP|NORTHEAST,
UP|NORTHWEST,
UP|SOUTHEAST,
UP|SOUTHWEST,

DOWN|NORTH,
DOWN|SOUTH,
DOWN|EAST,
DOWN|WEST,
DOWN|NORTHEAST,
DOWN|NORTHWEST,
DOWN|SOUTHEAST,
DOWN|SOUTHWEST,
))
GLOBAL_LIST_INIT(alldirs_multiz, list(
NORTH,
SOUTH,
EAST,
WEST,
NORTHEAST,
NORTHWEST,
SOUTHEAST,
SOUTHWEST,

UP,
UP|NORTH,
UP|SOUTH,
UP|EAST,
UP|WEST,
UP|NORTHEAST,
UP|NORTHWEST,
UP|SOUTHEAST,
UP|SOUTHWEST,

DOWN,
DOWN|NORTH,
DOWN|SOUTH,
DOWN|EAST,
DOWN|WEST,
DOWN|NORTHEAST,
DOWN|NORTHWEST,
DOWN|SOUTHEAST,
DOWN|SOUTHWEST,
))
GLOBAL_LIST_INIT(alldirs, list(
NORTH,
SOUTH,
EAST,
WEST,
NORTHEAST,
NORTHWEST,
SOUTHEAST,
SOUTHWEST,
))
2 changes: 1 addition & 1 deletion code/game/atoms.dm
Original file line number Diff line number Diff line change
Expand Up @@ -631,7 +631,7 @@
if(Proj.damage_flags & DAMAGE_FLAG_LASER)
if(Proj.damage >= 20)
bullet_mark_icon_state = "scorch"
bullet_mark_dir = pick(GLOB.cardinal) // Pick random scorch design
bullet_mark_dir = pick(GLOB.cardinals) // Pick random scorch design
else
bullet_mark_icon_state = "light_scorch"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
to_chat(daddy, SPAN_WARNING("You feel a bit less real. Which one of you two was original again?.."))

/obj/effect/bluegoast/proc/mirror_dir(var/atom/movable/am, var/old_dir, var/new_dir)
set_dir(GLOB.reverse_dir[new_dir])
set_dir(REVERSE_DIR(new_dir))

/obj/effect/bluegoast/examine(mob/user, distance, is_adjacent, infix, suffix, show_extended)
SHOULD_CALL_PARENT(FALSE)
Expand Down
2 changes: 1 addition & 1 deletion code/game/gamemodes/events/clang.dm
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ In my current plan for it, 'solid' will be defined as anything with density == 1
var/starty = 0
var/endy = 0
var/endx = 0
var/startside = pick(GLOB.cardinal)
var/startside = pick(GLOB.cardinals)

switch(startside)
if(NORTH)
Expand Down
2 changes: 1 addition & 1 deletion code/game/gamemodes/meteor/meteor.dm
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
next_wave = round_duration_in_ticks + meteor_wave_delay
// Starts as barely noticeable dust impact, ends as barrage of most severe meteor types the code has to offer. Have fun.
spawn()
spawn_meteors(meteor_severity, get_meteor_types(), pick(GLOB.cardinal), pick(SSmapping.levels_by_trait(ZTRAIT_STATION)))
spawn_meteors(meteor_severity, get_meteor_types(), pick(GLOB.cardinals), pick(SSmapping.levels_by_trait(ZTRAIT_STATION)))
var/escalated = FALSE
if(prob(escalation_probability) && (meteor_severity < maximal_severity))
meteor_severity++
Expand Down
4 changes: 2 additions & 2 deletions code/game/gamemodes/technomancer/devices/shield_armor.dm
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

/obj/item/clothing/suit/armor/shield/New()
..()
spark(src, 5, GLOB.cardinal)
spark(src, 5, GLOB.cardinals)

/obj/item/clothing/suit/armor/shield/handle_shield(mob/user, var/on_back, var/damage, atom/damage_source = null, mob/attacker = null, var/def_zone = null, var/attack_text = "the attack")
//Since this is a pierce of armor that is passive, we do not need to check if the user is incapacitated.
Expand Down Expand Up @@ -63,7 +63,7 @@
user.visible_message(SPAN_DANGER("\The [user]'s [src] absorbs [attack_text]!"))
to_chat(user, SPAN_WARNING("Your shield has absorbed most of \the [damage_source]."))

spark(src, 5, GLOB.cardinal)
spark(src, 5, GLOB.cardinals)
playsound(src, 'sound/weapons/blade.ogg', 50, 1)
return BULLET_ACT_HIT // This shield does not block all damage, so returning 0 is needed to tell the game to apply the new damage.

Expand Down
8 changes: 4 additions & 4 deletions code/game/gamemodes/technomancer/spells/apportation.dm
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
if(isitem(hit_atom))
var/obj/item/I = hit_atom

spark(I, 5, GLOB.cardinal)
spark(user, 5, GLOB.cardinal)
spark(I, 5, GLOB.cardinals)
spark(user, 5, GLOB.cardinals)
I.visible_message(SPAN_DANGER("\The [I] vanishes into thin air!"))
I.forceMove(get_turf(user))
user.drop_item(src)
Expand All @@ -48,8 +48,8 @@
else if(isliving(hit_atom))
var/mob/living/L = hit_atom
to_chat(L, SPAN_DANGER("You are teleported towards \the [user]!"))
spark(L, 5, GLOB.cardinal)
spark(user, 5, GLOB.cardinal)
spark(L, 5, GLOB.cardinals)
spark(user, 5, GLOB.cardinals)
L.throw_at(get_step(get_turf(src), get_dir(src, L)), 4, 1, src)
addtimer(CALLBACK(src, PROC_REF(seize_mob), L, user), 1 SECOND)
user.drop_item(src)
Expand Down
2 changes: 1 addition & 1 deletion code/game/gamemodes/technomancer/spells/passwall.dm
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
visible_message("<span class='info'>[user] rests a hand on \the [hit_atom].</span>")
busy = 1

spark(our_turf, 3, GLOB.cardinal)
spark(our_turf, 3, GLOB.cardinals)

while(i)
checked_turf = get_step(checked_turf, direction) //Advance in the given direction
Expand Down
4 changes: 2 additions & 2 deletions code/game/gamemodes/technomancer/spells/reflect.dm
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
return BULLET_ACT_HIT

//block as long as they are not directly behind us
var/bad_arc = reverse_direction(user.dir) //arc of directions from which we cannot block
var/bad_arc = REVERSE_DIR(user.dir) //arc of directions from which we cannot block
if(check_shield_arc(user, bad_arc, damage_source, attacker))

if(istype(damage_source, /obj/projectile))
Expand Down Expand Up @@ -75,7 +75,7 @@
to_chat(attacker, SPAN_DANGER("Your [damage_source.name] goes through \the [src] in one location, comes out \
on the same side, and hits you!"))

spark(src, 5, GLOB.cardinal)
spark(src, 5, GLOB.cardinals)
playsound(src, 'sound/weapons/blade.ogg', 50, 1)

log_and_message_admins("[user] reflected [attacker]'s attack back at them.")
Expand Down
4 changes: 2 additions & 2 deletions code/game/gamemodes/technomancer/spells/shield.dm
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@
return BULLET_ACT_HIT

//block as long as they are not directly behind us
var/bad_arc = reverse_direction(user.dir) //arc of directions from which we cannot block
var/bad_arc = REVERSE_DIR(user.dir) //arc of directions from which we cannot block
if(check_shield_arc(user, bad_arc, damage_source, attacker))
user.visible_message(SPAN_DANGER("\The [user]'s [src] blocks [attack_text]!"))
spark(src, 3, GLOB.cardinal)
spark(src, 3, GLOB.cardinals)
playsound(src, 'sound/weapons/blade.ogg', 50, 1)
adjust_instability(2)
return BULLET_ACT_BLOCK
Expand Down
4 changes: 2 additions & 2 deletions code/game/machinery/bots/bots.dm
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@
pulse2.icon_state = "empdisable"
pulse2.name = "emp sparks"
pulse2.anchored = 1
pulse2.set_dir(pick(GLOB.cardinal))
pulse2.set_dir(pick(GLOB.cardinals))

QDEL_IN(pulse2, 10)

Expand Down Expand Up @@ -174,7 +174,7 @@

// for(var/turf/simulated/t in oview(src,1))

for(var/d in GLOB.cardinal)
for(var/d in GLOB.cardinals)
var/turf/simulated/T = get_step(src, d)
if(istype(T) && !T.density)
if(!LinkBlockedWithAccess(src, T, ID))
Expand Down
2 changes: 1 addition & 1 deletion code/game/machinery/crusher_piston.dm
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@
var/turf/T = get_turf(src)

var/list/valid_turfs = list()
for(var/dir_to_test in GLOB.cardinal)
for(var/dir_to_test in GLOB.cardinals)
var/turf/new_turf = get_step(T, dir_to_test)
if(!new_turf.contains_dense_objects())
valid_turfs += new_turf
Expand Down
2 changes: 1 addition & 1 deletion code/game/machinery/deployable.dm
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ Deployable Kits
/obj/item/deployable_kit/surgery_table/assemble_kit(mob/user)
..()
var/free_spot = null
for(var/check_dir in GLOB.cardinal)
for(var/check_dir in GLOB.cardinals)
var/turf/T = get_step(src, check_dir)
if(turf_clear(T))
free_spot = T
Expand Down
2 changes: 1 addition & 1 deletion code/game/machinery/doors/airlock.dm
Original file line number Diff line number Diff line change
Expand Up @@ -1954,7 +1954,7 @@ About the new airlock wires panel:
var/turf/T = loc
if(istype(T))
var/list/valid_turfs = list()
for(var/dir_to_test in GLOB.cardinal)
for(var/dir_to_test in GLOB.cardinals)
var/turf/new_turf = get_step(T, dir_to_test)
if(!new_turf.contains_dense_objects())
valid_turfs |= new_turf
Expand Down
2 changes: 1 addition & 1 deletion code/game/machinery/doors/airlock_electronics.dm
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
t1 += "<B>Unrestricted Access Settings</B><br>"


for(var/direction in GLOB.cardinal)
for(var/direction in GLOB.cardinals)
if(direction & unres_dir)
t1 += "<a style='color:#00dd12' href='?src=[REF(src)];unres_dir=[direction]'>[capitalize(dir2text(direction))]</a><br>"
else
Expand Down
Loading
Loading