From 1725713d33cb270766250da1e9c5dea8f7b8e3ac Mon Sep 17 00:00:00 2001 From: Jordan Brown Date: Sun, 17 Jun 2018 21:54:02 -0400 Subject: [PATCH 1/3] Removes status_effect_listener (#38537) --- code/datums/components/_component.dm | 8 +--- .../components/status_effect_listener.dm | 38 ------------------- code/datums/status_effects/gas.dm | 5 ++- code/datums/status_effects/status_effect.dm | 16 -------- tgstation.dme | 1 - 5 files changed, 5 insertions(+), 63 deletions(-) delete mode 100644 code/datums/components/status_effect_listener.dm diff --git a/code/datums/components/_component.dm b/code/datums/components/_component.dm index 39f17edd582f..b3adfccfa5e6 100644 --- a/code/datums/components/_component.dm +++ b/code/datums/components/_component.dm @@ -3,7 +3,6 @@ var/dupe_mode = COMPONENT_DUPE_HIGHLANDER var/dupe_type var/list/signal_procs - var/report_signal_origin = FALSE var/datum/parent /datum/component/New(datum/P, ...) @@ -132,8 +131,6 @@ var/datum/callback/CB = C.signal_procs[sigtype] if(!CB) return NONE - if(initial(C.report_signal_origin)) - arguments = list(sigtype) + arguments return CB.InvokeAsync(arglist(arguments)) . = NONE for(var/I in target) @@ -143,10 +140,7 @@ var/datum/callback/CB = C.signal_procs[sigtype] if(!CB) continue - if(initial(C.report_signal_origin)) - . |= CB.InvokeAsync(arglist(list(sigtype) + arguments)) - else - . |= CB.InvokeAsync(arglist(arguments)) + . |= CB.InvokeAsync(arglist(arguments)) /datum/proc/GetComponent(c_type) var/list/dc = datum_components diff --git a/code/datums/components/status_effect_listener.dm b/code/datums/components/status_effect_listener.dm deleted file mode 100644 index 2f25dca3d4e2..000000000000 --- a/code/datums/components/status_effect_listener.dm +++ /dev/null @@ -1,38 +0,0 @@ -/datum/component/status_effect_listener - dupe_mode = COMPONENT_DUPE_UNIQUE - report_signal_origin = TRUE - var/list/effect_signals = list() - -/datum/component/status_effect_listener/proc/RegisterEffectSignal(datum/status_effect/se, sig_type_or_types, proc_or_callback) - var/list/sig_types = islist(sig_type_or_types) ? sig_type_or_types : list(sig_type_or_types) - RegisterSignal(sig_type_or_types, .proc/signal, override = TRUE) - for(var/type in sig_types) - var/list/callbacks = effect_signals[type] - if(!callbacks) - callbacks = list() - effect_signals[type] = callbacks - if(!istype(proc_or_callback, /datum/callback)) //if it wasnt a callback before, it is now - proc_or_callback = CALLBACK(se, proc_or_callback) - effect_signals[type] += proc_or_callback - -/datum/component/status_effect_listener/proc/ClearSignalRegister(datum/status_effect/se) - for(var/type in effect_signals) - for(var/datum/callback/cb in effect_signals[type]) - if(cb.object == se) - effect_signals[type] -= cb - QDEL_NULL(cb) - if(effect_signals[type].len <= 0) - QDEL_LIST(effect_signals[type]) - effect_signals[type] = null - effect_signals -= type - if(effect_signals.len <= 0) - QDEL_LIST(effect_signals) - qdel(src) - -/datum/component/status_effect_listener/proc/signal(sigtype, ...) - var/list/arguments = args.Copy(2) - if(effect_signals[sigtype]) - for(var/datum/callback/CB in effect_signals[sigtype]) - if(!CB) - continue - . |= CB.InvokeAsync(arglist(arguments)) diff --git a/code/datums/status_effects/gas.dm b/code/datums/status_effects/gas.dm index 137879cdce37..ee974a6e6e0f 100644 --- a/code/datums/status_effects/gas.dm +++ b/code/datums/status_effects/gas.dm @@ -5,6 +5,7 @@ alert_type = /obj/screen/alert/status_effect/freon var/icon/cube var/can_melt = TRUE + var/datum/weakref/redirect_component /obj/screen/alert/status_effect/freon name = "Frozen Solid" @@ -12,7 +13,7 @@ icon_state = "frozen" /datum/status_effect/freon/on_apply() - RegisterEffectSignal(COMSIG_LIVING_RESIST, .proc/owner_resist) + redirect_component = WEAKREF(owner.AddComponent(/datum/component/redirect, list(COMSIG_LIVING_RESIST), CALLBACK(src, .proc/owner_resist))) if(!owner.stat) to_chat(owner, "You become frozen in a cube!") cube = icon('icons/effects/freeze.dmi', "ice_cube") @@ -39,6 +40,8 @@ owner.cut_overlay(cube) owner.adjust_bodytemperature(100) owner.update_canmove() + qdel(redirect_component.resolve()) + redirect_component = null /datum/status_effect/freon/watcher duration = 8 diff --git a/code/datums/status_effects/status_effect.dm b/code/datums/status_effects/status_effect.dm index 7b2776e8cbb9..c8bcd831e218 100644 --- a/code/datums/status_effects/status_effect.dm +++ b/code/datums/status_effects/status_effect.dm @@ -13,20 +13,9 @@ var/alert_type = /obj/screen/alert/status_effect //the alert thrown by the status effect, contains name and description var/obj/screen/alert/status_effect/linked_alert = null //the alert itself, if it exists - var/listening = FALSE //Whether or not the status effect listens to mob interaction, using the status_effect_listener. Don't touch! - /datum/status_effect/New(list/arguments) on_creation(arglist(arguments)) -/datum/status_effect/proc/RegisterEffectSignal(sig_type_or_types, proc_or_callback) - if(!owner) - CRASH("[src] attempted to apply a status effect listener before it had an owner.") - GET_COMPONENT_FROM(listener, /datum/component/status_effect_listener, owner) - if(!listener) - listener = owner.AddComponent(/datum/component/status_effect_listener) - listener.RegisterEffectSignal(src,sig_type_or_types, proc_or_callback) - listening = TRUE - /datum/status_effect/proc/on_creation(mob/living/new_owner, ...) if(new_owner) owner = new_owner @@ -51,10 +40,6 @@ owner.clear_alert(id) LAZYREMOVE(owner.status_effects, src) on_remove() - if(listening) - GET_COMPONENT_FROM(listener, /datum/component/status_effect_listener, owner) - if(listener) - listener.ClearSignalRegister(src) owner = null return ..() @@ -71,7 +56,6 @@ /datum/status_effect/proc/on_apply() //Called whenever the buff is applied; returning FALSE will cause it to autoremove itself. return TRUE /datum/status_effect/proc/tick() //Called every tick. -/datum/status_effect/proc/receiveSignal(var/sigtype) //Called when a listener recieves a signal, if the effect is listening. /datum/status_effect/proc/on_remove() //Called whenever the buff expires or is removed; do note that at the point this is called, it is out of the owner's status_effects but owner is not yet null /datum/status_effect/proc/be_replaced() //Called instead of on_remove when a status effect is replaced by itself or when a status effect with on_remove_on_mob_delete = FALSE has its mob deleted owner.clear_alert(id) diff --git a/tgstation.dme b/tgstation.dme index 3c9ed6dfaa6a..92078786f405 100644 --- a/tgstation.dme +++ b/tgstation.dme @@ -341,7 +341,6 @@ #include "code\datums\components\spooky.dm" #include "code\datums\components\squeek.dm" #include "code\datums\components\stationloving.dm" -#include "code\datums\components\status_effect_listener.dm" #include "code\datums\components\swarming.dm" #include "code\datums\components\thermite.dm" #include "code\datums\components\wearertargeting.dm" From 7aaabb1362dc48bceb490a06be64efc13f80f490 Mon Sep 17 00:00:00 2001 From: Ling Date: Mon, 18 Jun 2018 11:03:47 +0200 Subject: [PATCH 3/3] Update yogstation.dme --- yogstation.dme | 1 - 1 file changed, 1 deletion(-) diff --git a/yogstation.dme b/yogstation.dme index 1bfffaf9c7a7..e7adc70be1d2 100644 --- a/yogstation.dme +++ b/yogstation.dme @@ -344,7 +344,6 @@ #include "code\datums\components\spooky.dm" #include "code\datums\components\squeek.dm" #include "code\datums\components\stationloving.dm" -#include "code\datums\components\status_effect_listener.dm" #include "code\datums\components\swarming.dm" #include "code\datums\components\thermite.dm" #include "code\datums\components\wearertargeting.dm"