Moves adjacent air into the main atmos subsystem (#64559)

We should just straight up not be processing turfs if the adjacent turf
isn't correctly setup

It used to be on a seperate subsystem with a second wait with the idea
of reducing the cost of explosions, but since they're instant now
there's no reason to not just have it on SSair. Gets rid of my excuse
for process_cell runtimes too
This commit is contained in:
LemonInTheDark
2022-02-03 07:58:36 -08:00
committed by GitHub
parent e0c52238fa
commit 597902f745
5 changed files with 40 additions and 46 deletions
@@ -1,41 +0,0 @@
SUBSYSTEM_DEF(adjacent_air)
name = "Atmos Adjacency"
flags = SS_BACKGROUND
runlevels = RUNLEVEL_GAME | RUNLEVEL_POSTGAME
wait = 10
priority = FIRE_PRIORITY_ATMOS_ADJACENCY
var/list/queue = list()
/datum/controller/subsystem/adjacent_air/stat_entry(msg)
#ifdef TESTING
msg = "P:[length(queue)], S:[GLOB.atmos_adjacent_savings[1]], T:[GLOB.atmos_adjacent_savings[2]]"
#else
msg = "P:[length(queue)]"
#endif
return ..()
/datum/controller/subsystem/adjacent_air/Initialize()
while(length(queue))
fire(mc_check = FALSE)
return ..()
/datum/controller/subsystem/adjacent_air/fire(resumed = FALSE, mc_check = TRUE)
var/list/queue = src.queue
while (length(queue))
var/turf/currT = queue[1]
var/goal = queue[currT]
queue.Cut(1,2)
currT.immediate_calculate_adjacent_turfs()
if(goal == MAKE_ACTIVE)
SSair.add_to_active(currT)
else if(goal == KILL_EXCITED)
SSair.add_to_active(currT, TRUE)
if(mc_check)
if(MC_TICK_CHECK)
break
else
CHECK_TICK
+38 -1
View File
@@ -17,6 +17,7 @@ SUBSYSTEM_DEF(air)
var/cost_pipenets = 0
var/cost_atmos_machinery = 0
var/cost_rebuilds = 0
var/cost_adjacent = 0
var/list/excited_groups = list()
var/list/active_turfs = list()
@@ -25,10 +26,12 @@ SUBSYSTEM_DEF(air)
var/list/rebuild_queue = list()
//Subservient to rebuild queue
var/list/expansion_queue = list()
/// List of turfs to recalculate adjacent turfs on before processing
var/list/adjacent_rebuild = list()
/// A list of machines that will be processed when currentpart == SSAIR_ATMOSMACHINERY. Use SSair.begin_processing_machine and SSair.stop_processing_machine to add and remove machines.
var/list/obj/machinery/atmos_machinery = list()
var/list/pipe_init_dirs_cache = list()
var/list/pipe_init_dirs_cache = list()
//atmos singletons
var/list/gas_reactions = list()
var/list/atmos_gen
@@ -59,6 +62,7 @@ SUBSYSTEM_DEF(air)
msg += "AM:[round(cost_atmos_machinery,1)]|"
msg += "AO:[round(cost_atoms, 1)]|"
msg += "RB:[round(cost_rebuilds,1)]|"
msg += "AJ:[round(cost_adjacent,1)]|"
msg += "} "
msg += "AT:[active_turfs.len]|"
msg += "HS:[hotspots.len]|"
@@ -70,6 +74,7 @@ SUBSYSTEM_DEF(air)
msg += "AO:[atom_process.len]|"
msg += "RB:[rebuild_queue.len]|"
msg += "EP:[expansion_queue.len]|"
msg += "AJ:[adjacent_rebuild.len]|"
msg += "AT/MS:[round((cost ? active_turfs.len/cost : 0),0.1)]"
return ..()
@@ -82,6 +87,7 @@ SUBSYSTEM_DEF(air)
setup_atmos_machinery()
setup_pipenets()
setup_turf_visuals()
process_adjacent_rebuild()
return ..()
@@ -90,6 +96,16 @@ SUBSYSTEM_DEF(air)
//Rebuilds can happen at any time, so this needs to be done outside of the normal system
cost_rebuilds = 0
cost_adjacent = 0
// We need to have a solid setup for turfs before fire, otherwise we'll get massive runtimes and strange behavior
if(length(adjacent_rebuild))
timer = TICK_USAGE_REAL
process_adjacent_rebuild()
//This does mean that the apperent rebuild costs fluctuate very quickly, this is just the cost of having them always process, no matter what
cost_adjacent = TICK_USAGE_REAL - timer
if(state != SS_RUNNING)
return
// Every time we fire, we want to make sure pipenets are rebuilt. The game state could have changed between each fire() proc call
// and anything missing a pipenet can lead to unintended behaviour at worse and various runtimes at best.
@@ -206,6 +222,7 @@ SUBSYSTEM_DEF(air)
networks = SSair.networks
rebuild_queue = SSair.rebuild_queue
expansion_queue = SSair.expansion_queue
adjacent_rebuild = SSair.adjacent_rebuild
atmos_machinery = SSair.atmos_machinery
pipe_init_dirs_cache = SSair.pipe_init_dirs_cache
gas_reactions = SSair.gas_reactions
@@ -217,6 +234,26 @@ SUBSYSTEM_DEF(air)
currentrun = SSair.currentrun
queued_for_activation = SSair.queued_for_activation
/datum/controller/subsystem/air/proc/process_adjacent_rebuild(init = FALSE)
var/list/queue = adjacent_rebuild
while (length(queue))
var/turf/currT = queue[1]
var/goal = queue[currT]
queue.Cut(1,2)
currT.immediate_calculate_adjacent_turfs()
if(goal == MAKE_ACTIVE)
add_to_active(currT)
else if(goal == KILL_EXCITED)
add_to_active(currT, TRUE)
if(init)
CHECK_TICK
else
if(MC_TICK_CHECK)
break
/datum/controller/subsystem/air/proc/process_pipenets(resumed = FALSE)
if (!resumed)
src.currentrun = networks.Copy()