Ports MultiZAS

This commit is contained in:
Anewbe
2017-05-04 19:51:54 -04:00
committed by Leshana
parent b71a67a775
commit cce1fcc1f5
10 changed files with 150 additions and 73 deletions
+8 -2
View File
@@ -57,11 +57,11 @@ turf/c_airblock(turf/other)
#ifdef ZASDBG
ASSERT(isturf(other))
#endif
if(blocks_air || other.blocks_air)
if(((blocks_air & AIR_BLOCKED) || (other.blocks_air & AIR_BLOCKED)))
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
@@ -69,6 +69,12 @@ turf/c_airblock(turf/other)
if(!istype(other, /turf/simulated/open)) return BLOCKED
#endif
if(((blocks_air & ZONE_BLOCKED) || (other.blocks_air & ZONE_BLOCKED)))
if(z == other.z)
return ZONE_BLOCKED
else
return AIR_BLOCKED
var/result = 0
for(var/atom/movable/M in contents)
result |= M.c_airblock(other)
+5 -5
View File
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
+3
View File
@@ -158,6 +158,9 @@ Total Unsimulated Turfs: [world.maxx*world.maxy*world.maxz - simulated_turf_coun
//defer updating of self-zone-blocked turfs until after all other turfs have been updated.
//this hopefully ensures that non-self-zone-blocked turfs adjacent to self-zone-blocked ones
//have valid zones when the self-zone-blocked turfs update.
//This ensures that doorways don't form their own single-turf zones, since doorways are self-zone-blocked and
//can merge with an adjacent zone, whereas zones that are formed on adjacent turfs cannot merge with the doorway.
var/list/deferred = list()
for(var/turf/T in updating)
+4
View File
@@ -39,6 +39,10 @@ client/proc/Test_ZAS_Connection(var/turf/simulated/T as turf)
"South" = SOUTH,\
"East" = EAST,\
"West" = WEST,\
#ifdef MULTIZAS
"Up" = UP,\
"Down" = DOWN,\
#endif
"N/A" = null)
var/direction = input("What direction do you wish to test?","Set direction") as null|anything in direction_list
if(!direction)
+19 -17
View File
@@ -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)
@@ -52,34 +52,36 @@
*/
/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.Copy()
#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
@@ -98,7 +100,7 @@
#endif
if(zone)
var/zone/z = zone
if(can_safely_remove_from_zone()) //Helps normal airlocks avoid rebuilding zones all the time
z.remove(src)
else
@@ -110,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)
@@ -161,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)))
+1 -2
View File
@@ -28,8 +28,7 @@ Notes for people who used ZAS before:
*/
//#define ZASDBG
//#define ZLEVELS
//#define MULTIZAS
#define AIR_BLOCKED 1
#define ZONE_BLOCKED 2
#define BLOCKED 3