From 362caf6aeefe90c74b72fe25a1117cca9e1e7204 Mon Sep 17 00:00:00 2001 From: Bloop Date: Sat, 18 Mar 2023 11:10:17 -0400 Subject: [PATCH] [MODULAR] Fixes a couple of race conditions with inflatables (#19902) * Fixes a race condition with inflatables * Fixes the runtime in the issue report --- modular_skyrat/modules/inflatables/code/inflatable.dm | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/modular_skyrat/modules/inflatables/code/inflatable.dm b/modular_skyrat/modules/inflatables/code/inflatable.dm index b22688dd450..813ea27d499 100644 --- a/modular_skyrat/modules/inflatables/code/inflatable.dm +++ b/modular_skyrat/modules/inflatables/code/inflatable.dm @@ -22,6 +22,8 @@ var/hit_sound = 'sound/effects/Glasshit.ogg' /// How quickly we deflate when manually deflated. var/manual_deflation_time = 3 SECONDS + /// Whether or not the inflatable has been deflated + var/has_been_deflated = FALSE /obj/structure/inflatable/Initialize(mapload) . = ..() @@ -62,12 +64,19 @@ // Deflates the airbag and drops a deflated airbag item. If violent, drops a broken item instantly. /obj/structure/inflatable/proc/deflate(violent) + if(has_been_deflated) // We do not ever want to deflate more than once. + return + + has_been_deflated = TRUE + playsound(src, 'sound/machines/hiss.ogg', 75, 1) if(!violent) balloon_alert_to_viewers("slowly deflates!") addtimer(CALLBACK(src, PROC_REF(slow_deflate_finish)), manual_deflation_time) return - balloon_alert_to_viewers("rapidly deflates!") + + var/turf/inflatable_loc = get_turf(src) + inflatable_loc.balloon_alert_to_viewers("[src] rapidly deflates!") // just so we don't balloon alert from the qdeleted inflatable object if(torn_type) new torn_type(get_turf(src)) qdel(src)