mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2026-01-07 07:53:15 +00:00
Memory performance fixes for open space
* Don't infinately accumulate underlays! * Ease up on the New() and Destroy(), make sure they are a top level object (loc is a turf) * The open space darkness overlay is always the same, make it a global.
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
|
||||
/var/global/open_space_initialised = FALSE
|
||||
/var/global/datum/controller/process/open_space/OS_controller = null
|
||||
/var/global/image/over_OS_darkness = image('icons/turf/open_space.dmi', "black_open")
|
||||
|
||||
/datum/controller/process/open_space
|
||||
var/list/turfs_to_process = list() // List of turfs queued for update.
|
||||
@@ -15,6 +16,8 @@
|
||||
schedule_interval = world.tick_lag // every second
|
||||
start_delay = 30 SECONDS
|
||||
OS_controller = src
|
||||
over_OS_darkness.plane = OVER_OPENSPACE_PLANE
|
||||
over_OS_darkness.layer = MOB_LAYER
|
||||
initialize_open_space()
|
||||
|
||||
// Pre-process open space once once before the round starts. Wait 20 seconds so other stuff has time to finish.
|
||||
@@ -82,13 +85,14 @@
|
||||
|
||||
/obj/update_icon()
|
||||
. = ..()
|
||||
if(open_space_initialised && !invisibility)
|
||||
if(open_space_initialised && !invisibility && isturf(loc))
|
||||
var/turf/T = GetAbove(src)
|
||||
if(isopenspace(T))
|
||||
// log_debug("[T] ([T.x],[T.y],[T.z]) queued for update for [src].update_icon()")
|
||||
OS_controller.add_turf(T, 1)
|
||||
|
||||
// Ouch... this is painful. But is there any other way?
|
||||
/* - No for now
|
||||
/obj/New()
|
||||
. = ..()
|
||||
if(open_space_initialised && !invisibility)
|
||||
@@ -96,10 +100,11 @@
|
||||
if(isopenspace(T))
|
||||
// log_debug("[T] ([T.x],[T.y],[T.z]) queued for update for [src]New()")
|
||||
OS_controller.add_turf(T, 1)
|
||||
*/
|
||||
|
||||
// Just as New() we probably should hook Destroy() If we can think of something more efficient, lets hear it.
|
||||
/obj/Destroy()
|
||||
if(open_space_initialised && !invisibility)
|
||||
if(open_space_initialised && !invisibility && isturf(loc))
|
||||
var/turf/T = GetAbove(src)
|
||||
if(isopenspace(T))
|
||||
OS_controller.add_turf(T, 1)
|
||||
|
||||
@@ -79,18 +79,18 @@
|
||||
var/below_is_open = isopenspace(below)
|
||||
|
||||
if(below_is_open)
|
||||
underlays += below.underlays
|
||||
underlays = below.underlays
|
||||
else
|
||||
var/image/bottom_turf = image(icon = below.icon, icon_state = below.icon_state, dir=below.dir, layer=below.layer)
|
||||
bottom_turf.plane = src.plane
|
||||
bottom_turf.color = below.color
|
||||
underlays += bottom_turf
|
||||
underlays = list(bottom_turf)
|
||||
// VOREStation Edit - Hack workaround to byond crash bug - Include the magic overlay holder object.
|
||||
//overlays += below.overlays
|
||||
if(below.overlay_holder)
|
||||
overlays += (below.overlays + below.overlay_holder.overlays)
|
||||
else
|
||||
overlays += below.overlays
|
||||
overlays += below.overlays
|
||||
// if(below.overlay_holder)
|
||||
// overlays += (below.overlays + below.overlay_holder.overlays)
|
||||
// else
|
||||
// overlays += below.overlays
|
||||
// VOREStation Edit End
|
||||
|
||||
// get objects (not mobs, they are handled by /obj/zshadow)
|
||||
@@ -107,9 +107,6 @@
|
||||
overlays += o_img
|
||||
|
||||
if(!below_is_open)
|
||||
var/image/over_OS_darkness = image('icons/turf/open_space.dmi', "black_open")
|
||||
over_OS_darkness.plane = OVER_OPENSPACE_PLANE
|
||||
over_OS_darkness.layer = MOB_LAYER
|
||||
overlays += over_OS_darkness
|
||||
|
||||
return 0
|
||||
|
||||
Reference in New Issue
Block a user