From cddc34e08a2deb55759fd685a1f041955c5cc63e Mon Sep 17 00:00:00 2001
From: PabstMirror <pabstmirror@gmail.com>
Date: Sat, 8 Jul 2017 13:23:28 -0500
Subject: [PATCH] Handle locked doors (#5345)

---
 addons/interaction/functions/fnc_openDoor.sqf | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/addons/interaction/functions/fnc_openDoor.sqf b/addons/interaction/functions/fnc_openDoor.sqf
index 039974baa2..7d94a5c4a1 100644
--- a/addons/interaction/functions/fnc_openDoor.sqf
+++ b/addons/interaction/functions/fnc_openDoor.sqf
@@ -19,20 +19,25 @@
 private _info = [MACRO_DOOR_REACH_DISTANCE] call FUNC(getDoor);
 
 _info params ["_house", "_door"];
+TRACE_2("openDoor",_house,_door);
 
 if (isNull _house) exitWith {};
 
 private _getDoorAnimations = [_house, _door] call FUNC(getDoorAnimations);
 
-_getDoorAnimations params ["_animations", "_lockedVariable"];
+_getDoorAnimations params ["_animations"];
 
 if (_animations isEqualTo []) exitWith {};
 
+private _lockedVariable = format ["bis_disabled_%1", _door];
+
 //Check if the door can be locked aka have locked variable, otherwhise cant lock it
-if (!(isNil (_lockedVariable select 0))) then {
-    if ((_house animationPhase (_animations select 0) <= 0) && {_house getVariable [_lockedVariable select 0, 0] == 1}) exitWith {
-        _lockedVariable set [0, _house];
-        _lockedVariable call BIS_fnc_LockedDoorOpen;
+if ((_house animationPhase (_animations select 0) <= 0) && {_house getVariable [_lockedVariable, 0] == 1}) exitWith {
+    private _lockedAnimation = format ["%1_locked_source", _door];
+    TRACE_3("locked",_house,_lockedAnimation,isClass (configfile >> "CfgVehicles" >> (typeOf _house) >> "AnimationSources" >> _lockedAnimation));
+    if (isClass (configfile >> "CfgVehicles" >> (typeOf _house) >> "AnimationSources" >> _lockedAnimation)) then {
+        // from: a3\structures_f\scripts\fn_door.sqf: - wiggles the door handle (A3 buildings)
+        _house animateSource [_lockedAnimation, (1 - (_house animationSourcePhase _lockedAnimation))];
     };
 };