Skip to content

Commit 6f699c4

Browse files
author
realestestate
committed
moved the dir helper function to atom level
1 parent 85d1803 commit 6f699c4

File tree

3 files changed

+42
-41
lines changed

3 files changed

+42
-41
lines changed

code/game/atoms.dm

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1176,3 +1176,31 @@ its easier to just keep the beam vertical.
11761176

11771177
/atom/proc/silicate_act(var/atom/A, var/mob/user)
11781178
return FALSE
1179+
1180+
//bit operation that ensures dir is cardinal facing(N,E,S,W) just in case it's not.
1181+
/atom/proc/force_cardinal_dir()
1182+
dir = dir^(dir&(dir-1))
1183+
1184+
//Returns dir as a string
1185+
/atom/proc/get_dir_as_string(var/atom/target)
1186+
if(src.loc && target.loc)
1187+
var/direction = get_dir(src.loc, target.loc)
1188+
switch(direction)
1189+
if(NORTH)
1190+
return "north"
1191+
if(SOUTH)
1192+
return "south"
1193+
if(WEST)
1194+
return "west"
1195+
if(EAST)
1196+
return "east"
1197+
if(NORTHEAST)
1198+
return "northeast"
1199+
if(NORTHWEST)
1200+
return "northwest"
1201+
if(SOUTHEAST)
1202+
return "southeast"
1203+
if(SOUTHWEST)
1204+
return "southwest"
1205+
else
1206+
return null

code/game/machinery/machinery.dm

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -917,30 +917,3 @@ Class Procs:
917917
table_shift()
918918
else
919919
table_unshift()
920-
921-
/obj/machinery/proc/cardinalize_dir()
922-
//bit operation that ensures cardinal facing in the off chance its not.
923-
dir = dir^(dir&(dir-1))
924-
925-
/obj/machinery/proc/getDirString(var/atom/target)
926-
if(src.loc && target.loc)
927-
var/direction = get_dir(src.loc, target.loc)
928-
switch(direction)
929-
if(NORTH)
930-
return "NORTH"
931-
if(SOUTH)
932-
return "SOUTH"
933-
if(WEST)
934-
return "WEST"
935-
if(EAST)
936-
return "EAST"
937-
if(NORTHEAST)
938-
return "NORTHEAST"
939-
if(NORTHWEST)
940-
return "NORTHWEST"
941-
if(SOUTHEAST)
942-
return "SOUTHEAST"
943-
if(SOUTHWEST)
944-
return "SOUTHWEST"
945-
else
946-
return null

code/game/mecha/mech_bay.dm

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,11 @@
8888
/obj/machinery/mech_bay_recharge_floor/examine(mob/user)
8989
. = ..()
9090
if(recharge_port)
91-
var/direction = getDirString(recharge_port)
92-
to_chat(user,"<span class='notice'>Linked to \the [recharge_port] at the [direction].</span>")
91+
var/direction = get_dir_as_string(recharge_port)
92+
to_chat(user,"<span class='notice'>Linked to \the [recharge_port] at the [uppertext(direction)].</span>")
9393
if(recharge_console)
94-
var/direction = getDirString(recharge_console)
95-
to_chat(user,"<span class='notice'>Linked to \the [recharge_console] at the [direction].</span>")
94+
var/direction = get_dir_as_string(recharge_console)
95+
to_chat(user,"<span class='notice'>Linked to \the [recharge_console] at the [uppertext(direction)].</span>")
9696

9797
/obj/machinery/mech_bay_recharge_floor/proc/locate_and_link_port()
9898
if(recharge_port)//we already have a port
@@ -102,7 +102,7 @@
102102
continue
103103
if(potential_recharge_port.recharge_floor) //it is already linked to another floor. do not link to it.
104104
continue
105-
potential_recharge_port.cardinalize_dir()
105+
potential_recharge_port.force_cardinal_dir()
106106
if(src in get_step(potential_recharge_port, potential_recharge_port.dir).contents) //check if dir of recharge port matches mechbay floor
107107
recharge_port = potential_recharge_port
108108
recharge_port.recharge_floor = src
@@ -211,11 +211,11 @@
211211
/obj/machinery/mech_bay_recharge_port/examine(mob/user)
212212
. = ..()
213213
if(recharge_floor)
214-
var/direction = getDirString(recharge_floor)
215-
to_chat(user,"<span class='notice'>Linked to \the [recharge_floor] at the [direction].</span>")
214+
var/direction = get_dir_as_string(recharge_floor)
215+
to_chat(user,"<span class='notice'>Linked to \the [recharge_floor] at the [uppertext(direction)].</span>")
216216
if(recharge_console)
217-
var/direction = getDirString(recharge_console)
218-
to_chat(user,"<span class='notice'>Linked to \the [recharge_console] at the [direction].</span>")
217+
var/direction = get_dir_as_string(recharge_console)
218+
to_chat(user,"<span class='notice'>Linked to \the [recharge_console] at the [uppertext(direction)].</span>")
219219

220220
/obj/machinery/mech_bay_recharge_port/Destroy()
221221
delink_devices()
@@ -232,7 +232,7 @@
232232
/obj/machinery/mech_bay_recharge_port/proc/locate_and_link_station()
233233
if(recharge_floor) // we already have a station
234234
return 0
235-
cardinalize_dir()
235+
force_cardinal_dir()
236236
for(var/obj/machinery/mech_bay_recharge_floor/potential_recharge_floor in get_step(src,dir))
237237
if(!potential_recharge_floor.anchored)
238238
continue
@@ -467,11 +467,11 @@
467467
/obj/machinery/computer/mech_bay_power_console/examine(mob/user)
468468
. = ..()
469469
if(recharge_floor)
470-
var/direction = getDirString(recharge_floor)
471-
to_chat(user,"<span class='notice'>Linked to \the [recharge_floor] at the [direction].</span>")
470+
var/direction = get_dir_as_string(recharge_floor)
471+
to_chat(user,"<span class='notice'>Linked to \the [recharge_floor] at the [uppertext(direction)].</span>")
472472
if(recharge_port)
473-
var/direction = getDirString(recharge_port)
474-
to_chat(user,"<span class='notice'>Linked to \the [recharge_port] at the [direction].</span>")
473+
var/direction = get_dir_as_string(recharge_port)
474+
to_chat(user,"<span class='notice'>Linked to \the [recharge_port] at the [uppertext(direction)].</span>")
475475

476476

477477
/obj/machinery/computer/mech_bay_power_console/wrenchAnchor()

0 commit comments

Comments
 (0)