Adds a macro for 0 wait timers as END_OF_TICK (#30309)

* Adds a macro for 0 wait timers as END_OF_TICK

* comment update
This commit is contained in:
Contrabang
2025-09-04 07:09:08 +00:00
committed by GitHub
parent e660a30e68
commit 19e1785eed
11 changed files with 15 additions and 12 deletions
+3
View File
@@ -5,3 +5,6 @@
/// like CALLBACK but specifically for verb callbacks
#define VERB_CALLBACK new /datum/callback/verb_callback
// This is used to delay a callback until the end of the tick or later, to ensure that some arbitrary specification is met first. (i.e. spawners spawning stuff)
#define END_OF_TICK(callback) addtimer(callback, 0)
+1 -1
View File
@@ -50,7 +50,7 @@
// See /obj/structure/closet/Initialize for explanation of
// addtimer use here
addtimer(CALLBACK(src, PROC_REF(shelf_items)), 0)
END_OF_TICK(CALLBACK(src, PROC_REF(shelf_items)))
/datum/component/shelver/proc/shelf_items()
var/obj/structure/structure_parent = parent
@@ -60,7 +60,7 @@
// This includes maint loot spawners. The problem with that is if a closet loads before a spawner,
// the loot will just be in a pile. Adding a timer with 0 delay will cause it to only take in contents once the MC has loaded,
// therefore solving the issue on mapload. During rounds, everything will happen as normal
addtimer(CALLBACK(src, PROC_REF(take_contents)), 0)
END_OF_TICK(CALLBACK(src, PROC_REF(take_contents)))
populate_contents() // Spawn all its stuff
update_icon() // Set it to the right icon if needed
+1 -1
View File
@@ -71,7 +71,7 @@ GLOBAL_LIST_EMPTY(safes)
for(var/i in 1 to number_of_tumblers)
tumblers.Add(rand(0, 99))
if(mapload)
addtimer(CALLBACK(src, PROC_REF(take_contents)), 0)
END_OF_TICK(CALLBACK(src, PROC_REF(take_contents)))
/obj/structure/safe/proc/take_contents()
// Put as many items on our turf inside as possible
+1 -1
View File
@@ -374,7 +374,7 @@
/obj/item/book/random/Initialize(mapload)
. = ..()
addtimer(CALLBACK(src, PROC_REF(spawn_books)), 0)
END_OF_TICK(CALLBACK(src, PROC_REF(spawn_books)))
/obj/item/book/random/proc/spawn_books()
var/list/books = GLOB.library_catalog.get_random_book(amount)
+1 -1
View File
@@ -49,7 +49,7 @@
/obj/machinery/computer/library/Initialize(mapload)
. = ..()
addtimer(CALLBACK(src, PROC_REF(populate_booklist)), 0)
END_OF_TICK(CALLBACK(src, PROC_REF(populate_booklist)))
/obj/machinery/computer/library/attack_ai(mob/user)
return attack_hand(user)
+2 -2
View File
@@ -24,7 +24,7 @@
. = ..()
if(mapload)
// same reasoning as closets
addtimer(CALLBACK(src, PROC_REF(take_contents)), 0)
END_OF_TICK(CALLBACK(src, PROC_REF(take_contents)))
/obj/structure/bookcase/proc/take_contents()
for(var/obj/item/I in get_turf(src))
@@ -151,7 +151,7 @@
/obj/structure/bookcase/random/Initialize(mapload)
. = ..()
addtimer(CALLBACK(src, PROC_REF(load_books)), 0)
END_OF_TICK(CALLBACK(src, PROC_REF(load_books)))
icon_state = "bookshelf" // to keep random_bookshelf icon for mappers
/obj/structure/bookcase/random/proc/load_books()
@@ -377,7 +377,7 @@
..()
if(!activated || QDELETED(src))
return
addtimer(CALLBACK(src, PROC_REF(try_attach_to_owner)), 0) // Do this once the drop call stack is done. The holding limb might be getting removed
END_OF_TICK(CALLBACK(src, PROC_REF(try_attach_to_owner))) // Do this once the drop call stack is done. The holding limb might be getting removed
/obj/item/rod_of_asclepius/proc/try_attach_to_owner()
if(!ishuman(owner) || QDELETED(owner))
@@ -263,7 +263,7 @@ Difficulty: Hard
. = ..()
var/newcolor = rgb(241, 137, 172)
add_atom_colour(newcolor, TEMPORARY_COLOUR_PRIORITY)
addtimer(CALLBACK(src, PROC_REF(beam_it_up)), 0)
END_OF_TICK(CALLBACK(src, PROC_REF(beam_it_up)))
/obj/effect/vetus_laser/ex_act(severity)
return
+2 -2
View File
@@ -1374,7 +1374,7 @@
/obj/structure/disposalpipe/trunk/Initialize(mapload)
. = ..()
dpdir = dir
addtimer(CALLBACK(src, PROC_REF(getlinked)), 0) // This has a delay of 0, but wont actually start until the MC is done
END_OF_TICK(CALLBACK(src, PROC_REF(getlinked)))
update()
return
@@ -1515,7 +1515,7 @@
/obj/structure/disposaloutlet/Initialize(mapload)
. = ..()
addtimer(CALLBACK(src, PROC_REF(setup)), 0) // Wait of 0, but this wont actually do anything until the MC is firing
END_OF_TICK(CALLBACK(src, PROC_REF(setup)))
/obj/structure/disposaloutlet/proc/setup()
target = get_ranged_target_turf(src, dir, 10)
@@ -210,7 +210,7 @@
// we need to come back to this once the hand is actually removed/dead
if(!owner) // Rather not have this trigger on already removed limbs
return
addtimer(CALLBACK(owner, TYPE_PROC_REF(/mob/living/carbon/human, update_hands_hud), 0))
END_OF_TICK(CALLBACK(owner, TYPE_PROC_REF(/mob/living/carbon/human, update_hands_hud)))
/obj/item/organ/external/hand/right
limb_name = "r_hand"