Added caching of zlevels.

Currently only condition to cache them is lack of client mobs there.
This commit is contained in:
Chinsky
2014-07-15 16:32:49 +04:00
parent c7257c1bf2
commit 11f87c849b
2 changed files with 23 additions and 8 deletions

View File

@@ -35,6 +35,9 @@ proc/toggle_move_stars(zlevel, direction)
AM.throw_at(get_step(T,reverse_direction(direction)), 5, 1) AM.throw_at(get_step(T,reverse_direction(direction)), 5, 1)
//list used to cache empty zlevels to avoid nedless map bloat
var/list/cached_space = list()
proc/overmap_spacetravel(var/turf/space/T, var/atom/movable/A) proc/overmap_spacetravel(var/turf/space/T, var/atom/movable/A)
var/obj/effect/map/M = map_sectors["[T.z]"] var/obj/effect/map/M = map_sectors["[T.z]"]
if (!M) if (!M)
@@ -72,6 +75,14 @@ proc/overmap_spacetravel(var/turf/space/T, var/atom/movable/A)
if(TM) if(TM)
nz = TM.map_z nz = TM.map_z
testing("Destination: [TM]") testing("Destination: [TM]")
else
if(cached_space.len)
var/obj/effect/map/sector/temporary/cache = cached_space[cached_space.len]
cached_space -= cache
nz = cache.map_z
cache.x = mapx
cache.y = mapy
testing("Destination: *cached* [TM]")
else else
world.maxz++ world.maxz++
nz = world.maxz nz = world.maxz
@@ -81,3 +92,10 @@ proc/overmap_spacetravel(var/turf/space/T, var/atom/movable/A)
var/turf/dest = locate(nx,ny,nz) var/turf/dest = locate(nx,ny,nz)
if(dest) if(dest)
A.loc = dest A.loc = dest
if(istype(M, /obj/effect/map/sector/temporary))
var/obj/effect/map/sector/temporary/source = M
if (source.can_die())
testing("Catching [M] for future use")
source.loc = null
cached_space += source

View File

@@ -117,9 +117,6 @@ var/global/list/map_sectors = list()
/obj/effect/map/sector/temporary/proc/can_die(var/mob/observer) /obj/effect/map/sector/temporary/proc/can_die(var/mob/observer)
testing("Checking if sector at [map_z] can die.") testing("Checking if sector at [map_z] can die.")
if(src.map_z < world.maxz) //can't specify which zlevel to remove
testing("It is not last sector in the stack.")
return 0
for(var/mob/M in player_list) for(var/mob/M in player_list)
if(M != observer && M.z == map_z) if(M != observer && M.z == map_z)
testing("There are people on it.") testing("There are people on it.")