mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-12 03:02:54 +00:00
ports #4581 Startup Runtime fix
This commit is contained in:
@@ -1,5 +1,9 @@
|
|||||||
GLOBAL_LIST_EMPTY(all_observable_events)
|
GLOBAL_LIST_EMPTY(error_last_seen)
|
||||||
|
GLOBAL_LIST_EMPTY(error_cooldown)
|
||||||
|
|
||||||
|
GLOBAL_DATUM_INIT(all_observable_events, /datum/all_observable_events, new) // This is a datum. It is not a list.
|
||||||
|
GLOBAL_DATUM_INIT(destroyed_event, /decl/observ/destroyed, new())
|
||||||
|
|
||||||
GLOBAL_VAR_INIT(timezoneOffset, 0) // The difference betwen midnight (of the host computer) and 0 world.ticks.
|
GLOBAL_VAR_INIT(timezoneOffset, 0) // The difference betwen midnight (of the host computer) and 0 world.ticks.
|
||||||
|
|
||||||
GLOBAL_VAR_INIT(TAB, " ")
|
GLOBAL_VAR_INIT(TAB, " ")
|
||||||
@@ -11,7 +11,7 @@
|
|||||||
var/datum/controller/process/alarm/alarm_manager
|
var/datum/controller/process/alarm/alarm_manager
|
||||||
|
|
||||||
/datum/controller/process/alarm
|
/datum/controller/process/alarm
|
||||||
var/list/datum/alarm/all_handlers
|
var/list/datum/alarm/all_handlers = list()
|
||||||
|
|
||||||
/datum/controller/process/alarm/setup()
|
/datum/controller/process/alarm/setup()
|
||||||
name = "alarm"
|
name = "alarm"
|
||||||
|
|||||||
@@ -40,7 +40,7 @@
|
|||||||
// We are being killed. Least we can do is deregister all those events we registered
|
// We are being killed. Least we can do is deregister all those events we registered
|
||||||
/datum/controller/process/scheduler/onKill()
|
/datum/controller/process/scheduler/onKill()
|
||||||
for(var/st in scheduled_tasks)
|
for(var/st in scheduled_tasks)
|
||||||
destroyed_event.unregister(st, src)
|
GLOB.destroyed_event.unregister(st, src)
|
||||||
|
|
||||||
/datum/controller/process/scheduler/statProcess()
|
/datum/controller/process/scheduler/statProcess()
|
||||||
..()
|
..()
|
||||||
@@ -148,7 +148,7 @@
|
|||||||
|
|
||||||
/datum/scheduled_task/source/New(var/trigger_time, var/datum/source, var/procedure, var/list/arguments, var/proc/task_after_process, var/list/task_after_process_args)
|
/datum/scheduled_task/source/New(var/trigger_time, var/datum/source, var/procedure, var/list/arguments, var/proc/task_after_process, var/list/task_after_process_args)
|
||||||
src.source = source
|
src.source = source
|
||||||
destroyed_event.register(src.source, src, /datum/scheduled_task/source/proc/source_destroyed)
|
GLOB.destroyed_event.register(src.source, src, /datum/scheduled_task/source/proc/source_destroyed)
|
||||||
..(trigger_time, procedure, arguments, task_after_process, task_after_process_args)
|
..(trigger_time, procedure, arguments, task_after_process, task_after_process_args)
|
||||||
|
|
||||||
/datum/scheduled_task/source/Destroy()
|
/datum/scheduled_task/source/Destroy()
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
/****************
|
/****************
|
||||||
* Debug Support *
|
* Debug Support *
|
||||||
****************/
|
****************/
|
||||||
var/datum/all_observable_events/all_observable_events = new()
|
|
||||||
|
|
||||||
/datum/all_observable_events
|
/datum/all_observable_events
|
||||||
var/list/events
|
var/list/events
|
||||||
|
|||||||
@@ -5,11 +5,10 @@
|
|||||||
//
|
//
|
||||||
// Arguments that the called proc should expect:
|
// Arguments that the called proc should expect:
|
||||||
// /datum/destroyed_instance: The instance that was destroyed.
|
// /datum/destroyed_instance: The instance that was destroyed.
|
||||||
var/decl/observ/destroyed/destroyed_event = new()
|
|
||||||
|
|
||||||
/decl/observ/destroyed
|
/decl/observ/destroyed
|
||||||
name = "Destroyed"
|
name = "Destroyed"
|
||||||
|
|
||||||
/datum/Destroy()
|
/datum/Destroy()
|
||||||
destroyed_event.raise_event(src)
|
GLOB.destroyed_event.raise_event(src)
|
||||||
. = ..()
|
. = ..()
|
||||||
|
|||||||
@@ -63,7 +63,7 @@
|
|||||||
var/list/global_listeners = list() // Associative list of instances that listen to all events of this type (as opposed to events belonging to a specific source) and the proc to call.
|
var/list/global_listeners = list() // Associative list of instances that listen to all events of this type (as opposed to events belonging to a specific source) and the proc to call.
|
||||||
|
|
||||||
/decl/observ/New()
|
/decl/observ/New()
|
||||||
all_observable_events.events += src
|
GLOB.all_observable_events.events += src
|
||||||
. = ..()
|
. = ..()
|
||||||
|
|
||||||
/decl/observ/proc/is_listening(var/event_source, var/datum/listener, var/proc_call)
|
/decl/observ/proc/is_listening(var/event_source, var/datum/listener, var/proc_call)
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
var/list/global_listen_count = list()
|
GLOBAL_LIST_EMPTY(global_listen_count)
|
||||||
var/list/event_sources_count = list()
|
GLOBAL_LIST_EMPTY(event_sources_count)
|
||||||
var/list/event_listen_count = list()
|
GLOBAL_LIST_EMPTY(event_listen_count)
|
||||||
|
|
||||||
/decl/observ/destroyed/raise_event()
|
/decl/observ/destroyed/raise_event()
|
||||||
. = ..()
|
. = ..()
|
||||||
@@ -8,39 +8,39 @@ var/list/event_listen_count = list()
|
|||||||
return
|
return
|
||||||
var/source = args[1]
|
var/source = args[1]
|
||||||
|
|
||||||
if(global_listen_count[source])
|
if(GLOB.global_listen_count[source])
|
||||||
cleanup_global_listener(source, global_listen_count[source])
|
cleanup_global_listener(source, GLOB.global_listen_count[source])
|
||||||
if(event_sources_count[source])
|
if(GLOB.event_sources_count[source])
|
||||||
cleanup_source_listeners(source, event_sources_count[source])
|
cleanup_source_listeners(source, GLOB.event_sources_count[source])
|
||||||
if(event_listen_count[source])
|
if(GLOB.event_listen_count[source])
|
||||||
cleanup_event_listener(source, event_listen_count[source])
|
cleanup_event_listener(source, GLOB.event_listen_count[source])
|
||||||
|
|
||||||
|
|
||||||
/decl/observ/register(var/datum/event_source, var/datum/listener, var/proc_call)
|
/decl/observ/register(var/datum/event_source, var/datum/listener, var/proc_call)
|
||||||
. = ..()
|
. = ..()
|
||||||
if(.)
|
if(.)
|
||||||
event_sources_count[event_source] += 1
|
GLOB.event_sources_count[event_source] += 1
|
||||||
event_listen_count[listener] += 1
|
GLOB.event_listen_count[listener] += 1
|
||||||
|
|
||||||
/decl/observ/unregister(var/datum/event_source, var/datum/listener, var/proc_call)
|
/decl/observ/unregister(var/datum/event_source, var/datum/listener, var/proc_call)
|
||||||
. = ..()
|
. = ..()
|
||||||
if(.)
|
if(.)
|
||||||
event_sources_count[event_source] -= 1
|
GLOB.event_sources_count[event_source] -= 1
|
||||||
event_listen_count[listener] -= 1
|
GLOB.event_listen_count[listener] -= 1
|
||||||
|
|
||||||
/decl/observ/register_global(var/datum/listener, var/proc_call)
|
/decl/observ/register_global(var/datum/listener, var/proc_call)
|
||||||
. = ..()
|
. = ..()
|
||||||
if(.)
|
if(.)
|
||||||
global_listen_count[listener] += 1
|
GLOB.global_listen_count[listener] += 1
|
||||||
|
|
||||||
/decl/observ/unregister_global(var/datum/listener, var/proc_call)
|
/decl/observ/unregister_global(var/datum/listener, var/proc_call)
|
||||||
. = ..()
|
. = ..()
|
||||||
if(.)
|
if(.)
|
||||||
global_listen_count[listener] -= 1
|
GLOB.global_listen_count[listener] -= 1
|
||||||
|
|
||||||
/decl/observ/destroyed/proc/cleanup_global_listener(listener, listen_count)
|
/decl/observ/destroyed/proc/cleanup_global_listener(listener, listen_count)
|
||||||
global_listen_count -= listener
|
GLOB.global_listen_count -= listener
|
||||||
for(var/entry in all_observable_events.events)
|
for(var/entry in GLOB.all_observable_events.events)
|
||||||
var/decl/observ/event = entry
|
var/decl/observ/event = entry
|
||||||
if(event.unregister_global(listener))
|
if(event.unregister_global(listener))
|
||||||
log_debug("[event] - [listener] was deleted while still registered to global events.")
|
log_debug("[event] - [listener] was deleted while still registered to global events.")
|
||||||
@@ -48,8 +48,8 @@ var/list/event_listen_count = list()
|
|||||||
return
|
return
|
||||||
|
|
||||||
/decl/observ/destroyed/proc/cleanup_source_listeners(event_source, source_listener_count)
|
/decl/observ/destroyed/proc/cleanup_source_listeners(event_source, source_listener_count)
|
||||||
event_sources_count -= event_source
|
GLOB.event_sources_count -= event_source
|
||||||
for(var/entry in all_observable_events.events)
|
for(var/entry in GLOB.all_observable_events.events)
|
||||||
var/decl/observ/event = entry
|
var/decl/observ/event = entry
|
||||||
var/proc_owners = event.event_sources[event_source]
|
var/proc_owners = event.event_sources[event_source]
|
||||||
if(proc_owners)
|
if(proc_owners)
|
||||||
@@ -60,11 +60,11 @@ var/list/event_listen_count = list()
|
|||||||
return
|
return
|
||||||
|
|
||||||
/decl/observ/destroyed/proc/cleanup_event_listener(listener, listener_count)
|
/decl/observ/destroyed/proc/cleanup_event_listener(listener, listener_count)
|
||||||
event_listen_count -= listener
|
GLOB.event_listen_count -= listener
|
||||||
for(var/entry in all_observable_events.events)
|
for(var/entry in GLOB.all_observable_events.events)
|
||||||
var/decl/observ/event = entry
|
var/decl/observ/event = entry
|
||||||
for(var/event_source in event.event_sources)
|
for(var/event_source in event.event_sources)
|
||||||
if(event.unregister(event_source, listener))
|
if(event.unregister(event_source, listener))
|
||||||
log_debug("[event] - [listener] was deleted while still listening to [event_source].")
|
log_debug("[event] - [listener] was deleted while still listening to [event_source].")
|
||||||
if(!(--listener_count))
|
if(!(--listener_count))
|
||||||
return
|
return
|
||||||
@@ -250,4 +250,4 @@ var/global/list/image/splatter_cache=list()
|
|||||||
/obj/effect/decal/cleanable/mucus/mapped/New()
|
/obj/effect/decal/cleanable/mucus/mapped/New()
|
||||||
..()
|
..()
|
||||||
virus2 |= new /datum/disease2/disease
|
virus2 |= new /datum/disease2/disease
|
||||||
virus2.makerandom()
|
virus2[1].makerandom()
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
var/list/error_last_seen = list()
|
|
||||||
// error_cooldown items will either be positive (cooldown time) or negative (silenced error)
|
// 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
|
// 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 = 0
|
||||||
var/total_runtimes_skipped = 0
|
var/total_runtimes_skipped = 0
|
||||||
// The ifdef needs to be down here, since the error viewer references total_runtimes
|
// The ifdef needs to be down here, since the error viewer references total_runtimes
|
||||||
@@ -10,18 +8,18 @@ var/total_runtimes_skipped = 0
|
|||||||
if(!istype(e)) // Something threw an unusual exception
|
if(!istype(e)) // Something threw an unusual exception
|
||||||
log_error("\[[time_stamp()]] Uncaught exception: [e]")
|
log_error("\[[time_stamp()]] Uncaught exception: [e]")
|
||||||
return ..()
|
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 ..()
|
return ..()
|
||||||
total_runtimes++
|
total_runtimes++
|
||||||
|
|
||||||
var/erroruid = "[e.file][e.line]"
|
var/erroruid = "[e.file][e.line]"
|
||||||
var/last_seen = error_last_seen[erroruid]
|
var/last_seen = GLOB.error_last_seen[erroruid]
|
||||||
var/cooldown = error_cooldown[erroruid] || 0
|
var/cooldown = GLOB.error_cooldown[erroruid] || 0
|
||||||
if(last_seen == null) // A new error!
|
if(last_seen == null) // A new error!
|
||||||
error_last_seen[erroruid] = world.time
|
GLOB.error_last_seen[erroruid] = world.time
|
||||||
last_seen = world.time
|
last_seen = world.time
|
||||||
if(cooldown < 0)
|
if(cooldown < 0)
|
||||||
error_cooldown[erroruid]-- // Used to keep track of skip count for this error
|
GLOB.error_cooldown[erroruid]-- // Used to keep track of skip count for this error
|
||||||
total_runtimes_skipped++
|
total_runtimes_skipped++
|
||||||
return // Error is currently silenced, skip handling it
|
return // Error is currently silenced, skip handling it
|
||||||
|
|
||||||
@@ -36,13 +34,13 @@ var/total_runtimes_skipped = 0
|
|||||||
spawn(0)
|
spawn(0)
|
||||||
usr = null
|
usr = null
|
||||||
sleep(ERROR_SILENCE_TIME)
|
sleep(ERROR_SILENCE_TIME)
|
||||||
var/skipcount = abs(error_cooldown[erroruid]) - 1
|
var/skipcount = abs(GLOB.error_cooldown[erroruid]) - 1
|
||||||
error_cooldown[erroruid] = 0
|
GLOB.error_cooldown[erroruid] = 0
|
||||||
if(skipcount > 0)
|
if(skipcount > 0)
|
||||||
log_error("\[[time_stamp()]] Skipped [skipcount] runtimes in [e.file],[e.line].")
|
log_error("\[[time_stamp()]] Skipped [skipcount] runtimes in [e.file],[e.line].")
|
||||||
error_cache.logError(e, skipCount = skipcount)
|
error_cache.logError(e, skipCount = skipcount)
|
||||||
error_last_seen[erroruid] = world.time
|
GLOB.error_last_seen[erroruid] = world.time
|
||||||
error_cooldown[erroruid] = cooldown
|
GLOB.error_cooldown[erroruid] = cooldown
|
||||||
|
|
||||||
// The detailed error info needs some tweaking to make it look nice
|
// The detailed error info needs some tweaking to make it look nice
|
||||||
var/list/srcinfo = null
|
var/list/srcinfo = null
|
||||||
@@ -115,4 +113,4 @@ var/total_runtimes_skipped = 0
|
|||||||
else
|
else
|
||||||
e.desc = " [extra_info]\n\n" + e.desc
|
e.desc = " [extra_info]\n\n" + e.desc
|
||||||
|
|
||||||
world.Error(e, e_src)
|
world.Error(e, e_src)
|
||||||
@@ -125,7 +125,7 @@
|
|||||||
watching_mob = user
|
watching_mob = user
|
||||||
GLOB.moved_event.register(watching_mob, src, /obj/machinery/station_map/proc/checkPosition)
|
GLOB.moved_event.register(watching_mob, src, /obj/machinery/station_map/proc/checkPosition)
|
||||||
GLOB.dir_set_event.register(watching_mob, src, /obj/machinery/station_map/proc/checkPosition)
|
GLOB.dir_set_event.register(watching_mob, src, /obj/machinery/station_map/proc/checkPosition)
|
||||||
destroyed_event.register(watching_mob, src, /obj/machinery/station_map/proc/stopWatching)
|
GLOB.destroyed_event.register(watching_mob, src, /obj/machinery/station_map/proc/stopWatching)
|
||||||
update_use_power(2)
|
update_use_power(2)
|
||||||
|
|
||||||
if(bogus)
|
if(bogus)
|
||||||
@@ -154,7 +154,7 @@
|
|||||||
M.client.images -= holomap_datum.station_map
|
M.client.images -= holomap_datum.station_map
|
||||||
GLOB.moved_event.unregister(watching_mob, src)
|
GLOB.moved_event.unregister(watching_mob, src)
|
||||||
GLOB.dir_set_event.unregister(watching_mob, src)
|
GLOB.dir_set_event.unregister(watching_mob, src)
|
||||||
destroyed_event.unregister(watching_mob, src)
|
GLOB.destroyed_event.unregister(watching_mob, src)
|
||||||
watching_mob = null
|
watching_mob = null
|
||||||
update_use_power(1)
|
update_use_power(1)
|
||||||
|
|
||||||
|
|||||||
@@ -188,14 +188,14 @@
|
|||||||
// These procs do not relocate the grenade, that's the callers responsibility
|
// These procs do not relocate the grenade, that's the callers responsibility
|
||||||
/obj/item/integrated_circuit/manipulation/grenade/proc/attach_grenade(var/obj/item/weapon/grenade/G)
|
/obj/item/integrated_circuit/manipulation/grenade/proc/attach_grenade(var/obj/item/weapon/grenade/G)
|
||||||
attached_grenade = G
|
attached_grenade = G
|
||||||
destroyed_event.register(attached_grenade, src, /obj/item/integrated_circuit/manipulation/grenade/proc/detach_grenade)
|
GLOB.destroyed_event.register(attached_grenade, src, /obj/item/integrated_circuit/manipulation/grenade/proc/detach_grenade)
|
||||||
size += G.w_class
|
size += G.w_class
|
||||||
desc += " \An [attached_grenade] is attached to it!"
|
desc += " \An [attached_grenade] is attached to it!"
|
||||||
|
|
||||||
/obj/item/integrated_circuit/manipulation/grenade/proc/detach_grenade()
|
/obj/item/integrated_circuit/manipulation/grenade/proc/detach_grenade()
|
||||||
if(!attached_grenade)
|
if(!attached_grenade)
|
||||||
return
|
return
|
||||||
destroyed_event.unregister(attached_grenade, src, /obj/item/integrated_circuit/manipulation/grenade/proc/detach_grenade)
|
GLOB.destroyed_event.unregister(attached_grenade, src, /obj/item/integrated_circuit/manipulation/grenade/proc/detach_grenade)
|
||||||
attached_grenade = null
|
attached_grenade = null
|
||||||
size = initial(size)
|
size = initial(size)
|
||||||
desc = initial(desc)
|
desc = initial(desc)
|
||||||
|
|||||||
Reference in New Issue
Block a user