mirror of
https://github.com/ParadiseSS13/Paradise.git
synced 2026-07-09 06:04:23 +01:00
Makes all global variables handled by the GLOB controller (#13152)
* Handlers converted, now to fix 3532 compile errors * 3532 compile fixes later, got runtimes on startup * Well the server loads now atleast * Take 2 * Oops
This commit is contained in:
@@ -1,28 +1,28 @@
|
||||
var/list/error_last_seen = list()
|
||||
GLOBAL_LIST_EMPTY(error_last_seen)
|
||||
// error_cooldown items will either be positive (cooldown time) or negative (silenced error)
|
||||
// If negative, starts at -1, and goes down by 1 each time that error gets skipped
|
||||
var/list/error_cooldown = list()
|
||||
var/total_runtimes = 0
|
||||
var/total_runtimes_skipped = 0
|
||||
GLOBAL_LIST_EMPTY(error_cooldown)
|
||||
GLOBAL_VAR_INIT(total_runtimes, 0)
|
||||
GLOBAL_VAR_INIT(total_runtimes_skipped, 0)
|
||||
// The ifdef needs to be down here, since the error viewer references total_runtimes
|
||||
#ifdef DEBUG
|
||||
/world/Error(var/exception/e, var/datum/e_src)
|
||||
if(!istype(e)) // Something threw an unusual exception
|
||||
log_world("\[[time_stamp()]] Uncaught exception: [e]")
|
||||
return ..()
|
||||
if(!error_last_seen) // A runtime is occurring too early in start-up initialization
|
||||
if(!GLOB.error_last_seen) // A runtime is occurring too early in start-up initialization
|
||||
return ..()
|
||||
total_runtimes++
|
||||
GLOB.total_runtimes++
|
||||
|
||||
var/erroruid = "[e.file][e.line]"
|
||||
var/last_seen = error_last_seen[erroruid]
|
||||
var/cooldown = error_cooldown[erroruid] || 0
|
||||
var/last_seen = GLOB.error_last_seen[erroruid]
|
||||
var/cooldown = GLOB.error_cooldown[erroruid] || 0
|
||||
if(last_seen == null) // A new error!
|
||||
error_last_seen[erroruid] = world.time
|
||||
GLOB.error_last_seen[erroruid] = world.time
|
||||
last_seen = world.time
|
||||
if(cooldown < 0)
|
||||
error_cooldown[erroruid]-- // Used to keep track of skip count for this error
|
||||
total_runtimes_skipped++
|
||||
GLOB.error_cooldown[erroruid]-- // Used to keep track of skip count for this error
|
||||
GLOB.total_runtimes_skipped++
|
||||
return // Error is currently silenced, skip handling it
|
||||
|
||||
// Handle cooldowns and silencing spammy errors
|
||||
@@ -36,17 +36,17 @@ var/total_runtimes_skipped = 0
|
||||
spawn(0)
|
||||
usr = null
|
||||
sleep(ERROR_SILENCE_TIME)
|
||||
var/skipcount = abs(error_cooldown[erroruid]) - 1
|
||||
error_cooldown[erroruid] = 0
|
||||
var/skipcount = abs(GLOB.error_cooldown[erroruid]) - 1
|
||||
GLOB.error_cooldown[erroruid] = 0
|
||||
if(skipcount > 0)
|
||||
log_world("\[[time_stamp()]] Skipped [skipcount] runtimes in [e.file],[e.line].")
|
||||
error_cache.logError(e, skipCount = skipcount)
|
||||
error_last_seen[erroruid] = world.time
|
||||
error_cooldown[erroruid] = cooldown
|
||||
GLOB.error_cache.logError(e, skipCount = skipcount)
|
||||
GLOB.error_last_seen[erroruid] = world.time
|
||||
GLOB.error_cooldown[erroruid] = cooldown
|
||||
|
||||
// This line will log a runtime summary to a file which can be publicly distributed without sending player data
|
||||
log_runtime_summary("Runtime in [e.file],[e.line]: [e]")
|
||||
|
||||
|
||||
// The detailed error info needs some tweaking to make it look nice
|
||||
var/list/srcinfo = null
|
||||
var/list/usrinfo = null
|
||||
@@ -103,8 +103,8 @@ var/total_runtimes_skipped = 0
|
||||
for(var/line in desclines)
|
||||
log_world(line)
|
||||
log_runtime_txt(line)
|
||||
if(error_cache)
|
||||
error_cache.logError(e, desclines, e_src = e_src)
|
||||
if(GLOB.error_cache)
|
||||
GLOB.error_cache.logError(e, desclines, e_src = e_src)
|
||||
#endif
|
||||
|
||||
/proc/log_runtime(exception/e, datum/e_src, extra_info)
|
||||
|
||||
@@ -8,10 +8,10 @@
|
||||
// right here:
|
||||
|
||||
#ifdef DEBUG
|
||||
var/global/datum/ErrorViewer/ErrorCache/error_cache = new()
|
||||
GLOBAL_DATUM_INIT(error_cache, /datum/ErrorViewer/ErrorCache, new())
|
||||
#else
|
||||
// If debugging is disabled, there's nothing useful to log, so don't bother.
|
||||
var/global/datum/ErrorViewer/ErrorCache/error_cache = null
|
||||
GLOBAL_DATUM(error_cache, /datum/ErrorViewer/ErrorCache)
|
||||
#endif
|
||||
|
||||
// - ErrorSource datums exist for each line (of code) that generates an error,
|
||||
@@ -80,7 +80,7 @@ var/global/datum/ErrorViewer/ErrorCache/error_cache = null
|
||||
|
||||
/datum/ErrorViewer/ErrorCache/showTo(var/user, var/datum/ErrorViewer/back_to, var/linear)
|
||||
var/html = buildHeader(null, linear, refreshable=1)
|
||||
html += "[total_runtimes] runtimes, [total_runtimes_skipped] skipped<br><br>"
|
||||
html += "[GLOB.total_runtimes] runtimes, [GLOB.total_runtimes_skipped] skipped<br><br>"
|
||||
if(!linear)
|
||||
html += "organized | [makeLink("linear", null, 1)]<hr>"
|
||||
var/datum/ErrorViewer/ErrorSource/error_source
|
||||
@@ -130,7 +130,7 @@ var/global/datum/ErrorViewer/ErrorCache/error_cache = null
|
||||
|
||||
/datum/ErrorViewer/ErrorSource/showTo(var/user, var/datum/ErrorViewer/back_to, var/linear)
|
||||
if(!istype(back_to))
|
||||
back_to = error_cache
|
||||
back_to = GLOB.error_cache
|
||||
var/html = buildHeader(back_to, refreshable=1)
|
||||
for(var/datum/ErrorViewer/ErrorEntry/error_entry in errors)
|
||||
html += "<p class='runtime_list'>[error_entry.makeLink(null, src)]<br></p>"
|
||||
|
||||
Reference in New Issue
Block a user