From 6d92a0fe88321f6d2e6642d180ac29bf4eeeebd8 Mon Sep 17 00:00:00 2001 From: commy2 Date: Wed, 22 Apr 2015 21:31:42 +0200 Subject: [PATCH] abort if stuff changes --- .../repair/functions/fnc_canReplaceWheel.sqf | 23 ++++++++++++------- addons/repair/functions/fnc_removeWheel.sqf | 2 +- addons/repair/functions/fnc_repairVehicle.sqf | 2 +- addons/repair/functions/fnc_replaceWheel.sqf | 2 +- 4 files changed, 18 insertions(+), 11 deletions(-) diff --git a/addons/repair/functions/fnc_canReplaceWheel.sqf b/addons/repair/functions/fnc_canReplaceWheel.sqf index 26038fc78d..585df1dd86 100644 --- a/addons/repair/functions/fnc_canReplaceWheel.sqf +++ b/addons/repair/functions/fnc_canReplaceWheel.sqf @@ -13,25 +13,32 @@ */ #include "script_component.hpp" -private ["_unit", "_target", "_hitPoint"]; +private ["_unit", "_target", "_hitPoint", "_wheel"]; _unit = _this select 0; _target = _this select 1; _hitPoint = _this select 2; +_wheel = ARR_SELECT(_this,3,false); if !([_unit, _target, []] call EFUNC(common,canInteractWith)) exitWith {false}; if !([_unit, GVAR(engineerSetting_Wheel)] call FUNC(isEngineer)) exitWith {false}; // check for a near wheel -private "_wheel"; -_wheel = objNull; - -{ - if ([_unit, _x, ["isNotDragging", "isNotCarrying"]] call EFUNC(common,canInteractWith)) exitWith { - _wheel = _x; +if (typeName _wheel == "OBJECT") then { + // not near interpret as objNull + if !(_wheel in nearestObjects [_unit, ["ACE_Wheel"], 5]) then { + _wheel = objNull; }; -} forEach nearestObjects [_unit, ["ACE_Wheel"], 5]; +} else { + _wheel = objNull; + + { + if ([_unit, _x, ["isNotDragging", "isNotCarrying"]] call EFUNC(common,canInteractWith)) exitWith { + _wheel = _x; + }; + } forEach nearestObjects [_unit, ["ACE_Wheel"], 5]; +}; if (isNull _wheel) exitWith {false}; diff --git a/addons/repair/functions/fnc_removeWheel.sqf b/addons/repair/functions/fnc_removeWheel.sqf index 4c40cc454c..ca6d33c90f 100644 --- a/addons/repair/functions/fnc_removeWheel.sqf +++ b/addons/repair/functions/fnc_removeWheel.sqf @@ -27,7 +27,7 @@ private "_time"; _time = 10; // open the loading bar -[_time, [_unit, _vehicle, _hitPoint], {(_this select 0) call DFUNC(doRemoveWheel)}, {[localize "STR_ACE_Common_ActionAborted"] call EFUNC(common,displayTextStructured);}, localize "STR_ACE_Repair_RemovingWheel", {true}, []] call EFUNC(common,progressBar); +[_time, [_unit, _vehicle, _hitPoint], {(_this select 0) call DFUNC(doRemoveWheel)}, {[localize "STR_ACE_Common_ActionAborted"] call EFUNC(common,displayTextStructured);}, localize "STR_ACE_Repair_RemovingWheel", {(_this select 0) call DFUNC(canRemoveWheel)}, []] call EFUNC(common,progressBar); // do animation [_unit] call EFUNC(common,goKneeling); diff --git a/addons/repair/functions/fnc_repairVehicle.sqf b/addons/repair/functions/fnc_repairVehicle.sqf index c253e7f36e..053a4172a1 100644 --- a/addons/repair/functions/fnc_repairVehicle.sqf +++ b/addons/repair/functions/fnc_repairVehicle.sqf @@ -40,7 +40,7 @@ if (isLocalized _text) then { }; // open the loading bar -[_time, [_unit, _vehicle, _hitPoint], {_this call DFUNC(doRepair)}, {_this call DFUNC(doRepair)}, _text, {true}, []] call EFUNC(common,progressBar); +[_time, [_unit, _vehicle, _hitPoint], {_this call DFUNC(doRepair)}, {_this call DFUNC(doRepair)}, _text, {(_this select 0) call DFUNC(canRepair)}, []] call EFUNC(common,progressBar); // do animation [_unit] call EFUNC(common,goKneeling); diff --git a/addons/repair/functions/fnc_replaceWheel.sqf b/addons/repair/functions/fnc_replaceWheel.sqf index 9cf43bb6ae..9ae16f168d 100644 --- a/addons/repair/functions/fnc_replaceWheel.sqf +++ b/addons/repair/functions/fnc_replaceWheel.sqf @@ -41,7 +41,7 @@ private "_time"; _time = 10; // open the loading bar -[_time, [_unit, _vehicle, _hitPoint, _wheel], {(_this select 0) call DFUNC(doReplaceWheel)}, {[objNull, _this select 0 select 3] call DEFUNC(common,claim); [localize "STR_ACE_Common_ActionAborted"] call EFUNC(common,displayTextStructured);}, localize "STR_ACE_Repair_ReplacingWheel", {true}, []] call EFUNC(common,progressBar); +[_time, [_unit, _vehicle, _hitPoint, _wheel], {(_this select 0) call DFUNC(doReplaceWheel)}, {[objNull, _this select 0 select 3] call DEFUNC(common,claim); [localize "STR_ACE_Common_ActionAborted"] call EFUNC(common,displayTextStructured);}, localize "STR_ACE_Repair_ReplacingWheel", {(_this select 0) call DFUNC(canReplaceWheel)}, []] call EFUNC(common,progressBar); // do animation [_unit] call EFUNC(common,goKneeling);