mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-11 10:43:20 +00:00
@@ -27,17 +27,17 @@
|
||||
/**
|
||||
* Components attached to this datum
|
||||
*
|
||||
* Lazy associated list in the structure of `type:component/list of components`
|
||||
* Lazy associated list in the structure of `type -> component/list of components`
|
||||
*/
|
||||
var/list/datum_components
|
||||
var/list/_datum_components
|
||||
/**
|
||||
* Any datum registered to receive signals from this datum is in this list
|
||||
*
|
||||
* Lazy associated list in the structure of `signal:registree/list of registrees`
|
||||
* Lazy associated list in the structure of `signal -> registree/list of registrees`
|
||||
*/
|
||||
var/list/comp_lookup
|
||||
var/list/list/signal_procs // List of lists
|
||||
var/signal_enabled = FALSE
|
||||
var/list/_listen_lookup
|
||||
/// Lazy associated list in the structure of `target -> list(signal -> proctype)` that are run when the datum receives that signal
|
||||
var/list/list/_signal_procs
|
||||
|
||||
/// Datum level flags
|
||||
var/datum_flags = NONE
|
||||
@@ -72,32 +72,47 @@
|
||||
// This should be overridden to remove all references pointing to the object being destroyed.
|
||||
// Return the appropriate QDEL_HINT; in most cases this is QDEL_HINT_QUEUE.
|
||||
/datum/proc/Destroy(force=FALSE)
|
||||
SHOULD_CALL_PARENT(TRUE)
|
||||
// SHOULD_NOT_SLEEP(TRUE) FIXME: Causing some big issues still
|
||||
tag = null
|
||||
weak_reference = null //ensure prompt GCing of weakref.
|
||||
|
||||
//clear timers
|
||||
var/list/timers = active_timers
|
||||
active_timers = null
|
||||
for(var/datum/timedevent/timer as anything in timers)
|
||||
if (timer.spent)
|
||||
continue
|
||||
qdel(timer)
|
||||
if(active_timers)
|
||||
var/list/timers = active_timers
|
||||
active_timers = null
|
||||
for(var/datum/timedevent/timer as anything in timers)
|
||||
if (timer.spent)
|
||||
continue
|
||||
qdel(timer)
|
||||
|
||||
weak_reference = null // Clear this reference to ensure it's kept for as brief duration as possible.
|
||||
#ifdef REFERENCE_TRACKING
|
||||
#ifdef REFERENCE_TRACKING_DEBUG
|
||||
found_refs = null
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//BEGIN: ECS SHIT
|
||||
signal_enabled = FALSE
|
||||
|
||||
var/list/dc = datum_components
|
||||
var/list/dc = _datum_components
|
||||
if(dc)
|
||||
var/all_components = dc[/datum/component]
|
||||
if(length(all_components))
|
||||
for(var/datum/component/C as anything in all_components)
|
||||
qdel(C, FALSE, TRUE)
|
||||
else
|
||||
var/datum/component/C = all_components
|
||||
qdel(C, FALSE, TRUE)
|
||||
for(var/component_key in dc)
|
||||
var/component_or_list = dc[component_key]
|
||||
if(islist(component_or_list))
|
||||
for(var/datum/component/component as anything in component_or_list)
|
||||
qdel(component, FALSE)
|
||||
else
|
||||
var/datum/component/C = component_or_list
|
||||
qdel(C, FALSE)
|
||||
dc.Cut()
|
||||
|
||||
var/list/lookup = comp_lookup
|
||||
_clear_signal_refs()
|
||||
//END: ECS SHIT
|
||||
|
||||
return QDEL_HINT_QUEUE
|
||||
|
||||
///Only override this if you know what you're doing. You do not know what you're doing
|
||||
///This is a threat
|
||||
/datum/proc/_clear_signal_refs()
|
||||
var/list/lookup = _listen_lookup
|
||||
if(lookup)
|
||||
for(var/sig in lookup)
|
||||
var/list/comps = lookup[sig]
|
||||
@@ -107,15 +122,10 @@
|
||||
else
|
||||
var/datum/component/comp = comps
|
||||
comp.UnregisterSignal(src, sig)
|
||||
comp_lookup = lookup = null
|
||||
_listen_lookup = lookup = null
|
||||
|
||||
for(var/target in signal_procs)
|
||||
UnregisterSignal(target, signal_procs[target])
|
||||
//END: ECS SHIT
|
||||
|
||||
tag = null
|
||||
SStgui.close_uis(src)
|
||||
return QDEL_HINT_QUEUE
|
||||
for(var/target in _signal_procs)
|
||||
UnregisterSignal(target, _signal_procs[target])
|
||||
|
||||
/**
|
||||
* Callback called by a timer to end an associative-list-indexed cooldown.
|
||||
|
||||
Reference in New Issue
Block a user