-
-
Notifications
You must be signed in to change notification settings - Fork 285
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
mc update: init stages, better subsystem init tracking, etc (#6857)
modifies the hollow metrics API; that'll probably be implemented soon adds init stages changes SSatoms to not abuse its `initialized` variable closes #6858
- Loading branch information
Showing
102 changed files
with
1,343 additions
and
925 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
//* Runlevels *// | ||
//* Must be powers of 2. Runlevels should be in order of progression. *// | ||
//* Only subsystem with a runlevel matching the MC's will be ticked. *// | ||
//* The first runlevel (value '1') will be the default runlevel when the MC is first initialized. *// | ||
|
||
/// "Initialize Only" - Used for subsystems that should never be fired (Should also have SS_NO_FIRE set). | ||
#define RUNLEVEL_INIT 0 | ||
/// Initial runlevel before setup. Returns to here if setup fails. | ||
#define RUNLEVEL_LOBBY 1 | ||
/// While the gamemode setup is running. I.E gameticker.setup() | ||
#define RUNLEVEL_SETUP 2 | ||
/// After successful game ticker setup, while the round is running. | ||
#define RUNLEVEL_GAME 4 | ||
/// When round completes but before reboot. | ||
#define RUNLEVEL_POSTGAME 8 | ||
|
||
/// default runlevels for most subsystems | ||
#define RUNLEVELS_DEFAULT (RUNLEVEL_SETUP | RUNLEVEL_GAME | RUNLEVEL_POSTGAME) | ||
/// all valid runlevels - subsystems with this will run all the time after their MC init stage. | ||
#define RUNLEVELS_ALL (RUNLEVEL_LOBBY | RUNLEVEL_SETUP | RUNLEVEL_GAME | RUNLEVEL_POSTGAME) | ||
|
||
var/global/list/runlevel_flags = list(RUNLEVEL_LOBBY, RUNLEVEL_SETUP, RUNLEVEL_GAME, RUNLEVEL_POSTGAME) | ||
/// Convert from the runlevel bitfield constants to index in runlevel_flags list. | ||
#define RUNLEVEL_FLAG_TO_INDEX(flag) (log(2, flag) + 1) | ||
|
||
DEFINE_BITFIELD(runlevels, list( | ||
BITFIELD(RUNLEVEL_INIT), | ||
BITFIELD(RUNLEVEL_LOBBY), | ||
BITFIELD(RUNLEVEL_SETUP), | ||
BITFIELD(RUNLEVEL_GAME), | ||
BITFIELD(RUNLEVEL_POSTGAME), | ||
)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/** | ||
* This file (and its -dash files) is called MC, but actually holds quite a lot of logic including init orders | ||
* and subsystems as the MC and subsystems make up the global orchestration system of the codebase. | ||
*/ | ||
|
||
#define MC_TICK_CHECK ( ( TICK_USAGE > Master.current_ticklimit || src.state != SS_RUNNING ) ? pause() : 0 ) | ||
#define MC_TICK_CHECK_USAGE ( ( TICK_USAGE > Master.current_ticklimit ) ? pause() : 0 ) | ||
|
||
#define MC_SPLIT_TICK_INIT(phase_count) var/original_tick_limit = Master.current_ticklimit; var/split_tick_phases = ##phase_count | ||
#define MC_SPLIT_TICK \ | ||
if(split_tick_phases > 1){\ | ||
Master.current_ticklimit = ((original_tick_limit - TICK_USAGE) / split_tick_phases) + TICK_USAGE;\ | ||
--split_tick_phases;\ | ||
} else {\ | ||
Master.current_ticklimit = original_tick_limit;\ | ||
} | ||
|
||
// Used to smooth out costs to try and avoid oscillation. | ||
#define MC_AVERAGE_FAST(average, current) (0.7 * (average) + 0.3 * (current)) | ||
#define MC_AVERAGE(average, current) (0.8 * (average) + 0.2 * (current)) | ||
#define MC_AVERAGE_SLOW(average, current) (0.9 * (average) + 0.1 * (current)) | ||
|
||
#define MC_AVG_FAST_UP_SLOW_DOWN(average, current) (average > current ? MC_AVERAGE_SLOW(average, current) : MC_AVERAGE_FAST(average, current)) | ||
#define MC_AVG_SLOW_UP_FAST_DOWN(average, current) (average < current ? MC_AVERAGE_SLOW(average, current) : MC_AVERAGE_FAST(average, current)) | ||
|
||
#define START_PROCESSING(Processor, Datum) if (!(Datum.datum_flags & DF_ISPROCESSING)) {Datum.datum_flags |= DF_ISPROCESSING;Processor.processing += Datum} | ||
#define STOP_PROCESSING(Processor, Datum) Datum.datum_flags &= ~DF_ISPROCESSING;Processor.processing -= Datum | ||
|
||
/// Returns true if the MC is initialized and running. | ||
/// Optional argument init_stage controls what stage the mc must have initializted to count as initialized. Defaults to INITSTAGE_MAX if not specified. | ||
#define MC_RUNNING(INIT_STAGE...) (Master && Master.processing > 0 && Master.current_runlevel && Master.init_stage_completed == (max(min(INIT_STAGE_MAX, ##INIT_STAGE), 1))) | ||
/// Returns true if the MC is at atleast a given init stage. Defaults to fully initialized. | ||
/// | ||
/// * This does not check anything else about the MC, including if it's actually running. | ||
#define MC_INITIALIZED(INIT_STAGE...) (Master?.init_stage_completed >= max(INIT_STAGE_MAX, ##INIT_STAGE)) | ||
|
||
//* Recreate_MC() return values *// | ||
|
||
#define MC_RESTART_RTN_FAILED -1 | ||
#define MC_RESTART_RTN_COOLDOWN 0 | ||
#define MC_RESTART_RTN_SUCCESS 1 | ||
|
||
//* Master Controller Loop() return values *// | ||
|
||
/// Unknown or error | ||
#define MC_LOOP_RTN_UNKNOWN 0 | ||
/// New initialize stage happened | ||
#define MC_LOOP_RTN_NEWSTAGES 1 | ||
/// We want the MC to exit. | ||
#define MC_LOOP_RTN_GRACEFUL_EXIT 2 | ||
|
||
//* Master Controller RunQueue() return values *// | ||
|
||
/// Unknown or error | ||
#define MC_RUN_RTN_UNKNOWN 0 | ||
/// Success; full completion | ||
#define MC_RUN_RTN_FULL_COMPLETION 1 | ||
/// Atleast one subsystem was sleeping or pausing | ||
#define MC_RUN_RTN_PARTIAL_COMPLETION 2 |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
//* Initialization Stages *// | ||
//* After each stage, the MC starts ticking that stage while later stages are still waiting to init. *// | ||
//* MC init stages must be a positive number, and init stages must all be consequetive! *// | ||
|
||
/// Early initializations required for server function; database, timers, tgui, etc | ||
#define INIT_STAGE_BACKEND 1 | ||
/// Pre-mapload initializations | ||
#define INIT_STAGE_EARLY 2 | ||
/// Mapload | ||
#define INIT_STAGE_WORLD 3 | ||
/// Late | ||
#define INIT_STAGE_LATE 4 | ||
|
||
/// Last init stage we need to do. | ||
/// | ||
/// * This must be set to the maximum INIT_STAGE. | ||
#define INIT_STAGE_MAX 4 | ||
|
||
//* Initialization Orders *// | ||
|
||
/** | ||
*! Subsystem init_order, from highest priority to lowest priority. | ||
*? Subsystems shutdown in the reverse of the order they initialize in. | ||
*? Subsystems should always have init_order defined, even if they don't initialize, if they use init. | ||
*? The numbers just define the ordering, they are meaningless otherwise. | ||
*/ | ||
|
||
//* Backend *// | ||
|
||
#define INIT_ORDER_FAIL2TOPIC 100 | ||
#define INIT_ORDER_DBCORE 50 | ||
#define INIT_ORDER_REPOSITORY 25 | ||
#define INIT_ORDER_TIMER 10 | ||
#define INIT_ORDER_STATPANELS 0 | ||
|
||
//* Early *// | ||
|
||
#define INIT_ORDER_EARLY_INIT 200 | ||
#define INIT_ORDER_INPUT 170 | ||
#define INIT_ORDER_PREFERENCES 150 | ||
#define INIT_ORDER_JOBS 125 | ||
#define INIT_ORDER_ASSETS 100 | ||
#define INIT_ORDER_INSTRUMENTS 50 | ||
#define INIT_ORDER_AI_SCHEDULING 25 | ||
#define INIT_ORDER_AI_MOVEMENT 25 | ||
#define INIT_ORDER_AI_HOLDERS 25 | ||
|
||
//* World *// | ||
|
||
#define INIT_ORDER_CHARACTERS 140 | ||
#define INIT_ORDER_SOUNDS 130 | ||
#define INIT_ORDER_GARBAGE 120 | ||
#define INIT_ORDER_VIS 90 | ||
#define INIT_ORDER_SERVER_MAINT 75 | ||
#define INIT_ORDER_MEDIA_TRACKS 65 | ||
#define INIT_ORDER_CHEMISTRY 60 | ||
#define INIT_ORDER_MATERIALS 55 | ||
#define INIT_ORDER_PHOTOGRAPHY 50 | ||
#define INIT_ORDER_MAPPING 45 | ||
#define INIT_ORDER_SPATIAL_GRIDS 43 //! must be after SSmapping so we know world.maxx and world.maxy | ||
#define INIT_ORDER_GAME_WORLD 40 | ||
#define INIT_ORDER_LEGACY_ATC 37 | ||
#define INIT_ORDER_LEGACY_LORE 35 | ||
#define INIT_ORDER_PLANTS 25 | ||
#define INIT_ORDER_ALARMS 20 | ||
#define INIT_ORDER_RESEARCH 17 | ||
#define INIT_ORDER_ATOMS 15 | ||
#define INIT_ORDER_MACHINES 10 | ||
#define INIT_ORDER_SHUTTLES 3 | ||
#define INIT_ORDER_DEFAULT 0 | ||
#define INIT_ORDER_AIR -1 | ||
#define INIT_ORDER_PLANETS -2 | ||
#define INIT_ORDER_PERSISTENCE -3 | ||
#define INIT_ORDER_AMBIENT_OCCLUSION -5 | ||
#define INIT_ORDER_HOLOMAPS -5 | ||
#define INIT_ORDER_ICON_SMOOTHING -6 | ||
#define INIT_ORDER_EVENTS -10 | ||
#define INIT_ORDER_OVERMAPS -20 | ||
#define INIT_ORDER_TICKER -30 | ||
#define INIT_ORDER_LIGHTING -40 | ||
#define INIT_ORDER_ZMIMIC -45 | ||
#define INIT_ORDER_AMBIENT_LIGHT -46 | ||
#define INIT_ORDER_XENOARCH -50 | ||
#define INIT_ORDER_CIRCUIT -60 | ||
#define INIT_ORDER_AI -70 | ||
|
||
//* Late *// | ||
|
||
#define INIT_ORDER_OVERLAY 200 | ||
#define INIT_ORDER_TITLESCREEN 150 | ||
#define INIT_ORDER_NIGHTSHIFT 75 | ||
#define INIT_ORDER_CHAT -100 //! Should be last to ensure chat remains smooth during init. |
Oops, something went wrong.