mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-10 18:22:39 +00:00
Fixes multi-z things.
This commit is contained in:
committed by
SkyMarshal
parent
772c320303
commit
8c61c3ab6f
@@ -4,28 +4,32 @@ var/z_levels = 0 // Each bit represents a connection between adjacent levels. S
|
||||
|
||||
// If the height is more than 1, we mark all contained levels as connected.
|
||||
/obj/effect/landmark/map_data/New()
|
||||
for(var/i = z - 1 to height - 2)
|
||||
z_levels |= 1 << i
|
||||
del src
|
||||
ASSERT(height <= z)
|
||||
// Due to the offsets of how connections are stored v.s. how z-levels are indexed, some magic number silliness happened.
|
||||
for(var/i = (z - height) to (z - 2))
|
||||
z_levels |= (1 << i)
|
||||
qdel(src)
|
||||
|
||||
HasAbove(z)
|
||||
if(z > world.maxz || z > 17 || z < 2)
|
||||
// The storage of connections between adjacent levels means some bitwise magic is needed.
|
||||
proc/HasAbove(var/z)
|
||||
if(z >= world.maxz || z > 16 || z < 1)
|
||||
return 0
|
||||
return z_levels & (1 << (z - 1))
|
||||
|
||||
HasBelow(z)
|
||||
if(z >= world.maxz || z > 16 || z < 1)
|
||||
proc/HasBelow(var/z)
|
||||
if(z > world.maxz || z > 17 || z < 2)
|
||||
return 0
|
||||
return z_levels & (1 << z)
|
||||
return z_levels & (1 << (z - 2))
|
||||
|
||||
GetAbove(var/atom/thing)
|
||||
var/turf/turf = get_turf(thing)
|
||||
if(!istype(turf))
|
||||
// Thankfully, no bitwise magic is needed here.
|
||||
proc/GetAbove(var/atom/atom)
|
||||
var/turf/turf = get_turf(atom)
|
||||
if(!turf)
|
||||
return null
|
||||
return HasBelow(turf.z) ? locate(turf.z, turf.y, turf.z - 1) : null
|
||||
return HasAbove(turf.z) ? get_step(turf, UP) : null
|
||||
|
||||
GetBelow(var/atom/thing)
|
||||
var/turf/turf = get_turf(thing)
|
||||
if(!istype(turf))
|
||||
proc/GetBelow(var/atom/atom)
|
||||
var/turf/turf = get_turf(atom)
|
||||
if(!turf)
|
||||
return null
|
||||
return HasBelow(turf.z) ? locate(turf.z, turf.y, turf.z + 1) : null
|
||||
return HasBelow(turf.z) ? get_step(turf, DOWN) : null
|
||||
|
||||
Reference in New Issue
Block a user