Merge pull request #10286 from VOREStation/Arokha/SSabandonship

Adds subsystem crash logging to SSprocess and SSmobs
This commit is contained in:
Novacat
2021-05-10 22:54:31 -04:00
committed by Chompstation Bot
parent cfeb771bd3
commit 1358ad8867
5 changed files with 136 additions and 0 deletions
@@ -60,6 +60,49 @@ SUBSYSTEM_DEF(processing)
to_chat(usr, "[name] - Debug mode [debug_original_process_proc ? "en" : "dis"]abled")
/datum/controller/subsystem/processing/proc/log_recent()
var/msg = "Debug output from the [name] subsystem:\n"
msg += "- Process subsystems are processed tail-first -\n"
if(!currentrun || !processing)
msg += "ERROR: A critical list [currentrun ? "processing" : "currentrun"] is gone!"
log_game(msg)
log_world(msg)
return
msg += "Lists: current_run: [currentrun.len], processing: [processing.len]\n"
if(!currentrun.len)
msg += "!!The subsystem just finished the processing list, and currentrun is empty (or has never run).\n"
msg += "!!The info below is the tail of processing instead of currentrun.\n"
var/datum/D = currentrun.len ? currentrun[currentrun.len] : processing[processing.len]
msg += "Tail entry: [describeThis(D)] (this is likely the item AFTER the problem item)\n"
var/position = processing.Find(D)
if(!position)
msg += "Unable to find context of tail entry in processing list.\n"
else
if(position != processing.len)
var/additional = processing.Find(D, position+1)
if(additional)
msg += "WARNING: Tail entry found more than once in processing list! Context is for the first found.\n"
var/start = clamp(position-2,1,processing.len)
var/end = clamp(position+2,1,processing.len)
msg += "2 previous elements, then tail, then 2 next elements of processing list for context:\n"
msg += "---\n"
for(var/i in start to end)
msg += "[describeThis(processing[i])][i == position ? " << TAIL" : ""]\n"
msg += "---\n"
log_game(msg)
log_world(msg)
/datum/controller/subsystem/processing/fail()
..()
log_recent()
/datum/controller/subsystem/processing/critfail()
..()
log_recent()
/datum/proc/DebugSubsystemProcess(var/wait, var/times_fired, var/datum/controller/subsystem/processing/subsystem)
subsystem.debug_last_thing = src
var/start_tick = world.time