From 41e39c9c3a85b0e354a2157da759c6f8c20582f2 Mon Sep 17 00:00:00 2001 From: commy2 Date: Sat, 6 Feb 2016 11:58:31 +0100 Subject: [PATCH] replace more filter with select --- addons/common/functions/fnc_map.sqf | 2 +- addons/interaction/functions/fnc_passMagazine.sqf | 5 +---- addons/map/functions/fnc_blueForceTrackingUpdate.sqf | 10 +++++----- addons/map/functions/fnc_determineMapLight.sqf | 11 ++++++----- addons/reload/functions/fnc_canLinkBelt.sqf | 2 +- addons/reload/functions/fnc_startLinkingBelt.sqf | 2 +- .../functions/fnc_getLoadableMissiles.sqf | 2 +- addons/switchunits/functions/fnc_switchUnit.sqf | 2 +- .../weaponselect/functions/fnc_selectNextGrenade.sqf | 6 +++--- 9 files changed, 20 insertions(+), 22 deletions(-) diff --git a/addons/common/functions/fnc_map.sqf b/addons/common/functions/fnc_map.sqf index ab9e61cba7..c92a4eb588 100644 --- a/addons/common/functions/fnc_map.sqf +++ b/addons/common/functions/fnc_map.sqf @@ -17,7 +17,7 @@ params [["_array", [], [[]]], ["_code", {}, [{}]]]; -ACE_DEPRECATED("ace_common_fnc_filter","3.7.0","apply"); +ACE_DEPRECATED("ace_common_fnc_map","3.7.0","apply"); // copy array to not alter the original one _array = + _array; diff --git a/addons/interaction/functions/fnc_passMagazine.sqf b/addons/interaction/functions/fnc_passMagazine.sqf index 2afe2f3817..7e2f7b9356 100644 --- a/addons/interaction/functions/fnc_passMagazine.sqf +++ b/addons/interaction/functions/fnc_passMagazine.sqf @@ -21,10 +21,7 @@ params ["_player", "_target", "_weapon"]; private ["_compatibleMags", "_filteredMags", "_magToPass", "_magToPassIndex", "_playerName", "_magToPassDisplayName"]; _compatibleMags = getArray (configfile >> "CfgWeapons" >> _weapon >> "magazines"); -_filteredMags = [magazinesAmmoFull _player, { - params ["_className", "", "_loaded"]; - _className in _compatibleMags && !_loaded -}] call EFUNC(common,filter); +_filteredMags = magazinesAmmoFull _player select {(_x select 0) in _compatibleMags && {!(_x select 2)}}; //select magazine with most ammo _magToPass = _filteredMags select 0; diff --git a/addons/map/functions/fnc_blueForceTrackingUpdate.sqf b/addons/map/functions/fnc_blueForceTrackingUpdate.sqf index e9a619b5a4..bf2c413837 100644 --- a/addons/map/functions/fnc_blueForceTrackingUpdate.sqf +++ b/addons/map/functions/fnc_blueForceTrackingUpdate.sqf @@ -17,14 +17,14 @@ if (GVAR(BFT_Enabled) and {(!isNil "ACE_player") and {alive ACE_player}}) then { _playerSide = call EFUNC(common,playerSide); if !(GVAR(BFT_HideAiGroups)) then { - _groupsToDrawMarkers = [allGroups, {side _this == _playerSide}] call EFUNC(common,filter); + _groupsToDrawMarkers = allGroups select {side _x == _playerSide}; } else { - _groupsToDrawMarkers = [allGroups, { + _groupsToDrawMarkers = allGroups select { _anyPlayers = { [_x] call EFUNC(common,isPlayer); - } count units _this; - (side _this == _playerSide) && _anyPlayers > 0 - }] call EFUNC(common,filter); + } count units _x; + (side _x == _playerSide) && _anyPlayers > 0 + }; // @todo, simplify this }; { diff --git a/addons/map/functions/fnc_determineMapLight.sqf b/addons/map/functions/fnc_determineMapLight.sqf index 9712b84515..a844cdad07 100644 --- a/addons/map/functions/fnc_determineMapLight.sqf +++ b/addons/map/functions/fnc_determineMapLight.sqf @@ -95,11 +95,12 @@ TRACE_1("Player is on foot or in an open vehicle",""); // Using chemlights -_nearObjects = [_unit nearObjects ["SmokeShell", 4], { - alive _this && {(typeOf _this == "Chemlight_red") || { - (typeOf _this == "Chemlight_green") || { - (typeOf _this == "Chemlight_blue") || { - (typeOf _this == "Chemlight_yellow")}}}}}] call EFUNC(common,filter); +_nearObjects = (_unit nearObjects ["SmokeShell", 4]) select { + alive _x && {(typeOf _x == "Chemlight_red") || { + (typeOf _x == "Chemlight_green") || { + (typeOf _x == "Chemlight_blue") || { + (typeOf _x == "Chemlight_yellow")}}}}}; // @todo, simplify this + if (count (_nearObjects) > 0) then { _light = _nearObjects select 0; diff --git a/addons/reload/functions/fnc_canLinkBelt.sqf b/addons/reload/functions/fnc_canLinkBelt.sqf index b36959e4e1..13fad4d460 100644 --- a/addons/reload/functions/fnc_canLinkBelt.sqf +++ b/addons/reload/functions/fnc_canLinkBelt.sqf @@ -32,6 +32,6 @@ private _maxAmmo = 0; { _maxAmmo = _maxAmmo max (_x select 1); -} forEach ([magazinesAmmo _player, {_this select 0 == _magazineType}] call EFUNC(common,filter)); +} forEach (magazinesAmmo _player select {_x select 0 == _magazineType}); _maxAmmo > 0 diff --git a/addons/reload/functions/fnc_startLinkingBelt.sqf b/addons/reload/functions/fnc_startLinkingBelt.sqf index ebee6fd350..5924e1b4e1 100644 --- a/addons/reload/functions/fnc_startLinkingBelt.sqf +++ b/addons/reload/functions/fnc_startLinkingBelt.sqf @@ -32,7 +32,7 @@ private _maxAmmo = 0; { _maxAmmo = _maxAmmo max (_x select 1); -} forEach ([magazinesAmmo _player, {_this select 0 == _magazineType}] call EFUNC(common,filter)); +} forEach (magazinesAmmo _player select {_x select 0 == _magazineType}); if (_maxAmmo == 0) exitWith {}; diff --git a/addons/reloadlaunchers/functions/fnc_getLoadableMissiles.sqf b/addons/reloadlaunchers/functions/fnc_getLoadableMissiles.sqf index 9b083a04c6..ed1f11bdf3 100644 --- a/addons/reloadlaunchers/functions/fnc_getLoadableMissiles.sqf +++ b/addons/reloadlaunchers/functions/fnc_getLoadableMissiles.sqf @@ -25,4 +25,4 @@ _magazines = magazines _unit; _magazines = [_magazines, {toLower _this}] call EFUNC(common,map); // get reloaders magazine types compatible with targets launcher. No duplicates. -[getArray (configFile >> "CfgWeapons" >> _weapon >> "magazines"), {toLower _this in _magazines}] call EFUNC(common,filter) +getArray (configFile >> "CfgWeapons" >> _weapon >> "magazines") select {toLower _x in _magazines} // return diff --git a/addons/switchunits/functions/fnc_switchUnit.sqf b/addons/switchunits/functions/fnc_switchUnit.sqf index 903207652c..a26b2d474a 100644 --- a/addons/switchunits/functions/fnc_switchUnit.sqf +++ b/addons/switchunits/functions/fnc_switchUnit.sqf @@ -25,7 +25,7 @@ private _leave = false; if (GVAR(EnableSafeZone)) then { private _allNearestPlayers = [position _unit, GVAR(SafeZoneRadius)] call FUNC(nearestPlayers); - private _nearestEnemyPlayers = [_allNearestPlayers, {((side GVAR(OriginalGroup)) getFriend (side _this) < 0.6) && !(_this getVariable [QGVAR(IsPlayerControlled), false])}] call EFUNC(common,filter); + private _nearestEnemyPlayers = _allNearestPlayers select {((side GVAR(OriginalGroup)) getFriend side _x < 0.6) && !(_x getVariable [QGVAR(IsPlayerControlled), false])}; if (count _nearestEnemyPlayers > 0) exitWith { _leave = true; diff --git a/addons/weaponselect/functions/fnc_selectNextGrenade.sqf b/addons/weaponselect/functions/fnc_selectNextGrenade.sqf index a4e93814a9..f4b48a1b1e 100644 --- a/addons/weaponselect/functions/fnc_selectNextGrenade.sqf +++ b/addons/weaponselect/functions/fnc_selectNextGrenade.sqf @@ -57,9 +57,9 @@ private _nextGrenade = _grenades select _nextGrenadeIndex; if (_currentGrenade == _nextGrenade) exitWith {false}; // current best method to select a grenade: remove all grenades except the one you want to select, then add them back -private _uniformGrenades = [uniformItems _unit, {_x in GVAR(GrenadesAll) && {_x != _nextGrenade}}] call EFUNC(common,filter); -private _vestGrenades = [vestItems _unit, {_x in GVAR(GrenadesAll) && {_x != _nextGrenade}}] call EFUNC(common,filter); -private _backpackGrenades = [backpackItems _unit, {_x in GVAR(GrenadesAll) && {_x != _nextGrenade}}] call EFUNC(common,filter); +private _uniformGrenades = uniformItems _unit select {_x in GVAR(GrenadesAll) && {_x != _nextGrenade}}; +private _vestGrenades = vestItems _unit select {_x in GVAR(GrenadesAll) && {_x != _nextGrenade}}; +private _backpackGrenades = backpackItems _unit select {_x in GVAR(GrenadesAll) && {_x != _nextGrenade}}; // remove all grenades except those we are switching to --> this breaks the selector {_unit removeItemFromUniform _x; false} count _uniformGrenades;