More spawn/sleep removals (#47634)

* remove more spawns

* more

* more

* varsets

* oops

* unfuck this
This commit is contained in:
spookydonut
2019-11-13 03:07:59 -08:00
committed by Rob Bailey
parent 736414a741
commit dd6fa5eded
26 changed files with 122 additions and 130 deletions
+1
View File
@@ -2,3 +2,4 @@
/// A shorthand for the callback datum, [documented here](datum/callback.html)
#define CALLBACK new /datum/callback
#define INVOKE_ASYNC world.ImmediateInvokeAsync
#define CALLBACK_NEW(typepath, args) CALLBACK(GLOBAL_PROC, /proc/___callbacknew, typepath, args)
+12
View File
@@ -490,3 +490,15 @@ GLOBAL_LIST_EMPTY(species_list)
REMOVE_TRAIT(L, TRAIT_PASSTABLE, source)
if(!HAS_TRAIT(L, TRAIT_PASSTABLE))
L.pass_flags &= ~PASSTABLE
/proc/dance_rotate(atom/movable/AM, datum/callback/callperrotate, set_original_dir=FALSE)
set waitfor = FALSE
var/originaldir = AM.dir
for(var/i in list(NORTH,SOUTH,EAST,WEST,EAST,SOUTH,NORTH,SOUTH,EAST,WEST,EAST,SOUTH))
if(!AM)
return
AM.setDir(i)
callperrotate?.Invoke()
sleep(1)
if(set_original_dir)
AM.setDir(originaldir)
+2
View File
@@ -221,3 +221,5 @@
sleep(resolution*world.tick_lag)
return CS.finished
/proc/___callbacknew(typepath, arguments)
new typepath(arglist(arguments))
+1 -10
View File
@@ -23,18 +23,9 @@
return 1
return 0
/datum/martial_art/plasma_fist/proc/TornadoAnimate(mob/living/carbon/human/A)
set waitfor = FALSE
for(var/i in list(NORTH,SOUTH,EAST,WEST,EAST,SOUTH,NORTH,SOUTH,EAST,WEST,EAST,SOUTH))
if(!A)
break
A.setDir(i)
playsound(A.loc, 'sound/weapons/punch1.ogg', 15, TRUE, -1)
sleep(1)
/datum/martial_art/plasma_fist/proc/Tornado(mob/living/carbon/human/A, mob/living/carbon/human/D)
A.say("TORNADO SWEEP!", forced="plasma fist")
TornadoAnimate(A)
dance_rotate(A, CALLBACK(GLOBAL_PROC, .proc/playsound, A.loc, 'sound/weapons/punch1.ogg', 15, TRUE, -1))
var/obj/effect/proc_holder/spell/aoe_turf/repulse/R = new(null)
var/list/turfs = list()
for(var/turf/T in range(1,A))
+8 -7
View File
@@ -357,13 +357,7 @@
playsound(src, 'sound/machines/terminal_prompt.ogg', 50, FALSE)
say("Initiating scan...")
spawn(20)
scan_occupant(scanner.occupant, usr, body_only)
loading = FALSE
updateUsrDialog()
playsound(src, 'sound/machines/terminal_prompt_confirm.ogg', 50, FALSE)
addtimer(CALLBACK(src, .proc/do_scan, usr, body_only), 2 SECONDS)
//No locking an open scanner.
else if ((href_list["lock"]) && !isnull(scanner) && scanner.is_operational())
@@ -523,6 +517,13 @@
updateUsrDialog()
return
/obj/machinery/computer/cloning/proc/do_scan(mob/user, body_only)
scan_occupant(scanner.occupant, user, body_only)
loading = FALSE
updateUsrDialog()
playsound(src, 'sound/machines/terminal_prompt_confirm.ogg', 50, FALSE)
/obj/machinery/computer/cloning/proc/scan_occupant(occupant, mob/M, body_only)
var/mob/living/mob_occupant = get_mob_or_brainmob(occupant)
var/datum/dna/dna
+7 -7
View File
@@ -312,15 +312,15 @@
if(7 to 9)
dance5(M)
/obj/machinery/jukebox/disco/proc/dance2(var/mob/living/M)
for(var/i = 1, i < 10, i++)
for(var/d in list(NORTH,SOUTH,EAST,WEST,EAST,SOUTH,NORTH,SOUTH,EAST,WEST,EAST,SOUTH))
M.setDir(d)
if(i == WEST)
M.emote("flip")
sleep(1)
/obj/machinery/jukebox/disco/proc/dance2(mob/living/M)
for(var/i in 0 to 9)
dance_rotate(M, CALLBACK(M, /mob.proc/dance_flip))
sleep(20)
/mob/proc/dance_flip()
if(dir == WEST)
emote("flip")
/obj/machinery/jukebox/disco/proc/dance3(var/mob/living/M)
var/matrix/initial_matrix = matrix(M.transform)
for (var/i in 1 to 75)
+7 -5
View File
@@ -234,11 +234,7 @@
playsound(src, 'sound/machines/terminal_prompt.ogg', 50, FALSE)
say("Initiating scan...")
spawn(20)
clone_occupant(scanner.occupant)
loading = FALSE
updateUsrDialog()
playsound(src, 'sound/machines/terminal_prompt_confirm.ogg', 50, FALSE)
addtimer(CALLBACK(src, .proc/do_clone), 2 SECONDS)
//No locking an open scanner.
else if ((href_list["lock"]) && !isnull(scanner) && scanner.is_operational())
@@ -257,6 +253,12 @@
updateUsrDialog()
return
/obj/machinery/computer/prototype_cloning/proc/do_clone()
clone_occupant(scanner.occupant)
loading = FALSE
updateUsrDialog()
playsound(src, 'sound/machines/terminal_prompt_confirm.ogg', 50, FALSE)
/obj/machinery/computer/prototype_cloning/proc/clone_occupant(occupant)
var/mob/living/mob_occupant = get_mob_or_brainmob(occupant)
var/datum/dna/dna
@@ -292,8 +292,9 @@
controllock = TRUE
on = FALSE //turns off the turret temporarily
update_icon()
sleep(60) //6 seconds for the traitor to gtfo of the area before the turret decides to ruin his shit
on = TRUE //turns it back on. The cover popUp() popDown() are automatically called in process(), no need to define it here
//6 seconds for the traitor to gtfo of the area before the turret decides to ruin his shit
addtimer(VARSET_CALLBACK(src, on, TRUE), 6 SECONDS)
//turns it back on. The cover popUp() popDown() are automatically called in process(), no need to define it here
/obj/machinery/porta_turret/emp_act(severity)
@@ -47,14 +47,16 @@ GLOBAL_VAR_INIT(message_delay, 0) // To make sure restarting the recentmessages
signal.broadcast()
if(!GLOB.message_delay)
GLOB.message_delay = 1
spawn(10)
GLOB.message_delay = 0
GLOB.recentmessages = list()
GLOB.message_delay = TRUE
addtimer(CALLBACK(GLOBAL_PROC, .proc/end_message_delay), 1 SECONDS)
/* --- Do a snazzy animation! --- */
flick("broadcaster_send", src)
/proc/end_message_delay()
GLOB.message_delay = FALSE
GLOB.recentmessages = list()
/obj/machinery/telecomms/broadcaster/Destroy()
// In case message_delay is left on 1, otherwise it won't reset the list and people can't say the same thing twice anymore.
if(GLOB.message_delay)
@@ -172,9 +172,11 @@
if(severity == 1) //so shreds created during an explosion aren't deleted by the explosion.
qdel(src)
/obj/effect/decal/cleanable/shreds/Initialize()
/obj/effect/decal/cleanable/shreds/Initialize(mapload, oldname)
pixel_x = rand(-10, 10)
pixel_y = rand(-10, 10)
if(!isnull(oldname))
desc = "The sad remains of what used to be [oldname]"
. = ..()
/obj/effect/decal/cleanable/glitter
@@ -93,10 +93,9 @@
S.set_opacity(TRUE)
newsmokes.Add(S)
if(newsmokes.len)
spawn(1) //the smoke spreads rapidly but not instantly
for(var/obj/effect/particle_effect/smoke/SM in newsmokes)
SM.spread_smoke()
//the smoke spreads rapidly but not instantly
for(var/obj/effect/particle_effect/smoke/SM in newsmokes)
addtimer(CALLBACK(SM, /obj/effect/particle_effect/smoke.proc/spread_smoke), 1)
/datum/effect_system/smoke_spread
+4 -2
View File
@@ -296,12 +296,14 @@
var/obj/effect/particle_effect/foam/metal/resin/F = new (get_turf(target))
F.amount = 0
metal_synthesis_cooldown++
spawn(100)
metal_synthesis_cooldown--
addtimer(CALLBACK(src, .proc/reduce_metal_synth_cooldown), 10 SECONDS)
else
to_chat(user, "<span class='warning'>Resin foam mix is still being synthesized...</span>")
return
/obj/item/extinguisher/mini/nozzle/proc/reduce_metal_synth_cooldown()
metal_synthesis_cooldown--
/obj/effect/resin_container
name = "resin container"
desc = "A compacted ball of expansive resin, used to repair the atmosphere in a room, or seal off breaches."
+1 -5
View File
@@ -354,11 +354,7 @@
INVOKE_ASYNC(src, .proc/jedi_spin, user)
/obj/item/twohanded/dualsaber/proc/jedi_spin(mob/living/user)
for(var/i in list(NORTH,SOUTH,EAST,WEST,EAST,SOUTH,NORTH,SOUTH,EAST,WEST,EAST,SOUTH))
user.setDir(i)
if(i == WEST)
user.emote("flip")
sleep(1)
dance_rotate(user, CALLBACK(user, /mob.proc/dance_flip))
/obj/item/twohanded/dualsaber/proc/impale(mob/living/user)
to_chat(user, "<span class='warning'>You twirl around a bit before losing your balance and impaling yourself on [src].</span>")
@@ -37,6 +37,8 @@
/obj/structure/closet/crate/bin/proc/do_animate()
playsound(loc, open_sound, 15, TRUE, -3)
flick("animate_largebins", src)
spawn(13)
playsound(loc, close_sound, 15, TRUE, -3)
update_icon()
addtimer(CALLBACK(src, .proc/do_close), 13)
/obj/structure/closet/crate/bin/proc/do_close()
playsound(loc, close_sound, 15, TRUE, -3)
update_icon()
+10 -11
View File
@@ -188,16 +188,7 @@
//AdminPM popup for ApocStation and anybody else who wants to use it. Set it with POPUP_ADMIN_PM in config.txt ~Carn
if(CONFIG_GET(flag/popup_admin_pm))
spawn() //so we don't hold the caller proc up
var/sender = src
var/sendername = key
var/reply = input(recipient, msg,"Admin PM from-[sendername]", "") as message|null //show message and await a reply
if(recipient && reply)
if(sender)
recipient.cmd_admin_pm(sender,reply) //sender is still about, let's reply to them
else
adminhelp(reply) //sender has left, adminhelp instead
return
INVOKE_ASYNC(src, .proc/popup_admin_pm, recipient, msg)
else //neither are admins
to_chat(src, "<span class='danger'>Error: Admin-PM: Non-admin to non-admin PM communication is forbidden.</span>")
@@ -215,7 +206,15 @@
if(X.key!=key && X.key!=recipient.key) //check client/X is an admin and isn't the sender or recipient
to_chat(X, "<span class='notice'><B>PM: [key_name(src, X, 0)]-&gt;[key_name(recipient, X, 0)]:</B> [keywordparsedmsg]</span>" )
/client/proc/popup_admin_pm(client/recipient, msg)
var/sender = src
var/sendername = key
var/reply = input(recipient, msg,"Admin PM from-[sendername]", "") as message|null //show message and await a reply
if(recipient && reply)
if(sender)
recipient.cmd_admin_pm(sender,reply) //sender is still about, let's reply to them
else
adminhelp(reply) //sender has left, adminhelp instead
#define IRC_AHELP_USAGE "Usage: ticket <close|resolve|icissue|reject|reopen \[ticket #\]|list>"
/proc/IrcPm(target,msg,sender)
@@ -449,8 +449,7 @@
if(interrupted(user))
return
on_cooldown = 2
sleep(40)
on_cooldown = 0
addtimer(VARSET_CALLBACK(src, on_cooldown, 0), 4 SECONDS)
/obj/item/warpwhistle/Destroy()
if(on_cooldown == 1 && last_user) //Flute got dunked somewhere in the teleport
+2 -3
View File
@@ -319,9 +319,8 @@ BLIND // can't see anything
/obj/item/clothing/obj_destruction(damage_flag)
if(damage_flag == "bomb" || damage_flag == "melee")
var/turf/T = get_turf(src)
spawn(1) //so the shred survives potential turf change from the explosion.
var/obj/effect/decal/cleanable/shreds/Shreds = new(T)
Shreds.desc = "The sad remains of what used to be [name]."
//so the shred survives potential turf change from the explosion.
addtimer(CALLBACK_NEW(/obj/effect/decal/cleanable/shreds, list(T, name)), 1)
deconstruct(FALSE)
else
..()
@@ -494,19 +494,19 @@
to_chat(user, "<span class='info'>You light [src] on fire.</span>")
add_overlay(GLOB.fire_overlay)
if(!isGlass)
spawn(50)
if(active)
var/counter
var/target = src.loc
for(counter = 0, counter<2, counter++)
if(istype(target, /obj/item/storage))
var/obj/item/storage/S = target
target = S.loc
if(istype(target, /atom))
var/atom/A = target
SplashReagents(A)
A.fire_act()
qdel(src)
addtimer(CALLBACK(src, .proc/explode), 5 SECONDS)
/obj/item/reagent_containers/food/drinks/bottle/molotov/proc/explode()
if(!active)
return
if(get_turf(src))
var/atom/target = loc
for(var/i in 1 to 2)
if(istype(target, /obj/item/storage))
target = target.loc
SplashReagents(target)
target.fire_act()
qdel(src)
/obj/item/reagent_containers/food/drinks/bottle/molotov/attack_self(mob/user)
if(active)
+1 -2
View File
@@ -28,8 +28,7 @@
ShutOffDoomsdayDevice()
if(explosive)
spawn(10)
explosion(src.loc, 3, 6, 12, 15)
addtimer(CALLBACK(GLOBAL_PROC, .proc/explosion, loc, 3, 6, 12, 15), 1 SECONDS)
if(src.key)
for(var/each in GLOB.ai_status_displays) //change status
@@ -50,7 +50,7 @@
user.do_attack_animation(src)
if (user.name == master)
visible_message("<span class='notice'>Responding to its master's touch, [src] disengages its holochassis emitter, rapidly losing coherence.</span>")
spawn(10)
if(do_after(user, 1 SECONDS, TRUE, src))
fold_in()
if(user.put_in_hands(card))
user.visible_message("<span class='notice'>[user] promptly scoops up [user.p_their()] pAI's card.</span>")
@@ -70,10 +70,7 @@
if(prob(1))
emote("me", 1, pick("dances around.","chases its tail!"))
spawn(0)
for(var/i in list(1,2,4,8,4,2,1,2,4,8,4,2,1,2,4,8,4,2))
setDir(i)
sleep(1)
INVOKE_ASYNC(GLOBAL_PROC, .proc/dance_rotate, src)
//Corgis and pugs are now under one dog subtype
@@ -295,9 +292,7 @@
item_to_add.forceMove(drop_location())
if(prob(25))
step_rand(item_to_add)
for(var/i in list(1,2,4,8,4,8,4,dir))
setDir(i)
sleep(1)
dance_rotate(src, set_original_dir=TRUE)
return
item_to_add.forceMove(src)
@@ -357,9 +352,7 @@
item_to_add.forceMove(drop_location())
if(prob(25))
step_rand(item_to_add)
for(var/i in list(1,2,4,8,4,8,4,dir))
setDir(i)
sleep(1)
dance_rotate(src, set_original_dir=TRUE)
return valid
@@ -31,10 +31,7 @@
if(istype(O, /obj/item/newspaper))
if(!stat)
user.visible_message("<span class='notice'>[user] baps [name] on the nose with the rolled up [O].</span>")
spawn(0)
for(var/i in list(1,2,4,8,4,2,1,2))
setDir(i)
sleep(1)
dance_rotate(src)
else
..()
@@ -102,17 +102,7 @@
if(hasmatchingsummoner(L)) //if the summoner matches don't hurt them
continue
if(successfulshocks > 4)
if(iscarbon(L))
var/mob/living/carbon/C = L
if(ishuman(C))
var/mob/living/carbon/human/H = C
H.electrocution_animation(20)
C.jitteriness += 1000
C.do_jitter_animation(jitteriness)
C.stuttering += 1
spawn(20)
if(C)
C.jitteriness = max(C.jitteriness - 990, 10)
L.electrocute_act(0)
L.visible_message(
"<span class='danger'>[L] was shocked by the lightning chain!</span>", \
"<span class='userdanger'>You are shocked by the lightning chain!</span>", \
+3 -3
View File
@@ -215,9 +215,9 @@ GLOBAL_LIST_EMPTY(employmentCabinets)
if(virgin)
fillCurrent()
virgin = 0
cooldown = 1
sleep(100) // prevents the devil from just instantly emptying the cabinet, ensuring an easy win.
cooldown = 0
cooldown = TRUE
// prevents the devil from just instantly emptying the cabinet, ensuring an easy win.
addtimer(VARSET_CALLBACK(src, cooldown, FALSE), 10 SECONDS)
else
to_chat(user, "<span class='warning'>[src] is jammed, give it a few seconds.</span>")
..()
+8 -8
View File
@@ -86,8 +86,7 @@
c.copy_overlays(copy, TRUE)
toner--
busy = TRUE
sleep(15)
busy = FALSE
addtimer(CALLBACK(src, .proc/reset_busy), 1.5 SECONDS)
else
break
updateUsrDialog()
@@ -96,8 +95,7 @@
if(toner >= 5 && !busy && photocopy) //Was set to = 0, but if there was say 3 toner left and this ran, you would get -2 which would be weird for ink
new /obj/item/photo (loc, photocopy.picture.Copy(greytoggle == "Greyscale"? TRUE : FALSE))
busy = TRUE
sleep(15)
busy = FALSE
addtimer(CALLBACK(src, .proc/reset_busy), 1.5 SECONDS)
else
break
else if(doccopy)
@@ -106,8 +104,7 @@
new /obj/item/documents/photocopy(loc, doccopy)
toner-= 6 // the sprite shows 6 papers, yes I checked
busy = TRUE
sleep(15)
busy = FALSE
addtimer(CALLBACK(src, .proc/reset_busy), 1.5 SECONDS)
else
break
updateUsrDialog()
@@ -175,8 +172,7 @@
photo.pixel_y = rand(-10, 10)
toner -= 5 //AI prints color pictures only, thus they can do it more efficiently
busy = TRUE
sleep(15)
busy = FALSE
addtimer(CALLBACK(src, .proc/reset_busy), 1.5 SECONDS)
updateUsrDialog()
else if(href_list["colortoggle"])
if(greytoggle == "Greyscale")
@@ -185,6 +181,10 @@
greytoggle = "Greyscale"
updateUsrDialog()
/obj/machinery/photocopier/proc/reset_busy()
busy = FALSE
updateUsrDialog()
/obj/machinery/photocopier/proc/do_insertion(obj/item/O, mob/user)
O.forceMove(src)
to_chat(user, "<span class='notice'>You insert [O] into [src].</span>")
+15 -12
View File
@@ -293,18 +293,21 @@
if(start_with_cell && !no_emergency)
cell = new/obj/item/stock_parts/cell/emergency_light(src)
spawn(2)
switch(fitting)
if("tube")
brightness = 8
if(prob(2))
break_light_tube(1)
if("bulb")
brightness = 4
if(prob(5))
break_light_tube(1)
spawn(1)
update(0)
return INITIALIZE_HINT_LATELOAD
/obj/machinery/light/LateInitialize()
. = ..()
switch(fitting)
if("tube")
brightness = 8
if(prob(2))
break_light_tube(1)
if("bulb")
brightness = 4
if(prob(5))
break_light_tube(1)
addtimer(CALLBACK(src, .proc/update, 0), 1)
/obj/machinery/light/Destroy()
var/area/A = get_area(src)