From 37eaa510e0a87ff9c7587352b3585588f1193020 Mon Sep 17 00:00:00 2001 From: tmtmtl30 <53132901+tmtmtl30@users.noreply.github.com> Date: Mon, 15 Feb 2021 04:01:26 -0800 Subject: [PATCH] Fixes airlock autoclose, adds a sanity check to welding doors shut. (#3211) * removes unused door var, sanity checks welding * Fixes doors failing to autoclose. --- .../Components/Doors/ServerDoorComponent.cs | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/Content.Server/GameObjects/Components/Doors/ServerDoorComponent.cs b/Content.Server/GameObjects/Components/Doors/ServerDoorComponent.cs index 34b23fecca..c6b2825d54 100644 --- a/Content.Server/GameObjects/Components/Doors/ServerDoorComponent.cs +++ b/Content.Server/GameObjects/Components/Doors/ServerDoorComponent.cs @@ -67,13 +67,6 @@ namespace Content.Server.GameObjects.Components.Doors } } - /// - /// The amount of time the door has been open. Used to automatically close the door if it autocloses. - /// - [ViewVariables] - private float _openTimeCounter; - [ViewVariables(VVAccess.ReadWrite)] - private static readonly TimeSpan AutoCloseDelay = TimeSpan.FromSeconds(5); private CancellationTokenSource? _stateChangeCancelTokenSource; @@ -441,7 +434,6 @@ namespace Content.Server.GameObjects.Components.Doors public void Close() { State = DoorState.Closing; - _openTimeCounter = 0; // no more autoclose; we ARE closed _autoCloseCancelTokenSource?.Cancel(); @@ -573,7 +565,7 @@ namespace Content.Server.GameObjects.Components.Doors var realCloseTime = _doorCheck.GetCloseSpeed() ?? AutoCloseDelay; - Owner.SpawnTimer(realCloseTime, async () => + Owner.SpawnRepeatingTimer(realCloseTime, async () => { if (CanCloseGeneric()) { @@ -628,6 +620,12 @@ namespace Content.Server.GameObjects.Components.Doors _beingWelded = true; if(await welder.UseTool(eventArgs.User, Owner, 3f, ToolQuality.Welding, 3f, () => CanWeldShut)) { + // just in case + if (!CanWeldShut) + { + return false; + } + _beingWelded = false; IsWeldedShut = !IsWeldedShut; return true;