Subsystem base class ![code/controllers/subsystem.dm 10](git.png)
Defines a subsystem to be managed by the Master Controller
Simply define a child of this subsystem, using the [SUBSYSTEM_DEF] macro, and the MC will handle registration. Changing the name is required
Vars | |
can_fire | Set to 0 to prevent fire() calls, mostly for admin use or subsystems that may be resumed later use the SS_NO_FIRE flag instead for systems that never fire to keep it from even being added to list that is checked every tick |
---|---|
cost | Running average of the amount of milliseconds it takes the subsystem to complete a run (including all resumes but not the time spent paused) |
failure_strikes | How many times we suspect a subsystem type has crashed the MC, 3 strikes and you're out! |
flags | Subsystem Flags to control binary behavior. Flags must be set at compile time or before preinit finishes to take full effect. (You can also restart the mc to force them to process again) |
init_order | Order of initialization. Higher numbers are initialized first, lower numbers later. Use or create defines such as [INIT_ORDER_DEFAULT] so we can see the order in one file. |
init_stage | Which stage does this subsystem init at. Earlier stages can fire while later stages init. |
initialization_failure_message | String to store an applicable error message for a subsystem crashing, used to help debug crashes in contexts such as Continuous Integration/Unit Tests |
initialized | This var is set to TRUE after the subsystem has been initialized. |
last_fire | Last world.time the subsystem completed a run (as in wasn't paused by [MC_TICK_CHECK]) |
name | Name of the subsystem - you must change this |
next_fire | Scheduled world.time for next fire() |
paused_tick_usage | Tracks how much of a tick the subsystem has consumed in the current run |
paused_ticks | Tracks how many fires the subsystem has consecutively paused on in the current run |
postponed_fires | How many fires have we been requested to postpone |
priority | Priority Weight: When multiple subsystems need to run in the same tick, higher priority subsystems will be given a higher share of the tick before MC_TICK_CHECK triggers a sleep, higher priority subsystems also run before lower priority subsystems |
profiler_focused | boolean set by admins. if TRUE then this subsystem will stop the world profiler after ignite() returns and start it again when called. used so that you can audit a specific subsystem or group of subsystems' synchronous call chain. |
queue_next | Next subsystem in the queue of subsystems to run this tick |
queue_prev | Previous subsystem in the queue of subsystems to run this tick |
queued_priority | Priority at the time the subsystem entered the queue. Needed to avoid changes in priority (by admins and the like) from breaking things. |
queued_time | Time the subsystem entered the queue, (for timing and priority reasons) |
rolling_usage | Flat list of usage and time, every odd index is a log time, every even index is a usage |
runlevels | Bitmap of what game states can this subsystem fire at. See [RUNLEVELS_DEFAULT] for more details. |
slept_count | Tracks how many times a subsystem has ever slept in fire(). |
state | 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 |
tick_allocation_avg | How much of a tick (in percents of a tick) do we get allocated by the mc on avg. |
tick_allocation_last | How much of a tick (in percents of a tick) were we allocated last fire. |
tick_overrun | Running average of the amount of tick usage (in percents of a game tick) the subsystem has spent past its allocated time without pausing |
tick_usage | Running average of the amount of tick usage in percents of a tick it takes the subsystem to complete a run |
ticks | Tracks how many fires the subsystem takes to complete a run on average. |
times_fired | Tracks the amount of completed runs for the subsystem |
wait | Time to wait (in deciseconds) between each call to fire(). Must be a positive integer. |
Procs | |
Initialize | Used to initialize the subsystem. This is expected to be overridden by subtypes. |
OnConfigLoad | Called after the config has been loaded or reloaded. |
PreInit | datum/controller/subsystem/New() |
enqueue | Queue it to run. (we loop thru a linked list until we get to the end or find the right point) (this lets us sort our run order correctly without having to re-sort the entire already sorted list) |
fire | 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. Sleeping in here prevents future fires until returned. |
ignite | This is used so the mc knows when the subsystem sleeps. do not override. |
postpone | Causes the next "cycle" fires to be missed. Effect is accumulative but can reset by calling update_nextfire(reset_time = TRUE) |
prune_rolling_usage | Prunes out of date entries in our rolling usage list |
update_nextfire |
Var Details
can_fire ![code/controllers/subsystem.dm 36](git.png)
Set to 0 to prevent fire() calls, mostly for admin use or subsystems that may be resumed later use the SS_NO_FIRE flag instead for systems that never fire to keep it from even being added to list that is checked every tick
cost ![code/controllers/subsystem.dm 58](git.png)
Running average of the amount of milliseconds it takes the subsystem to complete a run (including all resumes but not the time spent paused)
failure_strikes ![code/controllers/subsystem.dm 103](git.png)
How many times we suspect a subsystem type has crashed the MC, 3 strikes and you're out!
flags ![code/controllers/subsystem.dm 26](git.png)
Subsystem Flags to control binary behavior. Flags must be set at compile time or before preinit finishes to take full effect. (You can also restart the mc to force them to process again)
init_order ![code/controllers/subsystem.dm 17](git.png)
Order of initialization. Higher numbers are initialized first, lower numbers later. Use or create defines such as [INIT_ORDER_DEFAULT] so we can see the order in one file.
init_stage ![code/controllers/subsystem.dm 29](git.png)
Which stage does this subsystem init at. Earlier stages can fire while later stages init.
initialization_failure_message ![code/controllers/subsystem.dm 111](git.png)
String to store an applicable error message for a subsystem crashing, used to help debug crashes in contexts such as Continuous Integration/Unit Tests
initialized ![code/controllers/subsystem.dm 32](git.png)
This var is set to TRUE after the subsystem has been initialized.
last_fire ![code/controllers/subsystem.dm 52](git.png)
Last world.time the subsystem completed a run (as in wasn't paused by [MC_TICK_CHECK])
name ![code/controllers/subsystem.dm 14](git.png)
Name of the subsystem - you must change this
next_fire ![code/controllers/subsystem.dm 55](git.png)
Scheduled world.time for next fire()
paused_tick_usage ![code/controllers/subsystem.dm 85](git.png)
Tracks how much of a tick the subsystem has consumed in the current run
paused_ticks ![code/controllers/subsystem.dm 82](git.png)
Tracks how many fires the subsystem has consecutively paused on in the current run
postponed_fires ![code/controllers/subsystem.dm 94](git.png)
How many fires have we been requested to postpone
priority ![code/controllers/subsystem.dm 23](git.png)
Priority Weight: When multiple subsystems need to run in the same tick, higher priority subsystems will be given a higher share of the tick before MC_TICK_CHECK triggers a sleep, higher priority subsystems also run before lower priority subsystems
profiler_focused ![code/controllers/subsystem.dm 45](git.png)
boolean set by admins. if TRUE then this subsystem will stop the world profiler after ignite() returns and start it again when called. used so that you can audit a specific subsystem or group of subsystems' synchronous call chain.
queue_next ![code/controllers/subsystem.dm 106](git.png)
Next subsystem in the queue of subsystems to run this tick
queue_prev ![code/controllers/subsystem.dm 108](git.png)
Previous subsystem in the queue of subsystems to run this tick
queued_priority ![code/controllers/subsystem.dm 100](git.png)
Priority at the time the subsystem entered the queue. Needed to avoid changes in priority (by admins and the like) from breaking things.
queued_time ![code/controllers/subsystem.dm 97](git.png)
Time the subsystem entered the queue, (for timing and priority reasons)
rolling_usage ![code/controllers/subsystem.dm 67](git.png)
Flat list of usage and time, every odd index is a log time, every even index is a usage
runlevels ![code/controllers/subsystem.dm 39](git.png)
Bitmap of what game states can this subsystem fire at. See [RUNLEVELS_DEFAULT] for more details.
slept_count ![code/controllers/subsystem.dm 79](git.png)
Tracks how many times a subsystem has ever slept in fire().
state ![code/controllers/subsystem.dm 76](git.png)
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
tick_allocation_avg ![code/controllers/subsystem.dm 73](git.png)
How much of a tick (in percents of a tick) do we get allocated by the mc on avg.
tick_allocation_last ![code/controllers/subsystem.dm 70](git.png)
How much of a tick (in percents of a tick) were we allocated last fire.
tick_overrun ![code/controllers/subsystem.dm 64](git.png)
Running average of the amount of tick usage (in percents of a game tick) the subsystem has spent past its allocated time without pausing
tick_usage ![code/controllers/subsystem.dm 61](git.png)
Running average of the amount of tick usage in percents of a tick it takes the subsystem to complete a run
ticks ![code/controllers/subsystem.dm 88](git.png)
Tracks how many fires the subsystem takes to complete a run on average.
times_fired ![code/controllers/subsystem.dm 91](git.png)
Tracks the amount of completed runs for the subsystem
wait ![code/controllers/subsystem.dm 20](git.png)
Time to wait (in deciseconds) between each call to fire(). Must be a positive integer.
Proc Details
Initialize
Used to initialize the subsystem. This is expected to be overridden by subtypes.
OnConfigLoad
Called after the config has been loaded or reloaded.
PreInit
datum/controller/subsystem/New()
enqueue
Queue it to run. (we loop thru a linked list until we get to the end or find the right point) (this lets us sort our run order correctly without having to re-sort the entire already sorted list)
fire
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. Sleeping in here prevents future fires until returned.
ignite
This is used so the mc knows when the subsystem sleeps. do not override.
postpone
Causes the next "cycle" fires to be missed. Effect is accumulative but can reset by calling update_nextfire(reset_time = TRUE)
prune_rolling_usage
Prunes out of date entries in our rolling usage list
update_nextfire
- Update next_fire for the next run.
- reset_time (bool) - Ignore things that would normally alter the next fire, like tick_overrun, and last_fire. (also resets postpone)