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.
This commit is contained in:
psq95
2024-01-26 20:56:33 +00:00
parent a59a79678d
commit 55f3970cc5
2 changed files with 17 additions and 0 deletions
+7
View File
@@ -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("<span class='warning'>[src]'s timing mechanism fails.</span>")
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)
+10
View File
@@ -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("<span class='warning'>[src]'s timing mechanism fails.</span>")
failCount = 0
return
if(M.density && M != src) //something is blocking the door
if(autoclose)
autoclose_in(60)
return
failCount = 0
operating = TRUE