Converts /datum/gas_mixture/var/graphic to a lazy list.

* The vast majority of gas mixtures never use their `graphic` list.  Prime candidate for making a lazy init list.
* While we are here, add nullchecks to ZAS's use of the graphic list a bit.  /turf/update_graphics was technically already null safe, but its even better to not bother calling it at all right?
This commit is contained in:
Leshana
2017-06-10 10:13:55 -04:00
parent 446f7b0a12
commit 1b8451bc9a
3 changed files with 20 additions and 18 deletions

View File

@@ -5,9 +5,9 @@
/turf/var/datum/gas_mixture/air
/turf/simulated/proc/update_graphic(list/graphic_add = null, list/graphic_remove = null)
if(graphic_add && graphic_add.len)
if(LAZYLEN(graphic_add))
overlays += graphic_add
if(graphic_remove && graphic_remove.len)
if(LAZYLEN(graphic_remove))
overlays -= graphic_remove
/turf/proc/update_air_properties()

View File

@@ -77,7 +77,8 @@ Class Procs:
fire_tiles.Add(T)
air_master.active_fire_zones |= src
if(fuel) fuel_objs += fuel
T.update_graphic(air.graphic)
if(air.graphic)
T.update_graphic(air.graphic)
/zone/proc/remove(turf/simulated/T)
#ifdef ZASDBG
@@ -92,7 +93,8 @@ Class Procs:
var/obj/effect/decal/cleanable/liquid_fuel/fuel = locate() in T
fuel_objs -= fuel
T.zone = null
T.update_graphic(graphic_remove = air.graphic)
if(air.graphic)
T.update_graphic(graphic_remove = air.graphic)
if(contents.len)
air.group_multiplier = contents.len
else
@@ -106,9 +108,11 @@ Class Procs:
ASSERT(!into.invalid)
#endif
c_invalidate()
var/list/air_graphic = air.graphic // Cache for sanic speed
for(var/turf/simulated/T in contents)
into.add(T)
T.update_graphic(graphic_remove = air.graphic)
if(air_graphic)
T.update_graphic(graphic_remove = air_graphic)
#ifdef ZASDBG
T.dbg(merged)
#endif
@@ -131,8 +135,10 @@ Class Procs:
/zone/proc/rebuild()
if(invalid) return //Short circuit for explosions where rebuild is called many times over.
c_invalidate()
var/list/air_graphic = air.graphic // Cache for sanic speed
for(var/turf/simulated/T in contents)
T.update_graphic(graphic_remove = air.graphic) //we need to remove the overlays so they're not doubled when the zone is rebuilt
if(air_graphic)
T.update_graphic(graphic_remove = air_graphic) //we need to remove the overlays so they're not doubled when the zone is rebuilt
//T.dbg(invalid_zone)
T.needs_air_update = 0 //Reset the marker so that it will be added to the list.
air_master.mark_for_update(T)