Files
Paradise/code/datums/cache/air_alarm.dm
MarcellusPye 0b15e47623 Away mission Central Atmospherics Computer fix (#7633)
* Initial Fix

The pre-round optimisation appears to cause the bug

* Round 2, a bit more optimal

This should be more optimal, the system is still in need of a refactor but this should stop mass load lag.

* Removes githubs numbers

Bad github

* Removed whitespace

Please compile
2017-07-08 20:31:51 -04:00

31 lines
1.3 KiB
Plaintext

var/global/datum/repository/air_alarm/air_alarm_repository = new()
/datum/repository/air_alarm/proc/air_alarm_data(var/list/monitored_alarms, var/refresh = 0, var/obj/machinery/alarm/passed_alarm)
var/alarms[0]
var/datum/cache_entry/cache_entry = cache_data
if(!cache_entry)
cache_entry = new/datum/cache_entry
cache_data = cache_entry
if(!refresh)
return cache_entry.data
if(ticker && ticker.current_state < GAME_STATE_PLAYING && istype(passed_alarm)) // Generating the list for the first time as the game hasn't started - no need to run through the machines list everything every time
alarms = cache_entry.data // Don't deleate the list
if(is_station_contact(passed_alarm.z)) // Still need sanity checks
alarms[++alarms.len] = passed_alarm.get_nano_data_console()
else
for(var/obj/machinery/alarm/alarm in (monitored_alarms ? monitored_alarms : air_alarms)) // Generating the whole list again is a bad habit but I can't be bothered to fix it right now
if(!monitored_alarms && !is_station_contact(alarm.z))
continue
alarms[++alarms.len] = alarm.get_nano_data_console()
cache_entry.timestamp = world.time //+ 10 SECONDS
cache_entry.data = alarms
return alarms
/datum/repository/air_alarm/proc/update_cache(var/obj/machinery/alarm/alarm)
return air_alarm_data(refresh = 1, passed_alarm = alarm)