mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-11 10:43:20 +00:00
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:
@@ -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()
|
||||
|
||||
@@ -77,6 +77,7 @@ Class Procs:
|
||||
fire_tiles.Add(T)
|
||||
air_master.active_fire_zones |= src
|
||||
if(fuel) fuel_objs += fuel
|
||||
if(air.graphic)
|
||||
T.update_graphic(air.graphic)
|
||||
|
||||
/zone/proc/remove(turf/simulated/T)
|
||||
@@ -92,6 +93,7 @@ Class Procs:
|
||||
var/obj/effect/decal/cleanable/liquid_fuel/fuel = locate() in T
|
||||
fuel_objs -= fuel
|
||||
T.zone = null
|
||||
if(air.graphic)
|
||||
T.update_graphic(graphic_remove = air.graphic)
|
||||
if(contents.len)
|
||||
air.group_multiplier = contents.len
|
||||
@@ -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)
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
/datum/gas_mixture/New(vol = CELL_VOLUME)
|
||||
volume = vol
|
||||
gas = list()
|
||||
graphic = list()
|
||||
|
||||
//Takes a gas string and the amount of moles to adjust by. Calls update_values() if update isn't 0.
|
||||
/datum/gas_mixture/proc/adjust_gas(gasid, moles, update = 1)
|
||||
@@ -331,27 +330,24 @@
|
||||
//Rechecks the gas_mixture and adjusts the graphic list if needed.
|
||||
//Two lists can be passed by reference if you need know specifically which graphics were added and removed.
|
||||
/datum/gas_mixture/proc/check_tile_graphic(list/graphic_add = null, list/graphic_remove = null)
|
||||
var/list/cur_graphic = graphic // Cache for sanic speed
|
||||
for(var/g in gas_data.overlay_limit)
|
||||
if(graphic.Find(gas_data.tile_overlay[g]))
|
||||
if(cur_graphic && cur_graphic.Find(gas_data.tile_overlay[g]))
|
||||
//Overlay is already applied for this gas, check if it's still valid.
|
||||
if(gas[g] <= gas_data.overlay_limit[g])
|
||||
if(!graphic_remove)
|
||||
graphic_remove = list()
|
||||
graphic_remove += gas_data.tile_overlay[g]
|
||||
LAZYADD(graphic_remove, gas_data.tile_overlay[g])
|
||||
else
|
||||
//Overlay isn't applied for this gas, check if it's valid and needs to be added.
|
||||
if(gas[g] > gas_data.overlay_limit[g])
|
||||
if(!graphic_add)
|
||||
graphic_add = list()
|
||||
graphic_add += gas_data.tile_overlay[g]
|
||||
LAZYADD(graphic_add, gas_data.tile_overlay[g])
|
||||
|
||||
. = 0
|
||||
//Apply changes
|
||||
if(graphic_add && graphic_add.len)
|
||||
graphic += graphic_add
|
||||
if(LAZYLEN(graphic_add))
|
||||
LAZYADD(graphic, graphic_add)
|
||||
. = 1
|
||||
if(graphic_remove && graphic_remove.len)
|
||||
graphic -= graphic_remove
|
||||
if(LAZYLEN(graphic_remove))
|
||||
LAZYREMOVE(graphic, graphic_remove)
|
||||
. = 1
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user