mirror of
https://github.com/fulpstation/fulpstation.git
synced 2025-12-10 10:01:40 +00:00
Makes the atmos MC entry subprocess cost readings more reliable
This commit is contained in:
@@ -97,9 +97,9 @@
|
|||||||
return
|
return
|
||||||
|
|
||||||
//This is used so the mc knows when the subsystem sleeps. do not override.
|
//This is used so the mc knows when the subsystem sleeps. do not override.
|
||||||
/datum/controller/subsystem/proc/ignite(resumed = 0)
|
/datum/controller/subsystem/proc/ignite(resumed = FALSE)
|
||||||
SHOULD_NOT_OVERRIDE(TRUE)
|
SHOULD_NOT_OVERRIDE(TRUE)
|
||||||
set waitfor = 0
|
set waitfor = FALSE
|
||||||
. = SS_SLEEPING
|
. = SS_SLEEPING
|
||||||
fire(resumed)
|
fire(resumed)
|
||||||
. = state
|
. = state
|
||||||
@@ -114,7 +114,7 @@
|
|||||||
//previously, this would have been named 'process()' but that name is used everywhere for different things!
|
//previously, this would have been named 'process()' but that name is used everywhere for different things!
|
||||||
//fire() seems more suitable. This is the procedure that gets called every 'wait' deciseconds.
|
//fire() seems more suitable. This is the procedure that gets called every 'wait' deciseconds.
|
||||||
//Sleeping in here prevents future fires until returned.
|
//Sleeping in here prevents future fires until returned.
|
||||||
/datum/controller/subsystem/proc/fire(resumed = 0)
|
/datum/controller/subsystem/proc/fire(resumed = FALSE)
|
||||||
flags |= SS_NO_FIRE
|
flags |= SS_NO_FIRE
|
||||||
CRASH("Subsystem [src]([type]) does not fire() but did not set the SS_NO_FIRE flag. Please add the SS_NO_FIRE flag to any subsystem that doesn't fire so it doesn't get added to the processing list and waste cpu.")
|
CRASH("Subsystem [src]([type]) does not fire() but did not set the SS_NO_FIRE flag. Please add the SS_NO_FIRE flag to any subsystem that doesn't fire so it doesn't get added to the processing list and waste cpu.")
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ SUBSYSTEM_DEF(air)
|
|||||||
flags = SS_BACKGROUND
|
flags = SS_BACKGROUND
|
||||||
runlevels = RUNLEVEL_GAME | RUNLEVEL_POSTGAME
|
runlevels = RUNLEVEL_GAME | RUNLEVEL_POSTGAME
|
||||||
|
|
||||||
|
var/cached_cost = 0
|
||||||
var/cost_turfs = 0
|
var/cost_turfs = 0
|
||||||
var/cost_groups = 0
|
var/cost_groups = 0
|
||||||
var/cost_highpressure = 0
|
var/cost_highpressure = 0
|
||||||
@@ -40,7 +41,6 @@ SUBSYSTEM_DEF(air)
|
|||||||
var/list/queued_for_activation
|
var/list/queued_for_activation
|
||||||
var/display_all_groups = FALSE
|
var/display_all_groups = FALSE
|
||||||
|
|
||||||
var/lasttick = 0
|
|
||||||
|
|
||||||
/datum/controller/subsystem/air/stat_entry(msg)
|
/datum/controller/subsystem/air/stat_entry(msg)
|
||||||
msg += "C:{"
|
msg += "C:{"
|
||||||
@@ -78,76 +78,101 @@ SUBSYSTEM_DEF(air)
|
|||||||
var/delta_time = wait * 0.1
|
var/delta_time = wait * 0.1
|
||||||
|
|
||||||
if(currentpart == SSAIR_REBUILD_PIPENETS)
|
if(currentpart == SSAIR_REBUILD_PIPENETS)
|
||||||
|
if(!resumed) //We track the use for each subprocess for the full tick, so we can get an acccurate idea of how much each part costs
|
||||||
|
cached_cost = 0
|
||||||
var/list/pipenet_rebuilds = pipenets_needing_rebuilt
|
var/list/pipenet_rebuilds = pipenets_needing_rebuilt
|
||||||
for(var/thing in pipenet_rebuilds)
|
for(var/thing in pipenet_rebuilds)
|
||||||
var/obj/machinery/atmospherics/AT = thing
|
var/obj/machinery/atmospherics/AT = thing
|
||||||
AT.build_network()
|
AT.build_network()
|
||||||
cost_rebuilds = MC_AVERAGE(cost_rebuilds, TICK_DELTA_TO_MS(TICK_USAGE_REAL - timer))
|
cached_cost += TICK_USAGE_REAL - timer
|
||||||
pipenets_needing_rebuilt.Cut()
|
pipenets_needing_rebuilt.Cut()
|
||||||
if(state != SS_RUNNING)
|
if(state != SS_RUNNING)
|
||||||
return
|
return
|
||||||
|
cost_rebuilds = MC_AVERAGE(cost_rebuilds, TICK_DELTA_TO_MS(cached_cost))
|
||||||
resumed = FALSE
|
resumed = FALSE
|
||||||
currentpart = SSAIR_PIPENETS
|
currentpart = SSAIR_PIPENETS
|
||||||
|
|
||||||
if(currentpart == SSAIR_PIPENETS || !resumed)
|
if(currentpart == SSAIR_PIPENETS || !resumed)
|
||||||
|
timer = TICK_USAGE_REAL
|
||||||
|
if(!resumed)
|
||||||
|
cached_cost = 0
|
||||||
process_pipenets(delta_time, resumed)
|
process_pipenets(delta_time, resumed)
|
||||||
cost_pipenets = MC_AVERAGE(cost_pipenets, TICK_DELTA_TO_MS(TICK_USAGE_REAL - timer))
|
cached_cost += TICK_USAGE_REAL - timer
|
||||||
if(state != SS_RUNNING)
|
if(state != SS_RUNNING)
|
||||||
return
|
return
|
||||||
|
cost_pipenets = MC_AVERAGE(cost_pipenets, TICK_DELTA_TO_MS(cached_cost))
|
||||||
resumed = FALSE
|
resumed = FALSE
|
||||||
currentpart = SSAIR_ATMOSMACHINERY
|
currentpart = SSAIR_ATMOSMACHINERY
|
||||||
|
|
||||||
if(currentpart == SSAIR_ATMOSMACHINERY)
|
if(currentpart == SSAIR_ATMOSMACHINERY)
|
||||||
timer = TICK_USAGE_REAL
|
timer = TICK_USAGE_REAL
|
||||||
|
if(!resumed)
|
||||||
|
cached_cost = 0
|
||||||
process_atmos_machinery(delta_time, resumed)
|
process_atmos_machinery(delta_time, resumed)
|
||||||
cost_atmos_machinery = MC_AVERAGE(cost_atmos_machinery, TICK_DELTA_TO_MS(TICK_USAGE_REAL - timer))
|
cached_cost += TICK_USAGE_REAL - timer
|
||||||
if(state != SS_RUNNING)
|
if(state != SS_RUNNING)
|
||||||
return
|
return
|
||||||
|
cost_atmos_machinery = MC_AVERAGE(cost_atmos_machinery, TICK_DELTA_TO_MS(cached_cost))
|
||||||
resumed = FALSE
|
resumed = FALSE
|
||||||
currentpart = SSAIR_ACTIVETURFS
|
currentpart = SSAIR_ACTIVETURFS
|
||||||
|
|
||||||
if(currentpart == SSAIR_ACTIVETURFS)
|
if(currentpart == SSAIR_ACTIVETURFS)
|
||||||
timer = TICK_USAGE_REAL
|
timer = TICK_USAGE_REAL
|
||||||
|
if(!resumed)
|
||||||
|
cached_cost = 0
|
||||||
process_active_turfs(resumed)
|
process_active_turfs(resumed)
|
||||||
cost_turfs = MC_AVERAGE(cost_turfs, TICK_DELTA_TO_MS(TICK_USAGE_REAL - timer))
|
cached_cost += TICK_USAGE_REAL - timer
|
||||||
if(state != SS_RUNNING)
|
if(state != SS_RUNNING)
|
||||||
return
|
return
|
||||||
|
cost_turfs = MC_AVERAGE(cost_turfs, TICK_DELTA_TO_MS(cached_cost))
|
||||||
resumed = FALSE
|
resumed = FALSE
|
||||||
currentpart = SSAIR_EXCITEDGROUPS
|
currentpart = SSAIR_EXCITEDGROUPS
|
||||||
|
|
||||||
if(currentpart == SSAIR_EXCITEDGROUPS)
|
if(currentpart == SSAIR_EXCITEDGROUPS)
|
||||||
timer = TICK_USAGE_REAL
|
timer = TICK_USAGE_REAL
|
||||||
|
if(!resumed)
|
||||||
|
cached_cost = 0
|
||||||
process_excited_groups(resumed)
|
process_excited_groups(resumed)
|
||||||
cost_groups = MC_AVERAGE(cost_groups, TICK_DELTA_TO_MS(TICK_USAGE_REAL - timer))
|
cached_cost += TICK_USAGE_REAL - timer
|
||||||
if(state != SS_RUNNING)
|
if(state != SS_RUNNING)
|
||||||
return
|
return
|
||||||
|
cost_groups = MC_AVERAGE(cost_groups, TICK_DELTA_TO_MS(cached_cost))
|
||||||
resumed = FALSE
|
resumed = FALSE
|
||||||
currentpart = SSAIR_HIGHPRESSURE
|
currentpart = SSAIR_HIGHPRESSURE
|
||||||
|
|
||||||
if(currentpart == SSAIR_HIGHPRESSURE)
|
if(currentpart == SSAIR_HIGHPRESSURE)
|
||||||
timer = TICK_USAGE_REAL
|
timer = TICK_USAGE_REAL
|
||||||
|
if(!resumed)
|
||||||
|
cached_cost = 0
|
||||||
process_high_pressure_delta(resumed)
|
process_high_pressure_delta(resumed)
|
||||||
cost_highpressure = MC_AVERAGE(cost_highpressure, TICK_DELTA_TO_MS(TICK_USAGE_REAL - timer))
|
cached_cost += TICK_USAGE_REAL - timer
|
||||||
if(state != SS_RUNNING)
|
if(state != SS_RUNNING)
|
||||||
return
|
return
|
||||||
|
cost_highpressure = MC_AVERAGE(cost_highpressure, TICK_DELTA_TO_MS(cached_cost))
|
||||||
resumed = FALSE
|
resumed = FALSE
|
||||||
currentpart = SSAIR_HOTSPOTS
|
currentpart = SSAIR_HOTSPOTS
|
||||||
|
|
||||||
if(currentpart == SSAIR_HOTSPOTS)
|
if(currentpart == SSAIR_HOTSPOTS)
|
||||||
timer = TICK_USAGE_REAL
|
timer = TICK_USAGE_REAL
|
||||||
|
if(!resumed)
|
||||||
|
cached_cost = 0
|
||||||
process_hotspots(delta_time, resumed)
|
process_hotspots(delta_time, resumed)
|
||||||
cost_hotspots = MC_AVERAGE(cost_hotspots, TICK_DELTA_TO_MS(TICK_USAGE_REAL - timer))
|
cached_cost += TICK_USAGE_REAL - timer
|
||||||
if(state != SS_RUNNING)
|
if(state != SS_RUNNING)
|
||||||
return
|
return
|
||||||
|
cost_hotspots = MC_AVERAGE(cost_hotspots, TICK_DELTA_TO_MS(cached_cost))
|
||||||
resumed = FALSE
|
resumed = FALSE
|
||||||
currentpart = SSAIR_SUPERCONDUCTIVITY
|
currentpart = SSAIR_SUPERCONDUCTIVITY
|
||||||
|
|
||||||
if(currentpart == SSAIR_SUPERCONDUCTIVITY)
|
if(currentpart == SSAIR_SUPERCONDUCTIVITY)
|
||||||
timer = TICK_USAGE_REAL
|
timer = TICK_USAGE_REAL
|
||||||
|
if(!resumed)
|
||||||
|
cached_cost = 0
|
||||||
process_super_conductivity(resumed)
|
process_super_conductivity(resumed)
|
||||||
cost_superconductivity = MC_AVERAGE(cost_superconductivity, TICK_DELTA_TO_MS(TICK_USAGE_REAL - timer))
|
cached_cost += TICK_USAGE_REAL - timer
|
||||||
if(state != SS_RUNNING)
|
if(state != SS_RUNNING)
|
||||||
return
|
return
|
||||||
|
cost_superconductivity = MC_AVERAGE(cost_superconductivity, TICK_DELTA_TO_MS(cached_cost))
|
||||||
resumed = FALSE
|
resumed = FALSE
|
||||||
currentpart = SSAIR_REBUILD_PIPENETS
|
currentpart = SSAIR_REBUILD_PIPENETS
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user