From 493ee57b097aee73ccb4d090db4fc67ba69c39b2 Mon Sep 17 00:00:00 2001 From: SkyratBot <59378654+SkyratBot@users.noreply.github.com> Date: Sat, 23 Jan 2021 19:09:23 +0100 Subject: [PATCH] [MIRROR] Prevents the most common case of fire settling with an excited group (#2845) * Prevents the most common case of fire settling with an excited group (#56317) Basically when a group with a breakdown timer one tick away from settling merges with a group with hotspots in it, and the one with a high breakdown timer is larger, the group would settle without respecting the timer of the hotspot group, causing fwoosh levels of flame. There's two other ways to achieve this, if you had one group of tiles that are close to the same gasmix as another group, and they became inactive, we'd have the same issue. I've solved this by moving the hotspot subprocess to after active turfs and before excited groups, just for safety ya feel me? It's still in theory possible, but much much harder. The hard solution to this would be to integrate heat with how we reset excited group timers, and split excited groups into smaller portions, but I'm not sure I like that idea. I need to mull it over. * Prevents the most common case of fire settling with an excited group Co-authored-by: LemonInTheDark <58055496+LemonInTheDark@users.noreply.github.com> --- code/__DEFINES/subsystems.dm | 8 ++--- code/controllers/subsystem/air.dm | 35 ++++++++++--------- .../environmental/LINDA_turf_tile.dm | 4 ++- 3 files changed, 25 insertions(+), 22 deletions(-) diff --git a/code/__DEFINES/subsystems.dm b/code/__DEFINES/subsystems.dm index 7620b53504c..6b512314c76 100644 --- a/code/__DEFINES/subsystems.dm +++ b/code/__DEFINES/subsystems.dm @@ -232,10 +232,10 @@ #define SSAIR_PIPENETS 1 #define SSAIR_ATMOSMACHINERY 2 #define SSAIR_ACTIVETURFS 3 -#define SSAIR_EXCITEDCLEANUP 4 -#define SSAIR_EXCITEDGROUPS 5 -#define SSAIR_HIGHPRESSURE 6 -#define SSAIR_HOTSPOTS 7 +#define SSAIR_HOTSPOTS 4 +#define SSAIR_EXCITEDCLEANUP 5 +#define SSAIR_EXCITEDGROUPS 6 +#define SSAIR_HIGHPRESSURE 7 #define SSAIR_SUPERCONDUCTIVITY 8 #define SSAIR_PROCESS_ATOMS 9 diff --git a/code/controllers/subsystem/air.dm b/code/controllers/subsystem/air.dm index b23e95c9021..32aa9afcbb1 100644 --- a/code/controllers/subsystem/air.dm +++ b/code/controllers/subsystem/air.dm @@ -9,14 +9,14 @@ SUBSYSTEM_DEF(air) var/cached_cost = 0 var/cost_atoms = 0 var/cost_turfs = 0 + var/cost_hotspots = 0 + var/cost_ex_cleanup = 0 var/cost_groups = 0 var/cost_highpressure = 0 - var/cost_hotspots = 0 var/cost_superconductivity = 0 var/cost_pipenets = 0 - var/cost_rebuilds = 0 var/cost_atmos_machinery = 0 - var/cost_ex_cleanup = 0 + var/cost_rebuilds = 0 var/list/excited_groups = list() var/list/cleanup_ex_groups = list() @@ -50,10 +50,10 @@ SUBSYSTEM_DEF(air) /datum/controller/subsystem/air/stat_entry(msg) msg += "C:{" msg += "AT:[round(cost_turfs,1)]|" + msg += "HS:[round(cost_hotspots,1)]|" msg += "CL:[round(cost_ex_cleanup, 1)]|" msg += "EG:[round(cost_groups,1)]|" msg += "HP:[round(cost_highpressure,1)]|" - msg += "HS:[round(cost_hotspots,1)]|" msg += "SC:[round(cost_superconductivity,1)]|" msg += "PN:[round(cost_pipenets,1)]|" msg += "AM:[round(cost_atmos_machinery,1)]|" @@ -61,14 +61,15 @@ SUBSYSTEM_DEF(air) msg += "RB:[round(cost_rebuilds,1)]|" msg += "} " msg += "AT:[active_turfs.len]|" + msg += "HS:[hotspots.len]|" msg += "CL:[cleanup_ex_groups.len]|" msg += "EG:[excited_groups.len]|" msg += "HP:[high_pressure_delta.len]|" - msg += "HS:[hotspots.len]|" msg += "SC:[active_super_conductivity.len]|" msg += "PN:[networks.len]|" msg += "AM:[atmos_machinery.len]|" msg += "AO:[atom_process.len]|" + msg += "RB:[pipenets_needing_rebuilt.len]|" msg += "AT/MS:[round((cost ? active_turfs.len/cost : 0),0.1)]" return ..() @@ -138,6 +139,18 @@ SUBSYSTEM_DEF(air) return cost_turfs = MC_AVERAGE(cost_turfs, TICK_DELTA_TO_MS(cached_cost)) resumed = FALSE + currentpart = SSAIR_HOTSPOTS + + if(currentpart == SSAIR_HOTSPOTS) //We do this before excited groups to allow breakdowns to be independent of adding turfs while still *mostly preventing mass fires + timer = TICK_USAGE_REAL + if(!resumed) + cached_cost = 0 + process_hotspots(delta_time, resumed) + cached_cost += TICK_USAGE_REAL - timer + if(state != SS_RUNNING) + return + cost_hotspots = MC_AVERAGE(cost_hotspots, TICK_DELTA_TO_MS(cached_cost)) + resumed = FALSE currentpart = SSAIR_EXCITEDCLEANUP if(currentpart == SSAIR_EXCITEDCLEANUP) @@ -174,18 +187,6 @@ SUBSYSTEM_DEF(air) return cost_highpressure = MC_AVERAGE(cost_highpressure, TICK_DELTA_TO_MS(cached_cost)) resumed = FALSE - currentpart = SSAIR_HOTSPOTS - - if(currentpart == SSAIR_HOTSPOTS) - timer = TICK_USAGE_REAL - if(!resumed) - cached_cost = 0 - process_hotspots(delta_time, resumed) - cached_cost += TICK_USAGE_REAL - timer - if(state != SS_RUNNING) - return - cost_hotspots = MC_AVERAGE(cost_hotspots, TICK_DELTA_TO_MS(cached_cost)) - resumed = FALSE currentpart = SSAIR_SUPERCONDUCTIVITY if(currentpart == SSAIR_SUPERCONDUCTIVITY) diff --git a/code/modules/atmospherics/environmental/LINDA_turf_tile.dm b/code/modules/atmospherics/environmental/LINDA_turf_tile.dm index 3e9aa5b6315..13b9577a9e7 100644 --- a/code/modules/atmospherics/environmental/LINDA_turf_tile.dm +++ b/code/modules/atmospherics/environmental/LINDA_turf_tile.dm @@ -439,6 +439,7 @@ if(should_display || SSair.display_all_groups) E.hide_turfs() display_turfs() + breakdown_cooldown = min(breakdown_cooldown, E.breakdown_cooldown) //Take the smaller of the two options dismantle_cooldown = 0 else SSair.excited_groups -= src @@ -446,11 +447,12 @@ var/turf/open/T = t T.excited_group = E E.turf_list += T - E.dismantle_cooldown = 0 E.should_display = E.should_display | should_display if(E.should_display || SSair.display_all_groups) hide_turfs() E.display_turfs() + E.breakdown_cooldown = min(breakdown_cooldown, E.breakdown_cooldown) + E.dismantle_cooldown = 0 /datum/excited_group/proc/reset_cooldowns() breakdown_cooldown = 0