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
This commit is contained in:
Leshana
2017-12-27 18:58:51 -05:00
parent 2024cc3fac
commit 032d26010b
3 changed files with 10 additions and 5 deletions

View File

@@ -13,7 +13,7 @@
// Sorts subsystems by init_order // Sorts subsystems by init_order
/proc/cmp_subsystem_init(datum/controller/subsystem/a, datum/controller/subsystem/b) /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 // Sorts subsystems by priority
/proc/cmp_subsystem_priority(datum/controller/subsystem/a, datum/controller/subsystem/b) /proc/cmp_subsystem_priority(datum/controller/subsystem/a, datum/controller/subsystem/b)

View File

@@ -54,13 +54,17 @@ var/datum/controller/master/Master = new()
/datum/controller/master/New() /datum/controller/master/New()
// Highlander-style: there can only be one! Kill off the old and replace it with the 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 (Master != src)
if (istype(Master)) if (istype(Master))
Recover() Recover()
qdel(Master) qdel(Master)
else 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 Master = src
/datum/controller/master/Destroy() /datum/controller/master/Destroy()
@@ -114,7 +118,8 @@ var/datum/controller/master/Master = new()
var/FireHim = FALSE var/FireHim = FALSE
if(istype(BadBoy)) if(istype(BadBoy))
msg = null msg = null
switch(++BadBoy.failure_strikes) LAZYINITLIST(BadBoy.failure_strikes)
switch(++BadBoy.failure_strikes[BadBoy.type])
if(2) 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." 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 FireHim = TRUE

View File

@@ -28,7 +28,7 @@
var/datum/controller/subsystem/queue_next var/datum/controller/subsystem/queue_next
var/datum/controller/subsystem/queue_prev 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 //Do not override
/datum/controller/subsystem/New() /datum/controller/subsystem/New()