diff --git a/code/__DEFINES/MC.dm b/code/__DEFINES/MC.dm index 65be8258a1..bad64846d6 100644 --- a/code/__DEFINES/MC.dm +++ b/code/__DEFINES/MC.dm @@ -25,35 +25,38 @@ //SubSystem flags (Please design any new flags so that the default is off, to make adding flags to subsystems easier) //subsystem does not initialize. -#define SS_NO_INIT 1 +#define SS_NO_INIT (1<<0) //subsystem does not fire. // (like can_fire = 0, but keeps it from getting added to the processing subsystems list) // (Requires a MC restart to change) -#define SS_NO_FIRE 2 +#define SS_NO_FIRE (1<<1) //subsystem only runs on spare cpu (after all non-background subsystems have ran that tick) // SS_BACKGROUND has its own priority bracket -#define SS_BACKGROUND 4 +#define SS_BACKGROUND (1<<2) //subsystem does not tick check, and should not run unless there is enough time (or its running behind (unless background)) -#define SS_NO_TICK_CHECK 8 +#define SS_NO_TICK_CHECK (1<<3) //Treat wait as a tick count, not DS, run every wait ticks. // (also forces it to run first in the tick, above even SS_NO_TICK_CHECK subsystems) // (implies all runlevels because of how it works) // (overrides SS_BACKGROUND) // This is designed for basically anything that works as a mini-mc (like SStimer) -#define SS_TICKER 16 +#define SS_TICKER (1<<4) //keep the subsystem's timing on point by firing early if it fired late last fire because of lag // ie: if a 20ds subsystem fires say 5 ds late due to lag or what not, its next fire would be in 15ds, not 20ds. -#define SS_KEEP_TIMING 32 +#define SS_KEEP_TIMING (1<<5) //Calculate its next fire after its fired. // (IE: if a 5ds wait SS takes 2ds to run, its next fire should be 5ds away, not 3ds like it normally would be) // This flag overrides SS_KEEP_TIMING -#define SS_POST_FIRE_TIMING 64 +#define SS_POST_FIRE_TIMING (1<<6) + +/// Show in stat() by default even if SS_NO_FIRE +#define SS_ALWAYS_SHOW_STAT (1<<7) //SUBSYSTEM STATES #define SS_IDLE 0 //aint doing shit. diff --git a/code/controllers/admin.dm b/code/controllers/admin.dm index 19fef28597..28803f0979 100644 --- a/code/controllers/admin.dm +++ b/code/controllers/admin.dm @@ -3,9 +3,7 @@ name = "Initializing..." var/target -INITIALIZE_IMMEDIATE(/obj/effect/statclick) - -/obj/effect/statclick/Initialize(mapload, text, target) //Don't port this to Initialize it's too critical +/obj/effect/statclick/New(loc, text, target) //Don't port this to Initialize it's too critical . = ..() name = text src.target = target @@ -33,6 +31,14 @@ INITIALIZE_IMMEDIATE(/obj/effect/statclick) usr.client.debug_variables(target) message_admins("Admin [key_name_admin(usr)] is debugging the [target] [class].") +/obj/effect/statclick/misc_subsystems/Click() + if(!usr.client.holder) + return + var/subsystem = input(usr, "Debug which subsystem?", "Debug nonprocessing subsystem") as null|anything in (Master.subsystems - Master.statworthy_subsystems) + if(!subsystem) + return + usr.client.debug_variables(subsystem) + message_admins("Admin [key_name_admin(usr)] is debugging the [subsystem] subsystem.") // Debug verbs. /client/proc/restart_controller(controller in list("Master", "Failsafe")) diff --git a/code/controllers/master.dm b/code/controllers/master.dm index db828539af..cdbea1de85 100644 --- a/code/controllers/master.dm +++ b/code/controllers/master.dm @@ -28,6 +28,8 @@ GLOBAL_REAL(Master, /datum/controller/master) = new // List of subsystems to process(). var/list/subsystems + /// List of subsystems to include in the MC stat panel. + var/list/statworthy_subsystems // Vars for keeping track of tick drift. var/init_timeofday @@ -65,6 +67,9 @@ GLOBAL_REAL(Master, /datum/controller/master) = new //used by CHECK_TICK as well so that the procs subsystems call can obey that SS's tick limits var/static/current_ticklimit = TICK_LIMIT_RUNNING + /// Statclick for misc subsystems + var/obj/effect/statclick/misc_subsystems/misc_statclick + /datum/controller/master/New() if(!config) config = new @@ -87,6 +92,11 @@ GLOBAL_REAL(Master, /datum/controller/master) = new _subsystems += new I Master = src + // We want to see all subsystems during init. + statworthy_subsystems = subsystems.Copy() + + misc_statclick = new(null, "Debug") + if(!GLOB) new /datum/controller/global_vars @@ -257,10 +267,14 @@ GLOBAL_REAL(Master, /datum/controller/master) = new var/list/tickersubsystems = list() var/list/runlevel_sorted_subsystems = list(list()) //ensure we always have at least one runlevel var/timer = world.time + statworthy_subsystems = list() for (var/thing in subsystems) var/datum/controller/subsystem/SS = thing if (SS.flags & SS_NO_FIRE) + if(SS.flags & SS_ALWAYS_SHOW_STAT) + statworthy_subsystems += SS continue + statworthy_subsystems += SS SS.queued_time = 0 SS.queue_next = null SS.queue_prev = null @@ -603,7 +617,7 @@ GLOBAL_REAL(Master, /datum/controller/master) = new stat("Byond:", "(FPS:[world.fps]) (TickCount:[world.time/world.tick_lag]) (TickDrift:[round(Master.tickdrift,1)]([round((Master.tickdrift/(world.time/world.tick_lag))*100,0.1)]%)) (Internal Tick Usage: [round(MAPTICK_LAST_INTERNAL_TICK_USAGE,0.1)]%)") stat("Master Controller:", statclick.update("(TickRate:[Master.processing]) (Iteration:[Master.iteration]) (TickLimit: [round(Master.current_ticklimit, 0.1)])")) - + stat("Misc Subsystems", misc_statclick) /datum/controller/master/StartLoadingMap() //disallow more than one map to load at once, multithreading it will just cause race conditions diff --git a/code/modules/mob/mob.dm b/code/modules/mob/mob.dm index b5dc25e4dc..ce3b8bf3d2 100644 --- a/code/modules/mob/mob.dm +++ b/code/modules/mob/mob.dm @@ -593,7 +593,7 @@ GLOBAL_VAR_INIT(exploit_warn_spam_prevention, 0) stat("Failsafe Controller:", "ERROR") if(Master) stat(null) - for(var/datum/controller/subsystem/SS in Master.subsystems) + for(var/datum/controller/subsystem/SS in Master.statworthy_subsystems) SS.stat_entry() GLOB.cameranet.stat_entry() if(statpanel("Tickets"))