From 2ea029c219b338a0817dba6725e7834cdd28de5a Mon Sep 17 00:00:00 2001 From: PabstMirror Date: Thu, 21 Mar 2019 21:29:51 -0500 Subject: [PATCH] Quickmount - optimize subActions (#6883) --- addons/quickmount/CfgVehicles.hpp | 4 ++-- addons/quickmount/functions/fnc_canShowFreeSeats.sqf | 10 ++++++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/addons/quickmount/CfgVehicles.hpp b/addons/quickmount/CfgVehicles.hpp index d24a207d4b..a0b54df48b 100644 --- a/addons/quickmount/CfgVehicles.hpp +++ b/addons/quickmount/CfgVehicles.hpp @@ -43,7 +43,7 @@ class CfgVehicles { condition = QUOTE(call DFUNC(canShowFreeSeats)); \ statement = QUOTE(call DFUNC(getInNearest)); \ exceptions[] = {"isNotSwimming"}; \ - insertChildren = QUOTE(call DFUNC(addFreeSeatsActions)); \ + insertChildren = QUOTE((_this select 2) param [ARR_2(0, [])]); \ }; \ }; \ }; \ @@ -52,7 +52,7 @@ class CfgVehicles { displayName = CSTRING(ChangeSeat); \ condition = QUOTE(call DFUNC(canShowFreeSeats)); \ statement = ""; \ - insertChildren = QUOTE(call DFUNC(addFreeSeatsActions)); \ + insertChildren = QUOTE((_this select 2) param [ARR_2(0, [])]); \ }; \ } diff --git a/addons/quickmount/functions/fnc_canShowFreeSeats.sqf b/addons/quickmount/functions/fnc_canShowFreeSeats.sqf index 560a036a50..ac146a8c57 100644 --- a/addons/quickmount/functions/fnc_canShowFreeSeats.sqf +++ b/addons/quickmount/functions/fnc_canShowFreeSeats.sqf @@ -6,6 +6,7 @@ * Arguments: * 0: Vehicle * 1: Unit + * 2: Args * * Return Value: * Can show menu @@ -16,8 +17,9 @@ * Public: No */ -params ["_vehicle", "_unit"]; +params ["_vehicle", "_unit", "_args"]; +_args set [0, []]; private _isInVehicle = _unit in _vehicle; GVAR(enabled) @@ -36,4 +38,8 @@ GVAR(enabled) 0.3 < vectorUp _vehicle select 2 // moveIn* and GetIn* don't work for flipped vehicles || {_vehicle isKindOf "Air"} // except Air } -&& {!([] isEqualTo (_this call FUNC(addFreeSeatsActions)))} // this should be replaced with faster function +&& { + private _subActions = _this call FUNC(addFreeSeatsActions); + _args set [0, _subActions]; + !([] isEqualTo _subActions) +}