From 55f3970cc5b98e0d61c0485a1b6a449611aab074 Mon Sep 17 00:00:00 2001 From: psq95 Date: Fri, 26 Jan 2024 20:56:33 +0000 Subject: [PATCH] Halt autoclose when blocked too many times Wooden barricades in powered airlocks cause lag as the doors try to autoclose over and over. This change adds a failure count that increments each time a door attempts to close but something is blocking it. If it fails too many times, it simply stops trying. Doors can be closed manually once the blockage is removed. --- code/game/machinery/doors/airlock.dm | 7 +++++++ code/game/machinery/doors/door.dm | 10 ++++++++++ 2 files changed, 17 insertions(+) diff --git a/code/game/machinery/doors/airlock.dm b/code/game/machinery/doors/airlock.dm index f786cbbc..ed328c25 100644 --- a/code/game/machinery/doors/airlock.dm +++ b/code/game/machinery/doors/airlock.dm @@ -1204,9 +1204,16 @@ return if(safe) for(var/atom/movable/M in get_turf(src)) + if (failCount > failThreshold) //something is continuously blocking the door + do_sparks(5, TRUE, src) + visible_message("[src]'s timing mechanism fails.") + failCount = 0 + return if(M.density && M != src) //something is blocking the door autoclose_in(60) + failCount++ return + failCount = 0 if(forced < 2) if(obj_flags & EMAGGED) diff --git a/code/game/machinery/doors/door.dm b/code/game/machinery/doors/door.dm index 69363d5a..0551d16e 100644 --- a/code/game/machinery/doors/door.dm +++ b/code/game/machinery/doors/door.dm @@ -37,6 +37,10 @@ var/poddoor = FALSE var/unres_sides = 0 //Unrestricted sides. A bitflag for which direction (if any) can open the door with no access + // GS13: Halt autoclose when blocked with static object, like a wooden barricade... + var/failCount = 0 + var/failThreshold = 5 + /obj/machinery/door/examine(mob/user) . = ..() if(red_alert_access) @@ -284,10 +288,16 @@ return if(safe) for(var/atom/movable/M in get_turf(src)) + if (failCount > failThreshold) //something is continuously blocking the door + do_sparks(5, TRUE, src) + visible_message("[src]'s timing mechanism fails.") + failCount = 0 + return if(M.density && M != src) //something is blocking the door if(autoclose) autoclose_in(60) return + failCount = 0 operating = TRUE