Files
Aurora.3/code/modules/multiz/basic.dm
Matt Atlas cadd19beac Ports the TG globals controller and converts globals. (#18057)
* SDQL2 update

* fix that verb

* cl

* fix that

* toworld

* this is pointless

* update info

* siiiiick..

* vv edit update

* fix that

* fix editing vars

* fix VV

* Port the /TG/ globals controller.

* part 1

* part 2

* oops

* part 3

* Hollow Purple

* sadas

* bsbsdb

* muda na agaki ta

* ids 1-15

* 16-31

* 41-75

* bring me back to how things used to be before i lost it all

* the strength of mayhem

* final touches

* cl

* protect some vars

* update sdql2 to use glob

* stuff?

* forgot that is not defined there

* whoops

* observ

* but it never gets better

* a

---------

Co-authored-by: Matt Atlas <liermattia@gmail.com>
2023-12-26 01:16:02 +00:00

86 lines
2.1 KiB
Plaintext

// If you add a more comprehensive system, just untick this file.
// Because this shit before was, for some reason, a bitfield.
GLOBAL_LIST_EMPTY(z_levels)
var/list/list/connected_z_cache = list()
// If the height is more than 1, we mark all contained levels as connected.
/obj/effect/landmark/map_data/New(turf/loc, _height)
..()
if(!istype(loc)) // Using loc.z is safer when using the maploader and New.
return
if(_height)
height = _height
for(var/i = (loc.z - height + 1) to (loc.z-1))
if (GLOB.z_levels.len <i)
GLOB.z_levels.len = i
GLOB.z_levels[i] = TRUE
/obj/effect/landmark/map_data/Initialize()
..()
return INITIALIZE_HINT_QDEL
/proc/HasAbove(var/z)
if(z >= world.maxz || z < 1 || z > GLOB.z_levels.len)
return 0
return GLOB.z_levels[z]
/proc/HasBelow(var/z)
if(z > world.maxz || z < 2 || (z-1) > GLOB.z_levels.len)
return 0
return GLOB.z_levels[z-1]
// Thankfully, no bitwise magic is needed here.
/proc/GetAbove(var/atom/atom)
var/turf/turf = get_turf(atom)
if(!turf)
return null
return HasAbove(turf.z) ? get_step(turf, UP) : null
/proc/GetBelow(var/atom/atom)
var/turf/turf = get_turf(atom)
if(!turf)
return null
return HasBelow(turf.z) ? get_step(turf, DOWN) : null
/proc/GetConnectedZlevels(z)
. = list(z)
for(var/level = z, HasBelow(level), level--)
. |= level-1
for(var/level = z, HasAbove(level), level++)
. |= level+1
/proc/AreConnectedZLevels(var/zA, var/zB)
if (zA == zB)
return TRUE
if(zA == 0 || zB == 0)
return FALSE
if (connected_z_cache.len >= zA && connected_z_cache[zA])
return (connected_z_cache[zA].len >= zB && connected_z_cache[zA][zB])
var/list/levels = GetConnectedZlevels(zA)
var/list/new_entry = new(max(levels))
for (var/entry in levels)
new_entry[entry] = TRUE
if (connected_z_cache.len < zA)
connected_z_cache.len = zA
connected_z_cache[zA] = new_entry
return (connected_z_cache[zA].len >= zB && connected_z_cache[zA][zB])
/proc/get_zstep(atom/ref, dir)
if (!isloc(ref))
CRASH("Expected atom.")
if (!ref.z)
ref = get_turf(ref)
switch (dir)
if (UP)
. = GET_ABOVE(ref)
if (DOWN)
. = GET_BELOW(ref)
else
. = get_step(ref, dir)