From 032d26010b5ff7a1fd94240f0f817d51c66ff504 Mon Sep 17 00:00:00 2001 From: Leshana Date: Wed, 27 Dec 2017 18:58:51 -0500 Subject: [PATCH] Merging changes from /tg https://github.com/tgstation/tgstation/pull/29637 Fixes subsystem MC crash tracking https://github.com/tgstation/tgstation/pull/30092 Subsystem PreInit() now respects init_order --- code/_helpers/sorts/comparators.dm | 2 +- code/controllers/master.dm | 11 ++++++++--- code/controllers/subsystem.dm | 2 +- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/code/_helpers/sorts/comparators.dm b/code/_helpers/sorts/comparators.dm index 8c1f954a00..69e77d5da5 100644 --- a/code/_helpers/sorts/comparators.dm +++ b/code/_helpers/sorts/comparators.dm @@ -13,7 +13,7 @@ // Sorts subsystems by init_order /proc/cmp_subsystem_init(datum/controller/subsystem/a, datum/controller/subsystem/b) - return b.init_order - a.init_order + return initial(b.init_order) - initial(a.init_order) //uses initial() so it can be used on types // Sorts subsystems by priority /proc/cmp_subsystem_priority(datum/controller/subsystem/a, datum/controller/subsystem/b) diff --git a/code/controllers/master.dm b/code/controllers/master.dm index 4ca4bebf0a..a538d887e8 100644 --- a/code/controllers/master.dm +++ b/code/controllers/master.dm @@ -54,13 +54,17 @@ var/datum/controller/master/Master = new() /datum/controller/master/New() // Highlander-style: there can only be one! Kill off the old and replace it with the new. - subsystems = list() + var/list/_subsystems = list() + subsystems = _subsystems if (Master != src) if (istype(Master)) Recover() qdel(Master) else - init_subtypes(/datum/controller/subsystem, subsystems) + var/list/subsytem_types = subtypesof(/datum/controller/subsystem) + sortTim(subsytem_types, /proc/cmp_subsystem_init) + for(var/I in subsytem_types) + _subsystems += new I Master = src /datum/controller/master/Destroy() @@ -114,7 +118,8 @@ var/datum/controller/master/Master = new() var/FireHim = FALSE if(istype(BadBoy)) msg = null - switch(++BadBoy.failure_strikes) + LAZYINITLIST(BadBoy.failure_strikes) + switch(++BadBoy.failure_strikes[BadBoy.type]) if(2) msg = "The [BadBoy.name] subsystem was the last to fire for 2 controller restarts. It will be recovered now and disabled if it happens again." FireHim = TRUE diff --git a/code/controllers/subsystem.dm b/code/controllers/subsystem.dm index 7dff609c76..394786c710 100644 --- a/code/controllers/subsystem.dm +++ b/code/controllers/subsystem.dm @@ -28,7 +28,7 @@ var/datum/controller/subsystem/queue_next var/datum/controller/subsystem/queue_prev - var/static/failure_strikes = 0 //How many times we suspect this subsystem has crashed the MC, 3 strikes and you're out! + var/static/list/failure_strikes //How many times we suspect a subsystem type has crashed the MC, 3 strikes and you're out! //Do not override /datum/controller/subsystem/New()