From 1fc778f70a9274133d6048f63d320b0b9cec34ae Mon Sep 17 00:00:00 2001 From: LetterN <24603524+LetterN@users.noreply.github.com> Date: Sat, 30 Oct 2021 13:16:31 +0800 Subject: [PATCH] soundloop fix. also it gets deleted (woo) --- .../items/devices/reverse_bear_trap.dm | 21 ++++++++---- code/game/objects/structures/watercloset.dm | 2 +- code/modules/clothing/spacesuits/hardsuit.dm | 6 +++- .../kitchen_machinery/deep_fryer.dm | 6 +++- .../kitchen_machinery/grill.dm | 32 +++++++++++-------- .../kitchen_machinery/microwave.dm | 3 +- code/modules/power/port_gen.dm | 2 +- code/modules/power/supermatter/supermatter.dm | 3 +- 8 files changed, 50 insertions(+), 25 deletions(-) diff --git a/code/game/objects/items/devices/reverse_bear_trap.dm b/code/game/objects/items/devices/reverse_bear_trap.dm index f2a0ea5450..de7e3d2812 100644 --- a/code/game/objects/items/devices/reverse_bear_trap.dm +++ b/code/game/objects/items/devices/reverse_bear_trap.dm @@ -24,8 +24,8 @@ /obj/item/reverse_bear_trap/Initialize() . = ..() - soundloop = new(list(src)) - soundloop2 = new(list(src)) + soundloop = new(src) + soundloop2 = new(src) /obj/item/reverse_bear_trap/Destroy() QDEL_NULL(soundloop) @@ -33,16 +33,16 @@ STOP_PROCESSING(SSprocessing, src) return ..() -/obj/item/reverse_bear_trap/process() +/obj/item/reverse_bear_trap/process(delta_time) if(!ticking) return - time_left-- + time_left -= delta_time soundloop2.mid_length = max(0.5, time_left - 5) //beepbeepbeepbeepbeep - if(!time_left || !isliving(loc)) + if(time_left <= 0 || !isliving(loc)) playsound(src, 'sound/machines/microwave/microwave-end.ogg', 100, FALSE) soundloop.stop() soundloop2.stop() - to_chat(loc, "*ding*") + to_chat(loc, span_userdanger("*ding*")) addtimer(CALLBACK(src, .proc/snap), 2) /obj/item/reverse_bear_trap/on_attack_hand(mob/user, act_intent = user.a_intent, unarmed_attack_flags) @@ -116,13 +116,22 @@ /obj/item/reverse_bear_trap/proc/reset() ticking = FALSE + update_appearance(UPDATE_OVERLAYS) REMOVE_TRAIT(src, TRAIT_NODROP, REVERSE_BEAR_TRAP_TRAIT) soundloop.stop() soundloop2.stop() STOP_PROCESSING(SSprocessing, src) +/obj/item/reverse_bear_trap/update_overlays() + . = ..() + if(ticking != TRUE) + return + /// note: this timer overlay increments one frame every second (to simulate a clock ticking). If you want to instead have it do a full cycle in a minute, set the 'delay' of each frame of the icon overlay to 75 rather than 10, and the worn overlay to twice that. + // . += "rbt_ticking" + /obj/item/reverse_bear_trap/proc/arm() //hulen ticking = TRUE + update_appearance(UPDATE_OVERLAYS) escape_chance = initial(escape_chance) //we keep these vars until re-arm, for tracking purposes time_left = initial(time_left) ADD_TRAIT(src, TRAIT_NODROP, REVERSE_BEAR_TRAP_TRAIT) diff --git a/code/game/objects/structures/watercloset.dm b/code/game/objects/structures/watercloset.dm index 9a2b4aab1a..85b9f17125 100644 --- a/code/game/objects/structures/watercloset.dm +++ b/code/game/objects/structures/watercloset.dm @@ -257,7 +257,7 @@ /obj/machinery/shower/Initialize() . = ..() - soundloop = new(list(src), FALSE) + soundloop = new(src, FALSE) /obj/machinery/shower/Destroy() QDEL_NULL(soundloop) diff --git a/code/modules/clothing/spacesuits/hardsuit.dm b/code/modules/clothing/spacesuits/hardsuit.dm index cd48a81350..a7f1e1db0b 100644 --- a/code/modules/clothing/spacesuits/hardsuit.dm +++ b/code/modules/clothing/spacesuits/hardsuit.dm @@ -20,12 +20,16 @@ /obj/item/clothing/head/helmet/space/hardsuit/Initialize() . = ..() - soundloop = new(list(), FALSE, TRUE) + soundloop = new(src, FALSE, TRUE) soundloop.volume = 5 START_PROCESSING(SSobj, src) /obj/item/clothing/head/helmet/space/hardsuit/Destroy() . = ..() + if(!QDELETED(suit)) + qdel(suit) + suit = null + QDEL_NULL(soundloop) STOP_PROCESSING(SSobj, src) /obj/item/clothing/head/helmet/space/hardsuit/attack_self(mob/user) diff --git a/code/modules/food_and_drinks/kitchen_machinery/deep_fryer.dm b/code/modules/food_and_drinks/kitchen_machinery/deep_fryer.dm index ebde504ec0..a41970ea2b 100644 --- a/code/modules/food_and_drinks/kitchen_machinery/deep_fryer.dm +++ b/code/modules/food_and_drinks/kitchen_machinery/deep_fryer.dm @@ -57,7 +57,11 @@ God bless America. component_parts += new /obj/item/circuitboard/machine/deep_fryer(null) component_parts += new /obj/item/stock_parts/micro_laser(null) RefreshParts() - fry_loop = new(list(src), FALSE) + fry_loop = new(src, FALSE) + +/obj/machinery/deepfryer/Destroy() + QDEL_NULL(fry_loop) + return ..() /obj/machinery/deepfryer/RefreshParts() var/oil_efficiency diff --git a/code/modules/food_and_drinks/kitchen_machinery/grill.dm b/code/modules/food_and_drinks/kitchen_machinery/grill.dm index 09e1d7b1c6..02b24402db 100644 --- a/code/modules/food_and_drinks/kitchen_machinery/grill.dm +++ b/code/modules/food_and_drinks/kitchen_machinery/grill.dm @@ -13,15 +13,21 @@ /obj/machinery/grill/Initialize() . = ..() - grill_loop = new(list(src), FALSE) + grill_loop = new(src, FALSE) + +/obj/machinery/grill/Destroy() + QDEL_NULL(grill_loop) + return ..() /obj/machinery/grill/update_icon_state() if(grilled_item) icon_state = "grill" - else if(grill_fuel) + return ..() + if(grill_fuel > 0) icon_state = "grill_on" - else - icon_state = "grill_open" + return ..() + icon_state = "grill_open" + return ..() /obj/machinery/grill/attackby(obj/item/I, mob/user) if(istype(I, /obj/item/stack/sheet/mineral/coal) || istype(I, /obj/item/stack/sheet/mineral/wood)) @@ -60,21 +66,21 @@ return ..() -/obj/machinery/grill/process() +/obj/machinery/grill/process(delta_time) ..() - update_icon() - if(!grill_fuel) + update_appearance() + if(grill_fuel <= 0) return else - grill_fuel -= 1 - if(prob(1)) + grill_fuel -= 0.5 * delta_time + if(DT_PROB(0.5, delta_time)) var/datum/effect_system/smoke_spread/bad/smoke = new smoke.set_up(1, loc) smoke.start() if(grilled_item) - grill_time += 1 + grill_time += delta_time grilled_item.reagents.add_reagent("char", 1) - grill_fuel -= 10 + grill_fuel -= 5 * delta_time grilled_item.AddComponent(/datum/component/sizzle) /obj/machinery/grill/Exited(atom/movable/AM) @@ -109,9 +115,9 @@ /obj/machinery/grill/on_attack_hand(mob/user, act_intent = user.a_intent, unarmed_attack_flags) if(grilled_item) - to_chat(user, "You take out [grilled_item] from [src].") + to_chat(user, span_notice("You take out [grilled_item] from [src].")) grilled_item.forceMove(drop_location()) - update_icon() + update_appearance() return return ..() diff --git a/code/modules/food_and_drinks/kitchen_machinery/microwave.dm b/code/modules/food_and_drinks/kitchen_machinery/microwave.dm index 5954788d5c..c4ac4c2dcf 100644 --- a/code/modules/food_and_drinks/kitchen_machinery/microwave.dm +++ b/code/modules/food_and_drinks/kitchen_machinery/microwave.dm @@ -36,12 +36,13 @@ . = ..() wires = new /datum/wires/microwave(src) create_reagents(100) - soundloop = new(list(src), FALSE) + soundloop = new(src, FALSE) /obj/machinery/microwave/Destroy() eject() if(wires) QDEL_NULL(wires) + QDEL_NULL(soundloop) . = ..() /obj/machinery/microwave/RefreshParts() diff --git a/code/modules/power/port_gen.dm b/code/modules/power/port_gen.dm index b5ed659e47..a57711a539 100644 --- a/code/modules/power/port_gen.dm +++ b/code/modules/power/port_gen.dm @@ -19,7 +19,7 @@ /obj/machinery/power/port_gen/Initialize() . = ..() - soundloop = new(list(src), active) + soundloop = new(src, active) /obj/machinery/power/port_gen/Destroy() QDEL_NULL(soundloop) diff --git a/code/modules/power/supermatter/supermatter.dm b/code/modules/power/supermatter/supermatter.dm index 8da3433381..baee4d85dc 100644 --- a/code/modules/power/supermatter/supermatter.dm +++ b/code/modules/power/supermatter/supermatter.dm @@ -210,7 +210,7 @@ GLOBAL_DATUM(main_supermatter_engine, /obj/machinery/power/supermatter_crystal) AddElement(/datum/element/bsa_blocker) RegisterSignal(src, COMSIG_ATOM_BSA_BEAM, .proc/call_explode) - soundloop = new(list(src), TRUE) + soundloop = new(src, TRUE) /obj/machinery/power/supermatter_crystal/Destroy() investigate_log("has been destroyed.", INVESTIGATE_SUPERMATTER) @@ -220,6 +220,7 @@ GLOBAL_DATUM(main_supermatter_engine, /obj/machinery/power/supermatter_crystal) QDEL_NULL(countdown) if(is_main_engine && GLOB.main_supermatter_engine == src) GLOB.main_supermatter_engine = null + QDEL_NULL(soundloop) return ..() /obj/machinery/power/supermatter_crystal/examine(mob/user)