Skip to content

Commit

Permalink
Fixes and enables MultiZAS
Browse files Browse the repository at this point in the history
  • Loading branch information
BlueNexus committed Nov 7, 2016
1 parent 451225d commit a53a34f
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 25 deletions.
2 changes: 1 addition & 1 deletion code/ZAS/Atom.dm
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ turf/c_airblock(turf/other)
return BLOCKED

//Z-level handling code. Always block if there isn't an open space.
#ifdef ZLEVELS
#ifdef MULTIZAS
if(other.z != src.z)
if(other.z < src.z)
if(!istype(src, /turf/simulated/open)) return BLOCKED
Expand Down
10 changes: 5 additions & 5 deletions code/ZAS/ConnectionManager.dm
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Class Procs:
/connection_manager/var/connection/E
/connection_manager/var/connection/W

#ifdef ZLEVELS
#ifdef MULTIZAS
/connection_manager/var/connection/U
/connection_manager/var/connection/D
#endif
Expand All @@ -57,7 +57,7 @@ Class Procs:
if(check(W)) return W
else return null

#ifdef ZLEVELS
#ifdef MULTIZAS
if(UP)
if(check(U)) return U
else return null
Expand All @@ -73,7 +73,7 @@ Class Procs:
if(EAST) E = c
if(WEST) W = c

#ifdef ZLEVELS
#ifdef MULTIZAS
if(UP) U = c
if(DOWN) D = c
#endif
Expand All @@ -83,7 +83,7 @@ Class Procs:
if(check(S)) S.update()
if(check(E)) E.update()
if(check(W)) W.update()
#ifdef ZLEVELS
#ifdef MULTIZAS
if(check(U)) U.update()
if(check(D)) D.update()
#endif
Expand All @@ -93,7 +93,7 @@ Class Procs:
if(check(S)) S.erase()
if(check(E)) E.erase()
if(check(W)) W.erase()
#ifdef ZLEVELS
#ifdef MULTIZAS
if(check(U)) U.erase()
if(check(D)) D.erase()
#endif
Expand Down
2 changes: 1 addition & 1 deletion code/ZAS/Diagnostic.dm
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ client/proc/Test_ZAS_Connection(var/turf/simulated/T as turf)
"South" = SOUTH,\
"East" = EAST,\
"West" = WEST,\
#ifdef ZLEVELS
#ifdef MULTIZAS
"Up" = UP,\
"Down" = DOWN,\
#endif
Expand Down
33 changes: 17 additions & 16 deletions code/ZAS/Turf.dm
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
//dbg(blocked)
return 1

#ifdef ZLEVELS
#ifdef MULTIZAS
for(var/d = 1, d < 64, d *= 2)
#else
for(var/d = 1, d < 16, d *= 2)
Expand Down Expand Up @@ -52,34 +52,35 @@
*/

/turf/simulated/proc/can_safely_remove_from_zone()
#ifdef ZLEVELS
return 0 //TODO generalize this to multiz.
#else

if(!zone) return 1

var/check_dirs = get_zone_neighbours(src)
var/unconnected_dirs = check_dirs

for(var/dir in list(NORTHWEST, NORTHEAST, SOUTHEAST, SOUTHWEST))

var/to_check = list(NORTHEAST, NORTHWEST, SOUTHEAST, SOUTHWEST)
#ifdef MULTIZAS
to_check += list(NORTHUP, EASTUP, WESTUP, SOUTHUP, NORTHDOWN, EASTDOWN, WESTDOWN, SOUTHDOWN)
#endif
for(var/dir in to_check)

//for each pair of "adjacent" cardinals (e.g. NORTH and WEST, but not NORTH and SOUTH)
if((dir & check_dirs) == dir)
//check that they are connected by the corner turf
var/connected_dirs = get_zone_neighbours(get_step(src, dir))
if(connected_dirs && (dir & turn(connected_dirs, 180)) == dir)
if(connected_dirs && (dir & reverse_dir[connected_dirs]) == dir)
unconnected_dirs &= ~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
return !unconnected_dirs

#endif

//helper for can_safely_remove_from_zone()
/turf/simulated/proc/get_zone_neighbours(turf/simulated/T)
. = 0
if(istype(T) && T.zone)
for(var/dir in cardinal)
var/to_check = cardinal
#ifdef MULTIZAS
to_check += list(UP, DOWN)
#endif
for(var/dir in to_check)
var/turf/simulated/other = get_step(T, dir)
if(istype(other) && other.zone == T.zone && !(other.c_airblock(T) & AIR_BLOCKED) && get_dist(src, other) <= 1)
. |= dir
Expand Down Expand Up @@ -111,7 +112,7 @@
open_directions = 0

var/list/postponed
#ifdef ZLEVELS
#ifdef MULTIZAS
for(var/d = 1, d < 64, d *= 2)
#else
for(var/d = 1, d < 16, d *= 2)
Expand Down Expand Up @@ -162,7 +163,7 @@
//Might have assigned a zone, since this happens for each direction.
if(!zone)

//We do not merge if
//We do not merge if
// they are blocking us and we are not blocking them, or if
// we are blocking them and not blocking ourselves - this prevents tiny zones from forming on doorways.
if(((block & ZONE_BLOCKED) && !(r_block & ZONE_BLOCKED)) || ((r_block & ZONE_BLOCKED) && !(s_block & ZONE_BLOCKED)))
Expand Down
2 changes: 1 addition & 1 deletion code/ZAS/_docs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Notes for people who used ZAS before:
*/

//#define ZASDBG
//#define ZLEVELS
#define MULTIZAS

#define AIR_BLOCKED 1
#define ZONE_BLOCKED 2
Expand Down
12 changes: 11 additions & 1 deletion code/__defines/misc.dm
Original file line number Diff line number Diff line change
Expand Up @@ -180,4 +180,14 @@
#define CELLSIZE (world.icon_size/CELLS) //Size of a cell in pixels

#define WORLD_ICON_SIZE 32
#define PIXEL_MULTIPLIER WORLD_ICON_SIZE/32
#define PIXEL_MULTIPLIER WORLD_ICON_SIZE/32

//MultiZ directions for ZAS checks.
#define NORTHUP (NORTH|UP)
#define EASTUP (EAST|UP)
#define SOUTHUP (SOUTH|UP)
#define WESTUP (WEST|UP)
#define NORTHDOWN (NORTH|DOWN)
#define EASTDOWN (EAST|DOWN)
#define SOUTHDOWN (SOUTH|DOWN)
#define WESTDOWN (WEST|DOWN)

0 comments on commit a53a34f

Please sign in to comment.