Multi-Z connectivity no longer limited by bit field

Port of Baystation PR  (#19832)
This commit is contained in:
Unknown
2019-11-22 08:34:38 -05:00
parent 2dddf3d594
commit b309f25e2b

View File

@@ -1,25 +1,27 @@
// If you add a more comprehensive system, just untick this file. // If you add a more comprehensive system, just untick this file.
// WARNING: Only works for up to 17 z-levels! var/list/z_levels = list()// Each bit re... haha just kidding this is a list of bools now
var/z_levels = 0 // Each bit represents a connection between adjacent levels. So the first bit means levels 1 and 2 are connected.
// If the height is more than 1, we mark all contained levels as connected. // If the height is more than 1, we mark all contained levels as connected.
/obj/effect/landmark/map_data/New() /obj/effect/landmark/map_data/New()
ASSERT(height <= z) for(var/i = (z - height + 1) to (z-1))
// Due to the offsets of how connections are stored v.s. how z-levels are indexed, some magic number silliness happened. if (z_levels.len <i)
for(var/i = (z - height) to (z - 2)) z_levels.len = i
z_levels |= (1 << i) z_levels[i] = TRUE
qdel(src)
/obj/effect/landmark/map_data/Initialize()
..()
return INITIALIZE_HINT_QDEL
// The storage of connections between adjacent levels means some bitwise magic is needed. // The storage of connections between adjacent levels means some bitwise magic is needed.
/proc/HasAbove(var/z) /proc/HasAbove(var/z)
if(z >= world.maxz || z > 16 || z < 1) if(z >= world.maxz || z < 1 || z > z_levels.len)
return 0 return 0
return z_levels & (1 << (z - 1)) return z_levels[z]
/proc/HasBelow(var/z) /proc/HasBelow(var/z)
if(z > world.maxz || z > 17 || z < 2) if(z > world.maxz || z < 2 || (z-1) > z_levels.len)
return 0 return 0
return z_levels & (1 << (z - 2)) return z_levels[z-1]
// Thankfully, no bitwise magic is needed here. // Thankfully, no bitwise magic is needed here.
/proc/GetAbove(var/atom/atom) /proc/GetAbove(var/atom/atom)