Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Tsar-Salat authored Nov 24, 2023
1 parent 2ea9b6f commit a8c489b
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions code/controllers/subsystem.dm
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,16 @@
var/next_fire = 0 //scheduled world.time for next fire()
var/cost = 0 //average time to execute
var/tick_usage = 0 //average tick usage
var/tick_overrun = 0 //average tick overrun
var/state = SS_IDLE //tracks the current state of the ss, running, paused, etc.
/// Running average of the amount of tick usage (in percents of a game tick) the subsystem has spent past its allocated time without pausing
var/tick_overrun = 0

/// How much of a tick (in percents of a tick) were we allocated last fire.
var/tick_allocation_last = 0

/// How much of a tick (in percents of a tick) do we get allocated by the mc on avg.
var/tick_allocation_avg = 0
/// Tracks the current execution state of the subsystem. Used to handle subsystems that sleep in fire so the mc doesn't run them again while they are sleeping
var/state = SS_IDLE
var/paused_ticks = 0 //ticks this ss is taking to run right now.
var/paused_tick_usage //total tick_usage of all of our runs while pausing this run
var/ticks = 1 //how many ticks does this ss take to run on avg.
Expand All @@ -46,8 +54,14 @@
return

//This is used so the mc knows when the subsystem sleeps. do not override.
/datum/controller/subsystem/proc/ignite(resumed = 0)
set waitfor = 0
/datum/controller/subsystem/proc/ignite(resumed = FALSE)
SHOULD_NOT_OVERRIDE(TRUE)
set waitfor = FALSE
. = SS_IDLE

tick_allocation_last = Master.current_ticklimit-(TICK_USAGE)
tick_allocation_avg = MC_AVERAGE(tick_allocation_avg, tick_allocation_last)

. = SS_SLEEPING
fire(resumed)
. = state
Expand Down

0 comments on commit a8c489b

Please sign in to comment.