Makes cable use BYOND directions

Instead of 11,12 they use 32,16 for DOWN,UP
Merges multiz handling into main logic
Port of: https://github.com/Baystation12/Baystation12/pull/15907
This commit is contained in:
comma
2017-02-01 02:11:35 +03:00
committed by Leshana
parent b8d9c95445
commit 5f2d23fbd7
3 changed files with 15 additions and 29 deletions

View File

@@ -43,3 +43,11 @@ var/z_levels = 0 // Each bit represents a connection between adjacent levels. S
proc/AreConnectedZLevels(var/zA, var/zB) proc/AreConnectedZLevels(var/zA, var/zB)
return zA == zB || (zB in GetConnectedZlevels(zA)) return zA == zB || (zB in GetConnectedZlevels(zA))
/proc/get_zstep(ref, dir)
if(dir == UP)
. = GetAbove(ref)
else if (dir == DOWN)
. = GetBelow(ref)
else
. = get_step(ref, dir)

View File

@@ -376,25 +376,15 @@ obj/structure/cable/proc/cableColor(var/colorC)
. = list() // this will be a list of all connected power objects . = list() // this will be a list of all connected power objects
var/turf/T var/turf/T
// Handle up/down cables
if(d1 == 11 || d2 == 11)
T = GetBelow(src)
if(T)
. += power_list(T, src, 12, 1)
if(d1 == 12 || d1 == 12)
T = GetAbove(src)
if(T)
. += power_list(T, src, 11, 1)
// Handle standard cables in adjacent turfs // Handle standard cables in adjacent turfs
for(var/cable_dir in list(d1, d2)) for(var/cable_dir in list(d1, d2))
if(cable_dir == 11 || cable_dir == 12 || cable_dir == 0) if(cable_dir == 0)
continue continue
var/reverse = reverse_dir[cable_dir] var/reverse = reverse_dir[cable_dir]
T = get_step(src, cable_dir) T = get_zstep(src, cable_dir)
if(T) if(T)
for(var/obj/structure/cable/C in T) for(var/obj/structure/cable/C in T)
if((C.d1 && C.d1 == reverse) || (C.d2 && C.d2 == reverse)) if(C.d1 == reverse || C.d2 == reverse)
. += C . += C
if(cable_dir & (cable_dir - 1)) // Diagonal, check for /\/\/\ style cables along cardinal directions if(cable_dir & (cable_dir - 1)) // Diagonal, check for /\/\/\ style cables along cardinal directions
for(var/pair in list(NORTH|SOUTH, EAST|WEST)) for(var/pair in list(NORTH|SOUTH, EAST|WEST))
@@ -402,7 +392,7 @@ obj/structure/cable/proc/cableColor(var/colorC)
if(T) if(T)
var/req_dir = cable_dir ^ pair var/req_dir = cable_dir ^ pair
for(var/obj/structure/cable/C in T) for(var/obj/structure/cable/C in T)
if((C.d1 && C.d1 == req_dir) || (C.d2 && C.d2 == req_dir)) if(C.d1 == req_dir || C.d2 == req_dir)
. += C . += C
// Handle cables on the same turf as us // Handle cables on the same turf as us

View File

@@ -209,16 +209,8 @@
// if unmarked==1, only return those with no powernet // if unmarked==1, only return those with no powernet
/proc/power_list(var/turf/T, var/source, var/d, var/unmarked=0, var/cable_only = 0) /proc/power_list(var/turf/T, var/source, var/d, var/unmarked=0, var/cable_only = 0)
. = list() . = list()
var/fdir = (!d)? 0 : turn(d, 180) // the opposite direction to d (or 0 if d==0)
///// Z-Level Stuff var/reverse = d ? reverse_dir[d] : 0
var/Zdir
if(d==11)
Zdir = 11
else if (d==12)
Zdir = 12
else
Zdir = 999
///// Z-Level Stuff
for(var/AM in T) for(var/AM in T)
if(AM == source) continue //we don't want to return source if(AM == source) continue //we don't want to return source
@@ -234,11 +226,7 @@
var/obj/structure/cable/C = AM var/obj/structure/cable/C = AM
if(!unmarked || !C.powernet) if(!unmarked || !C.powernet)
///// Z-Level Stuff if(C.d1 == d || C.d2 == d || C.d1 == reverse || C.d2 == reverse )
if(C.d1 == fdir || C.d2 == fdir || C.d1 == Zdir || C.d2 == Zdir)
///// Z-Level Stuff
. += C
else if(C.d1 == d || C.d2 == d)
. += C . += C
return . return .