Refactored deletion observables to use the COMSIG_QDELETING signal (#20121)

Refactored deletion observables to use the COMSIG_QDELETING signal
instead, removed the observable.
This commit is contained in:
Fluffy
2024-11-04 22:51:18 +01:00
committed by GitHub
parent ce0f722f18
commit 513facdb0d
25 changed files with 120 additions and 56 deletions

View File

@@ -69,13 +69,13 @@
return
ClearValue()
value_to_set = new_value
GLOB.destroyed_event.register(value_to_set, src, /datum/build_mode/edit/proc/ClearValue)
RegisterSignal(value_to_set, COMSIG_QDELETING, /datum/build_mode/edit/proc/ClearValue)
/datum/build_mode/edit/proc/ClearValue(var/feedback)
if(!istype(value_to_set, /datum))
return
GLOB.destroyed_event.unregister(value_to_set, src, /datum/build_mode/edit/proc/ClearValue)
UnregisterSignal(value_to_set, COMSIG_QDELETING)
value_to_set = initial(value_to_set)
if(feedback)
Warn("The selected reference value was deleted. Default value restored.")

View File

@@ -33,14 +33,14 @@
ClearDestination()
destination = A
GLOB.destroyed_event.register(destination, src, /datum/build_mode/move_into/proc/ClearDestination)
RegisterSignal(destination, COMSIG_QDELETING, /datum/build_mode/move_into/proc/ClearDestination)
to_chat(user, SPAN_NOTICE("Will now move targets into \the [destination]."))
/datum/build_mode/move_into/proc/ClearDestination(var/feedback)
if(!destination)
return
GLOB.destroyed_event.unregister(destination, src, /datum/build_mode/move_into/proc/ClearDestination)
UnregisterSignal(destination, COMSIG_QDELETING)
destination = null
if(feedback)
Warn("The selected destination was deleted.")

View File

@@ -92,14 +92,14 @@
/obj/item/mecha_equipment/mounted_system/proc/forget_holding()
if(holding) //It'd be strange for this to be called with this var unset
GLOB.destroyed_event.unregister(holding, src, PROC_REF(forget_holding))
UnregisterSignal(holding, COMSIG_QDELETING)
holding = null
/obj/item/mecha_equipment/mounted_system/Initialize()
. = ..()
if(holding_type)
holding = new holding_type(src)
GLOB.destroyed_event.register(holding, src, PROC_REF(forget_holding))
RegisterSignal(holding, COMSIG_QDELETING, PROC_REF(forget_holding))
if(holding)
if(!icon_state)
icon = holding.icon

View File

@@ -265,7 +265,7 @@
/obj/item/mecha_equipment/catapult/proc/beamdestroyed()
if(beam)
GLOB.destroyed_event.unregister(beam, src, .proc/beamdestroyed)
UnregisterSignal(beam, COMSIG_QDELETING)
beam = null
if(locked)
if(owner)
@@ -316,7 +316,7 @@
return
locked = AM
beam = owner.Beam(BeamTarget = target, icon_state = "r_beam", maxdistance = max_dist, beam_type = /obj/effect/ebeam/warp)
GLOB.destroyed_event.register(beam, src, .proc/beamdestroyed)
RegisterSignal(beam, COMSIG_QDELETING, PROC_REF(beamdestroyed))
animate(target,pixel_y= initial(target.pixel_y) - 2,time=1 SECOND, easing = SINE_EASING, flags = ANIMATION_PARALLEL, loop = -1)
animate(pixel_y= initial(target.pixel_y) + 2,time=1 SECOND)

View File

@@ -100,7 +100,7 @@
if(target == selected_hardpoint)
clear_selected_hardpoint()
GLOB.destroyed_event.unregister(module_to_forget, src, PROC_REF(forget_module))
UnregisterSignal(module_to_forget, COMSIG_QDELETING)
var/atom/movable/screen/mecha/hardpoint/H = hardpoint_hud_elements[target]
H.holding = null
@@ -144,7 +144,7 @@
if(!found)
return FALSE
ME.installed(src)
GLOB.destroyed_event.register(system, src, PROC_REF(forget_module))
RegisterSignal(system, COMSIG_QDELETING, PROC_REF(forget_module))
system.forceMove(src)
@@ -198,7 +198,7 @@
system.forceMove(get_turf(src))
system.screen_loc = null
system.layer = initial(system.layer)
GLOB.destroyed_event.unregister(system, src, PROC_REF(forget_module))
UnregisterSignal(system, COMSIG_QDELETING)
var/atom/movable/screen/mecha/hardpoint/H = hardpoint_hud_elements[system_hardpoint]
H.holding = null

View File

@@ -170,14 +170,14 @@
// These procs do not relocate the grenade, that's the callers responsibility
/obj/item/integrated_circuit/manipulation/grenade/proc/attach_grenade(var/obj/item/grenade/G)
attached_grenade = G
GLOB.destroyed_event.register(attached_grenade, src, PROC_REF(detach_grenade))
RegisterSignal(attached_grenade, COMSIG_QDELETING, PROC_REF(detach_grenade))
size += G.w_class
desc += " \An [attached_grenade] is attached to it!"
/obj/item/integrated_circuit/manipulation/grenade/proc/detach_grenade()
if(!attached_grenade)
return
GLOB.destroyed_event.unregister(attached_grenade, src)
UnregisterSignal(attached_grenade, COMSIG_QDELETING)
attached_grenade = null
size = initial(size)
desc = initial(desc)

View File

@@ -119,7 +119,7 @@
return FALSE
sources += source
RegisterSignal(source, COMSIG_MOVABLE_MOVED, PROC_REF(source_moved))
GLOB.destroyed_event.register(source, src, PROC_REF(remove_source))
RegisterSignal(source, COMSIG_QDELETING, PROC_REF(remove_source))
for_all_chunks_in_range(source, TYPE_PROC_REF(/datum/chunk, add_source), list(source))
if(update_visibility)
update_visibility(source, opacity_check)
@@ -129,7 +129,7 @@
if(!sources.Remove(source))
return FALSE
UnregisterSignal(source, COMSIG_MOVABLE_MOVED)
GLOB.destroyed_event.unregister(source, src)
UnregisterSignal(source, COMSIG_QDELETING)
for_all_chunks_in_range(source, /datum/chunk/proc/remove_source, list(source))
if(update_visibility)
update_visibility(source, opacity_check)

View File

@@ -163,14 +163,14 @@
if(tracker in trackers)
trackers -= tracker
GLOB.destroyed_event.unregister(tracker, src, PROC_REF(remove_tracker))
UnregisterSignal(tracker, COMSIG_QDELETING)
to_chat(user, SPAN_NOTICE("You unlink the tracker in \the [P]'s buffer from \the [src]."))
return
trackers += tracker
GLOB.destroyed_event.register(tracker, src, PROC_REF(remove_tracker))
RegisterSignal(tracker, COMSIG_QDELETING, PROC_REF(remove_tracker))
to_chat(user, SPAN_NOTICE("You link the tracker in \the [P]'s buffer to \the [src]."))
/obj/machinery/computer/ship/sensors/proc/remove_tracker(var/obj/item/ship_tracker/tracker)
/obj/machinery/computer/ship/sensors/proc/remove_tracker(obj/item/ship_tracker/tracker)
trackers -= tracker
/obj/machinery/computer/ship/sensors/proc/datalink_process()

View File

@@ -260,7 +260,7 @@
var/mob/S = new mob_type(T)
animals += S
GLOB.death_event.register(S, src, PROC_REF(remove_animal))
GLOB.destroyed_event.register(S, src, PROC_REF(remove_animal))
RegisterSignal(S, COMSIG_QDELETING, PROC_REF(remove_animal))
adapt_animal(S)
if(animals.len >= max_animal_count)
repopulating = 0
@@ -279,10 +279,10 @@
daddy.group_multiplier = Z.air.group_multiplier
Z.air.equalize(daddy)
/obj/effect/overmap/visitable/sector/exoplanet/proc/remove_animal(var/mob/M)
/obj/effect/overmap/visitable/sector/exoplanet/proc/remove_animal(mob/M)
animals -= M
GLOB.death_event.unregister(M, src)
GLOB.destroyed_event.unregister(M, src)
UnregisterSignal(M, COMSIG_QDELETING)
repopulate_types |= M.type
/obj/effect/overmap/visitable/sector/exoplanet/proc/generate_map()

View File

@@ -133,11 +133,11 @@
core_landmark = master
name = _name
landmark_tag = master.shuttle_name + _name
GLOB.destroyed_event.register(master, src, GLOBAL_PROC_REF(qdel))
RegisterSignal(master, COMSIG_QDELETING, TYPE_PROC_REF(/datum, qdel_self))
. = ..()
/obj/effect/shuttle_landmark/visiting_shuttle/Destroy()
GLOB.destroyed_event.unregister(core_landmark, src)
UnregisterSignal(core_landmark, COMSIG_QDELETING)
LAZYREMOVE(core_landmark.visitors, src)
core_landmark = null
. = ..()

View File

@@ -99,7 +99,7 @@
index_name = "Index ([length(indices) + 1])"
E.name = index_name
LAZYSET(indices, E.name, E)
GLOB.destroyed_event.register(E, src, PROC_REF(remove_index))
RegisterSignal(E, COMSIG_QDELETING, PROC_REF(remove_index))
return E
/obj/item/journal/proc/remove_index(var/obj/item/folder/embedded/E)

View File

@@ -215,7 +215,7 @@
lock_time = world.time + 35
RegisterSignal(owner, COMSIG_MOVABLE_MOVED, PROC_REF(update_aiming))
RegisterSignal(aiming_at, COMSIG_MOVABLE_MOVED, PROC_REF(target_moved))
GLOB.destroyed_event.register(aiming_at, src, PROC_REF(cancel_aiming))
RegisterSignal(aiming_at, COMSIG_QDELETING, PROC_REF(cancel_aiming))
/obj/aiming_overlay/proc/aim_cooldown(seconds)
aimcooldown = world.time + seconds SECONDS
@@ -261,7 +261,7 @@
UnregisterSignal(owner, COMSIG_MOVABLE_MOVED)
if(aiming_at)
UnregisterSignal(aiming_at, COMSIG_MOVABLE_MOVED)
GLOB.destroyed_event.unregister(aiming_at, src)
UnregisterSignal(aiming_at, COMSIG_QDELETING)
LAZYREMOVE(aiming_at.aimed_at_by, src)
aiming_at = null

View File

@@ -33,7 +33,7 @@
listeners = list()
listener_status = list()
GLOB.destroyed_event.register(source, src, /datum/proc/qdel_self)
RegisterSignal(source, COMSIG_QDELETING, TYPE_PROC_REF(/datum, qdel_self))
player.subscribe(src)
@@ -52,6 +52,6 @@
/datum/sound_token/instrument/Destroy()
. = ..()
GLOB.destroyed_event.unregister(source, src, /datum/proc/qdel_self)
UnregisterSignal(source, COMSIG_QDELETING)
player.unsubscribe(src)
player = null