From 765f8e32e0c899290acf58a995b73e68eab0cfd6 Mon Sep 17 00:00:00 2001
From: Coconutwarrior97 <40315842+Coconutwarrior97@users.noreply.github.com>
Date: Fri, 1 Mar 2019 14:43:53 -0600
Subject: [PATCH] Fixes transit tube barricade spam (#42813)
* Only two transit tubes per turf can be wrenched down.
* Made a can_wrench_in_loc() proc. Placed it at start of wrench_act and afterI.use_tool.
* This aint lookin hot.
* Should be working now.
* Added proc at start of wrench_act.
* Fixed if statement and put it before to_chat.
---
.../transit_tubes/transit_tube_construction.dm | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/code/game/objects/structures/transit_tubes/transit_tube_construction.dm b/code/game/objects/structures/transit_tubes/transit_tube_construction.dm
index fb5988f72af..9a2898f2d89 100644
--- a/code/game/objects/structures/transit_tubes/transit_tube_construction.dm
+++ b/code/game/objects/structures/transit_tubes/transit_tube_construction.dm
@@ -15,6 +15,15 @@
var/flipped_build_type
var/base_icon
+/obj/structure/c_transit_tube/proc/can_wrench_in_loc(mob/user)
+ var/turf/source_turf = get_turf(loc)
+ var/existing_tubes = 0
+ for(var/obj/structure/transit_tube/tube in source_turf)
+ existing_tubes +=1
+ if(existing_tubes >= 2)
+ to_chat(user, "You cannot wrench anymore transit tubes! ")
+ return FALSE
+ return TRUE
/obj/structure/c_transit_tube/ComponentInitialize()
. = ..()
@@ -32,9 +41,11 @@
icon_state = "[base_icon][flipped]"
/obj/structure/c_transit_tube/wrench_act(mob/living/user, obj/item/I)
+ if(!can_wrench_in_loc(user))
+ return
to_chat(user, "You start attaching the [name]...")
add_fingerprint(user)
- if(I.use_tool(src, user, time_to_unwrench, volume=50))
+ if(I.use_tool(src, user, time_to_unwrench, volume=50, extra_checks=CALLBACK(src, .proc/can_wrench_in_loc, user)))
to_chat(user, "You attach the [name].")
var/obj/structure/transit_tube/R = new build_type(loc, dir)
transfer_fingerprints_to(R)