Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

General - Change count to forEach where appropriate #9890

Merged
merged 2 commits into from
Apr 4, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions addons/advanced_throwing/XEH_postInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@ GVAR(ammoMagLookup) = call CBA_fnc_createNamespace;
{
private _ammo = getText (configFile >> "CfgMagazines" >> _x >> "ammo");
if (_ammo != "") then { GVAR(ammoMagLookup) setVariable [_ammo, _x]; };
} count (getArray (configFile >> "CfgWeapons" >> "Throw" >> _x >> "magazines"));
nil
} count getArray (configFile >> "CfgWeapons" >> "Throw" >> "muzzles");
} forEach (getArray (configFile >> "CfgWeapons" >> "Throw" >> _x >> "magazines"));
} forEach getArray (configFile >> "CfgWeapons" >> "Throw" >> "muzzles");


// Add keybinds
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@
_addedPickUpHelpers pushBack _pickUpHelper;
_throwablesHelped pushBack _x;
};
nil
} count _nearThrowables;
} forEach _nearThrowables;

_args set [0, getPosASL ACE_player];
_args set [3, _nearThrowables];
Expand All @@ -56,11 +55,10 @@
{
// Only handling with attachTo works nicely
_x attachTo [_x getVariable [QGVAR(throwable), objNull], [0, 0, 0]];
nil
} count _addedPickUpHelpers;
} forEach _addedPickUpHelpers;
} else {
TRACE_1("Cleaning Pick Up Helpers",count _addedPickUpHelpers);
{deleteVehicle _x} count _addedPickUpHelpers;
{deleteVehicle _x} forEach _addedPickUpHelpers;
[_idPFH] call CBA_fnc_removePerFrameHandler;
};
}, 0, [(getPosASL ACE_player) vectorAdd [-100, 0, 0], [], [], []]] call CBA_fnc_addPerFrameHandler;
2 changes: 1 addition & 1 deletion addons/aircraft/functions/fnc_canShowEject.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@ _vehicle == vehicle _unit
if (_unit == _x select FULLCREW_UNIT) exitWith {
_ejectVarName = format [QGVAR(ejectAction_%1_%2), _x select FULLCREW_ROLE, _x select FULLCREW_TURRETPATH];
};
} count fullCrew _vehicle;
} forEach fullCrew _vehicle;
_vehicle getVariable [_ejectVarName, false]
}
3 changes: 1 addition & 2 deletions addons/common/XEH_postInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,7 @@ if (isServer) then {
INFO_3("[%1] DC - Was Zeus [%2] while controlling unit [%3] - manually clearing `bis_fnc_moduleRemoteControl_owner`",[_x] call FUNC(getName),_dcPlayer,_x);
_x setVariable ["bis_fnc_moduleRemoteControl_owner", nil, true];
};
nil
} count (curatorEditableObjects _zeusLogic);
} forEach (curatorEditableObjects _zeusLogic);
};
}];
};
Expand Down
3 changes: 1 addition & 2 deletions addons/common/functions/fnc__handleRequestSyncedEvent.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ if (isServer) then {
{
_x params ["", "_eventArgs","_ttl"];
[_eventName, _eventArgs, _ttl] call FUNC(_handleSyncedEvent);
false
} count _eventLog;
} forEach _eventLog;

INFO_1("[%1] synchronized",_eventName);
};
Expand Down
21 changes: 8 additions & 13 deletions addons/common/functions/fnc_assignObjectsInList.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,13 @@ if (_list isEqualType "") then {
};

{
if (!isNil "_x") then {
if (_x isEqualType objNull) then {
if (local _x) then {
if (_vehicle) then {
(vehicle _x) setVariable [_variable, _setting, _global];
TRACE_6("Set variable vehicle",_x,vehicle _x,typeOf (vehicle _x),_variable,_setting,_global);
} else {
_x setVariable [_variable, _setting, _global];
TRACE_5("Set variable",_x,typeOf _x,_variable,_setting,_global);
};
};
if (!isNil "_x" && {_x isEqualType objNull} && {local _x}) then {
if (_vehicle) then {
(vehicle _x) setVariable [_variable, _setting, _global];
TRACE_6("Set variable vehicle",_x,vehicle _x,typeOf (vehicle _x),_variable,_setting,_global);
} else {
_x setVariable [_variable, _setting, _global];
TRACE_5("Set variable",_x,typeOf _x,_variable,_setting,_global);
};
};
false
} count _list;
} forEach _list;
3 changes: 1 addition & 2 deletions addons/common/functions/fnc_cbaSettings.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,7 @@ GVAR(settingsMovedToSQF) = [];
INFO_1("%1 delayed functions running.",count GVAR(runAtSettingsInitialized));
{
(_x select 1) call (_x select 0);
false
} count GVAR(runAtSettingsInitialized);
} forEach GVAR(runAtSettingsInitialized);
GVAR(runAtSettingsInitialized) = nil; //cleanup

#ifdef DEBUG_MODE_FULL
Expand Down
7 changes: 2 additions & 5 deletions addons/common/functions/fnc_displayIcon.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@ private _refresh = {

{
ctrlDelete _x;
false
} count _allControls;
} forEach _allControls;

_allControls = [];

Expand All @@ -80,7 +79,6 @@ private _refresh = {
_ctrl ctrlSetTextColor _xcolor;
_ctrl ctrlCommit 0;
_allControls pushBack _ctrl;
false
} forEach (missionNamespace getVariable [QGVAR(displayIconList),[]]);
};

Expand Down Expand Up @@ -116,8 +114,7 @@ if (_show) then {
if (_x select 0 != _iconId) then {
_newList pushBack _x;
};
false
} count _list;
} forEach _list;

missionNamespace setVariable [QGVAR(displayIconList), _newList];
call _refresh;
Expand Down
3 changes: 1 addition & 2 deletions addons/common/functions/fnc_dumpArray.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ if (IS_ARRAY(_var)) then {

{
[_x, _depth] call FUNC(dumpArray);
false
} count _var;
} forEach _var;

diag_log text format ["%1],", _pad];
};
Expand Down
9 changes: 3 additions & 6 deletions addons/common/functions/fnc_dumpPerformanceCounters.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ if (!isNil "ACE_PFH_COUNTER") then {
private _isActive = ["ACTIVE", "REMOVED"] select isNil {CBA_common_PFHhandles select (_pfh select 0)};

diag_log text format ["Registered PFH: id=%1 [%2, delay %3], %4:%5", _pfh select 0, _isActive, _parameters select 1, _pfh select 1, _pfh select 2];
false
} count ACE_PFH_COUNTER;
} forEach ACE_PFH_COUNTER;
};

diag_log text format ["ACE COUNTER RESULTS"];
Expand All @@ -50,8 +49,7 @@ diag_log text format ["-------------------------------------------"];
};

_iter = _iter + 1;
false
} count _counterEntry;
} forEach _counterEntry;

// results
_averageResult = (_total / _count) * 1000;
Expand All @@ -61,8 +59,7 @@ diag_log text format ["-------------------------------------------"];
} else {
diag_log text format ["%1: No results", _counterEntry select 0];
};
false
} count ACE_COUNTERS;
} forEach ACE_COUNTERS;

/*
// Dump PFH Trackers
Expand Down
3 changes: 1 addition & 2 deletions addons/common/functions/fnc_firedEH.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@ if (_unit isKindOf "CAManBase") then {
_gunner = _unit turretUnit _x;
_turret = _x;
};
false
} count allTurrets [_unit, true];
} forEach allTurrets [_unit, true];
// Ensure that at least the pilot is returned if there is no gunner
if (isManualFire _unit && {isNull _gunner}) then {
_gunner = effectiveCommander _unit;
Expand Down
3 changes: 1 addition & 2 deletions addons/common/functions/fnc_getAllDefinedSetVariables.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ private _return = [];
_return pushBack [_x select 0, typeName _val, _val, _x select 2, _x select 5];
};
};
false
} count GVAR(OBJECT_VARIABLES_STORAGE);
} forEach GVAR(OBJECT_VARIABLES_STORAGE);

_return
3 changes: 1 addition & 2 deletions addons/common/functions/fnc_getDoorTurrets.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ private _doorTurrets = [];
if (((getNumber (_config >> "isCopilot")) == 0) && {count getArray (_config >> "weapons") > 0}) then {
_doorTurrets pushBack _x;
};
false
} count _turrets;
} forEach _turrets;

_doorTurrets
3 changes: 1 addition & 2 deletions addons/common/functions/fnc_getGunner.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ private _gunner = objNull;
if (_weapon in (_vehicle weaponsTurret _x)) exitWith {
_gunner = _vehicle turretUnit _x;
};
false
} count allTurrets [_vehicle, true];
} forEach allTurrets [_vehicle, true];

// ensure that at least the pilot is returned if there is no gunner
if (isManualFire _vehicle && {isNull _gunner}) then {
Expand Down
3 changes: 1 addition & 2 deletions addons/common/functions/fnc_getInPosition.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ private _enemiesInVehicle = false; //Possible Side Restriction

{
if (side _unit getFriend side _x < 0.6) exitWith {_enemiesInVehicle = true};
false
} count crew _vehicle;
} forEach crew _vehicle;

switch (_position) do {
case "driver" : {
Expand Down
3 changes: 1 addition & 2 deletions addons/common/functions/fnc_getMapGridData.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ private _stepY = 1e10;
_stepX = getNumber (_x >> "stepX");
_stepY = getNumber (_x >> "stepY");
};
false
} count configProperties [_cfgGrid, "isClass _x", false];
} forEach configProperties [_cfgGrid, "isClass _x", false];

private _letterGrid = false;

Expand Down
3 changes: 1 addition & 2 deletions addons/common/functions/fnc_getNumberMagazinesIn.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ if (_unit isKindOf "CAManBase") then {
} else {
{
_return = _return + ({_x == _magazine} count magazines _x);
false
} count crew _unit;
} forEach crew _unit;

(getMagazineCargo _unit) params [["_magNames", []], ["_magCount", []]];
{
Expand Down
3 changes: 1 addition & 2 deletions addons/common/functions/fnc_getTurretIndex.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ scopeName "main";

{
if (_unit == (_vehicle turretUnit _x)) then {_x breakOut "main"};
nil
} count allTurrets [_vehicle, true];
} forEach allTurrets [_vehicle, true];

[]
3 changes: 1 addition & 2 deletions addons/common/functions/fnc_getVehicleCrew.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ private _crew = [];
_crew pushBack (_x select 0);
};
};
false
} count fullCrew _vehicle;
} forEach fullCrew _vehicle;

_crew
3 changes: 1 addition & 2 deletions addons/common/functions/fnc_getWeaponModes.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ private _modes = [];
if (_x == "this") then {
_modes pushBack _weapon;
};
false
} count getArray (_config >> "modes");
} forEach getArray (_config >> "modes");

_modes
3 changes: 1 addition & 2 deletions addons/common/functions/fnc_getWeaponState.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ private _ammo = _muzzles apply {0};
_ammo set [_index, _x select 1];
};
};
false
} count magazinesAmmoFull _unit;
} forEach magazinesAmmoFull _unit;

[_attachments, _muzzles, _magazines, _ammo];
6 changes: 2 additions & 4 deletions addons/common/functions/fnc_moduleLSDVehicles.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ if (isNil QGVAR(LSD_Vehicles)) then {
if (_hSCount > 0) then {
GVAR(LSD_Vehicles) pushBack [_x, _hSCount];
};
nil
} count _units;
} forEach _units;

if (isNil QGVAR(LSD_Colors)) then {
GVAR(LSD_Colors) = [
Expand All @@ -51,8 +50,7 @@ if (isNil QGVAR(LSD_PFH)) then {
for "_i" from 0 to (_hSCount - 1) do {
_vehicle setObjectTexture [_i, GVAR(LSD_Colors) select _index];
};
nil
} count GVAR(LSD_Vehicles);
} forEach GVAR(LSD_Vehicles);

_index = ((_index + 1) % 7) mod count GVAR(LSD_Colors);
(_this select 0) set [0, _index];
Expand Down
6 changes: 2 additions & 4 deletions addons/common/functions/fnc_parseList.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ private _whitespaceList = [];
} else {
_whitespaceList pushBack ([_x] call CBA_fnc_trim);
};
false
} count _list;
} forEach _list;

_list = _whitespaceList;
TRACE_1("Whitespace List",_list);
Expand All @@ -46,8 +45,7 @@ if (_checkNil) then {
if (!isNil _x) then {
_nilCheckedList pushBack (missionNamespace getVariable _x);
};
false
} count _list;
} forEach _list;

_list = _nilCheckedList;
};
Expand Down
6 changes: 2 additions & 4 deletions addons/common/functions/fnc_resetAllDefaults.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,12 @@ if (isPlayer _unit) then {
// clear all disable user input
{
[_x, false] call FUNC(setDisableUserInputStatus);
false
} count GVAR(DISABLE_USER_INPUT_COLLECTION);
} forEach GVAR(DISABLE_USER_INPUT_COLLECTION);
};
};

{
if !(_x select 4) then {
_unit setVariable [_x select 0, nil, _x select 3];
};
false
} count ([_unit] call FUNC(getAllDefinedSetVariables));
} forEach ([_unit] call FUNC(getAllDefinedSetVariables));
4 changes: 1 addition & 3 deletions addons/common/functions/fnc_restoreVariablesJIP.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,4 @@ _respawnVariables pushBack "ACE_PersistentFunctions";

{
_unit setVariable [_x, _unit getVariable _x, true];
false
} count _respawnVariables;
nil
} forEach _respawnVariables;
3 changes: 1 addition & 2 deletions addons/common/functions/fnc_sanitizeString.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ private _array = [];
_array pushBack _x;
};
};
false
} count toArray _string;
} forEach toArray _string;

toString _array // return
3 changes: 1 addition & 2 deletions addons/common/functions/fnc_throttledPublicVariable.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ if (isNil QGVAR(publishSchedId)) then {
{
_x params ["_unit", "_varName"];
_unit setVariable [_varName, _unit getVariable _varName, true];
false
} count GVAR(publishVarNames);
} forEach GVAR(publishVarNames);

GVAR(publishVarNames) = [];
GVAR(publishNextTime) = 1e7;
Expand Down
6 changes: 3 additions & 3 deletions addons/concertina_wire/functions/fnc_deploy.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ params ["_wirecoil", "_unit"];
private _wireNoGeo = "ACE_ConcertinaWireNoGeo" createVehicle [0,0,0];
{
_wireNoGeo animate [_x, 1];
} count WIRE_FAST;
} forEach WIRE_FAST;

GVAR(placer) = _unit;
private _dir = getDir _unit;
Expand Down Expand Up @@ -51,7 +51,7 @@ GVAR(deployPFH) = [{
private _wire = "ACE_ConcertinaWire" createvehicle [0, 0, 0];
{
_wire animate [_x, _anim];
} count WIRE_FAST;
} forEach WIRE_FAST;

[{
params ["_args", "_idPFH"];
Expand All @@ -74,7 +74,7 @@ GVAR(deployPFH) = [{
_wireNoGeo setDir _dir;
{
_wireNoGeo animate [_x, _anim];
} count WIRE_FAST;
} forEach WIRE_FAST;
}, 0, [_wireNoGeo, _wireNoGeoPos, _unit]] call CBA_fnc_addPerFrameHandler;

[LLSTRING(RollWire), "", ""] call EFUNC(interaction,showMouseHint);
Expand Down
2 changes: 1 addition & 1 deletion addons/concertina_wire/functions/fnc_dismountSuccess.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ params ["_wire"];

{
_wire animate [_x, 1];
} count WIRE_FAST;
} forEach WIRE_FAST;

[{
params ["_args", "_idPFH"];
Expand Down
Loading