diff --git a/code/__DEFINES/_profile.dm b/code/__DEFINES/_profile.dm new file mode 100644 index 00000000000..41047b8b7ba --- /dev/null +++ b/code/__DEFINES/_profile.dm @@ -0,0 +1,4 @@ +#if DM_BUILD >= 1506 +// We don't actually care about storing the output here, this is just an easy way to ensure the profile runs first. +GLOBAL_REAL_VAR(world_init_profiler) = world.Profile(PROFILE_START) +#endif diff --git a/code/controllers/subsystem/profiler.dm b/code/controllers/subsystem/profiler.dm index 019945b3d16..b3e972bdef4 100644 --- a/code/controllers/subsystem/profiler.dm +++ b/code/controllers/subsystem/profiler.dm @@ -18,7 +18,7 @@ SUBSYSTEM_DEF(profiler) if(CONFIG_GET(flag/auto_profile)) StartProfiling() else - StopProfiling() //Stop the early start from world/New + StopProfiling() //Stop the early start profiler return ..() /datum/controller/subsystem/profiler/fire() diff --git a/code/game/world.dm b/code/game/world.dm index 28d009a2f84..4ed77a3ad44 100644 --- a/code/game/world.dm +++ b/code/game/world.dm @@ -5,18 +5,28 @@ GLOBAL_VAR(restart_counter) /** * World creation * - * Here is where a round itself is actually begun and setup, lots of important config changes happen here + * Here is where a round itself is actually begun and setup. * * db connection setup * * config loaded from files * * loads admins * * Sets up the dynamic menu system * * and most importantly, calls initialize on the master subsystem, starting the game loop that causes the rest of the game to begin processing and setting up * - * Note this happens after the Master subsystem is created (as that is a global datum), this means all the subsystems exist, - * but they have not been Initialized at this point, only their New proc has run * * Nothing happens until something moves. ~Albert Einstein * + * For clarity, this proc gets triggered later in the initialization pipeline, it is not the first thing to happen, as it might seem. + * + * Initialization Pipeline: + * Global vars are new()'ed, (including config, glob, and the master controller will also new and preinit all subsystems when it gets new()ed) + * Compiled in maps are loaded (mainly centcom). all areas/turfs/objs/mobs(ATOMs) in these maps will be new()ed + * world/New() (You are here) + * Once world/New() returns, client's can connect. + * 1 second sleep + * Master Controller initialization. + * Subsystem initialization. + * Non-compiled-in maps are maploaded, all atoms are new()ed + * All atoms in both compiled and uncompiled maps are initialized() */ /world/New() var/extools = world.GetConfig("env", "EXTOOLS_DLL") || (world.system_type == MS_WINDOWS ? "./byond-extools.dll" : "./libbyond-extools.so") @@ -27,11 +37,6 @@ GLOBAL_VAR(restart_counter) enable_reference_tracking() #endif - //Early profile for auto-profiler - will be stopped on profiler init if necessary. -#if DM_BUILD >= 1506 - world.Profile(PROFILE_START) -#endif - log_world("World loaded at [time_stamp()]!") make_datum_references_lists() //initialises global lists for referencing frequently used datums (so that we only ever do it once) diff --git a/tgstation.dme b/tgstation.dme index f271bd78046..c48135c245a 100644 --- a/tgstation.dme +++ b/tgstation.dme @@ -18,6 +18,7 @@ #include "code\world.dm" #include "code\__DEFINES\_globals.dm" #include "code\__DEFINES\_helpers.dm" +#include "code\__DEFINES\_profile.dm" #include "code\__DEFINES\_protect.dm" #include "code\__DEFINES\_tick.dm" #include "code\__DEFINES\access.dm"