replace filter and map with select and apply

This commit is contained in:
commy2 2016-02-06 11:42:35 +01:00
parent 0032e7aa9a
commit 2ebd2f9046
7 changed files with 18 additions and 16 deletions

View File

@ -16,7 +16,7 @@
params ["_unit", "_target", ["_exceptions", []]];
_exceptions = [_exceptions, {toLower _this}] call FUNC(map);
_exceptions = _exceptions apply {toLower _x};
private _owner = _target getVariable [QGVAR(owner), objNull];

View File

@ -21,8 +21,8 @@ ACE_LOGINFO_1("ACE is version %1.",_version);
//private _addons = activatedAddons; // broken with High-Command module, see #2134
private _addons = "true" configClasses (configFile >> "CfgPatches");//
_addons = [_addons, {toLower configName _this}] call FUNC(map);//
_addons = [_addons, {_this find "ace_" == 0}] call FUNC(filter);
_addons = _addons apply {toLower configName _x};//
_addons = _addons select {_x find "ace_" == 0};
{
if (getText (configFile >> "CfgPatches" >> _x >> "versionStr") != _version) then {
@ -63,7 +63,7 @@ _addons = [_addons, {_this find "ace_" == 0}] call FUNC(filter);
///////////////
if (isMultiplayer) then {
// don't check optional addons
_addons = [_addons, {getNumber (configFile >> "CfgPatches" >> _this >> "ACE_isOptional") != 1}] call FUNC(filter);
_addons = _addons select {getNumber (configFile >> "CfgPatches" >> _x >> "ACE_isOptional") != 1};
if (isServer) then {
// send servers version of ACE to all clients

View File

@ -9,15 +9,16 @@
* Return Value:
* Final array
*
* Usage:
* [[0,1,2,3,4], {_this > 2}] call FUNC(filter) ==> [3,4]
*
* Public: Yes
*
* Deprecated
*/
#include "script_component.hpp"
params [["_array", [], [[]]], ["_code", {}, [{}]]];
ACE_DEPRECATED("ace_common_fnc_filter","3.7.0","select CODE");
private _result = [];
{

View File

@ -16,4 +16,4 @@ params ["_name", "_cfgClass"];
private _classes = format ["configName inheritsFrom _x == '%1'", _name] configClasses (configFile >> _cfgClass);
[_classes, {configName _this}] call FUNC(map) // return
_classes apply {configName _x} // return

View File

@ -14,4 +14,4 @@
params [["_vehicle", objNull, [objNull]]];
[crew _vehicle, {getText (configFile >> "CfgVehicles" >> typeOf _this >> "simulation") == "UAVPilot"}] call FUNC(filter) // return
crew _vehicle select {getText (configFile >> "CfgVehicles" >> typeOf _x >> "simulation") == "UAVPilot"} // return

View File

@ -1,6 +1,6 @@
/*
* Author: KoffeinFlummi, commy2
* Applies given code to every element in an array, LIKE SOMETHING SQF SHOULD HAVE BY DEFAULT.
* Applies given code to every element in an array, LIKE SOMETHING SQF SHOULD HAVE BY DEFAULT. <- :kappa:
*
* Arguments:
* 0: Array to be thingied.
@ -9,15 +9,16 @@
* Return Value:
* Final array
*
* Usage:
* [["2", "gobblecock", "25"], {parseNumber _this}] call FUNC(map) ==> [2, 0, 25]
*
* Public: Yes
*
* Deprecated
*/
#include "script_component.hpp"
params [["_array", [], [[]]], ["_code", {}, [{}]]];
ACE_DEPRECATED("ace_common_fnc_filter","3.7.0","apply");
// copy array to not alter the original one
_array = + _array;

View File

@ -19,7 +19,7 @@ params [["_unit", objNull, [objNull]], ["_magazineType", "", [""]], ["_ammoCount
private _isRemoved = false;
// Check uniform
private _magazines = [magazinesAmmoCargo uniformContainer _unit, {_this select 0 == _magazineType}] call FUNC(filter);
private _magazines = magazinesAmmoCargo uniformContainer _unit select {_x select 0 == _magazineType};
private _index = _magazines find [_magazineType, _ammoCount];
if (_index > -1) exitWith {
@ -39,7 +39,7 @@ if (_index > -1) exitWith {
};
// Check vest
_magazines = [magazinesAmmoCargo vestContainer _unit, {_this select 0 == _magazineType}] call FUNC(filter);
_magazines = magazinesAmmoCargo vestContainer _unit select {_x select 0 == _magazineType};
_index = _magazines find [_magazineType, _ammoCount];
if (_index > -1) exitWith {
@ -59,7 +59,7 @@ if (_index > -1) exitWith {
};
// Check backpack
_magazines = [magazinesAmmoCargo backpackContainer _unit, {_this select 0 == _magazineType}] call FUNC(filter);
_magazines = magazinesAmmoCargo backpackContainer _unit select {_x select 0 == _magazineType};
_index = _magazines find [_magazineType, _ammoCount];
if (_index > -1) exitWith {