Replace count w/ forEach

This commit is contained in:
eraser1 2015-09-04 11:35:19 -05:00
parent 6e627cf355
commit ea28d73468
21 changed files with 42 additions and 84 deletions

View File

@ -123,8 +123,7 @@ if !(_added) exitWith
_cleanup = []; _cleanup = [];
{ {
_cleanup pushBack _x; _cleanup pushBack _x;
false; } forEach _missionAIUnits;
} count _missionAIUnits;
_cleanup pushBack ((_missionObjs select 0)+(_missionObjs select 1)); _cleanup pushBack ((_missionObjs select 0)+(_missionObjs select 1));
@ -132,7 +131,7 @@ if !(_added) exitWith
// Delete the markers directly // Delete the markers directly
{deleteMarker _x;false;} count _markers; {deleteMarker _x;} forEach _markers;
// Reset the mission count // Reset the mission count

View File

@ -122,8 +122,7 @@ if !(_added) exitWith
_cleanup = []; _cleanup = [];
{ {
_cleanup pushBack _x; _cleanup pushBack _x;
false; } forEach _missionAIUnits;
} count _missionAIUnits;
_cleanup pushBack ((_missionObjs select 0)+(_missionObjs select 1)); _cleanup pushBack ((_missionObjs select 0)+(_missionObjs select 1));
@ -131,7 +130,7 @@ if !(_added) exitWith
// Delete the markers directly // Delete the markers directly
{deleteMarker _x;false;} count _markers; {deleteMarker _x;} forEach _markers;
// Reset the mission count // Reset the mission count

View File

@ -121,8 +121,7 @@ if !(_added) exitWith
_cleanup = []; _cleanup = [];
{ {
_cleanup pushBack _x; _cleanup pushBack _x;
false; } forEach _missionAIUnits;
} count _missionAIUnits;
_cleanup pushBack ((_missionObjs select 0)+(_missionObjs select 1)); _cleanup pushBack ((_missionObjs select 0)+(_missionObjs select 1));
@ -130,7 +129,7 @@ if !(_added) exitWith
// Delete the markers directly // Delete the markers directly
{deleteMarker _x;false;} count _markers; {deleteMarker _x;} forEach _markers;
// Reset the mission count // Reset the mission count

View File

@ -118,8 +118,7 @@ if !(_added) exitWith
_cleanup = []; _cleanup = [];
{ {
_cleanup pushBack _x; _cleanup pushBack _x;
false; } forEach _missionAIUnits;
} count _missionAIUnits;
_cleanup pushBack ((_missionObjs select 0)+(_missionObjs select 1)); _cleanup pushBack ((_missionObjs select 0)+(_missionObjs select 1));
@ -127,7 +126,7 @@ if !(_added) exitWith
// Delete the markers directly // Delete the markers directly
{deleteMarker _x;false;} count _markers; {deleteMarker _x;} forEach _markers;
// Reset the mission count // Reset the mission count

View File

@ -118,8 +118,7 @@ if !(_added) exitWith
_cleanup = []; _cleanup = [];
{ {
_cleanup pushBack _x; _cleanup pushBack _x;
false; } forEach _missionAIUnits;
} count _missionAIUnits;
_cleanup pushBack ((_missionObjs select 0)+(_missionObjs select 1)); _cleanup pushBack ((_missionObjs select 0)+(_missionObjs select 1));
@ -127,7 +126,7 @@ if !(_added) exitWith
// Delete the markers directly // Delete the markers directly
{deleteMarker _x;false;} count _markers; {deleteMarker _x;} forEach _markers;
// Reset the mission count // Reset the mission count

View File

@ -118,8 +118,7 @@ if !(_added) exitWith
_cleanup = []; _cleanup = [];
{ {
_cleanup pushBack _x; _cleanup pushBack _x;
false; } forEach _missionAIUnits;
} count _missionAIUnits;
_cleanup pushBack ((_missionObjs select 0)+(_missionObjs select 1)); _cleanup pushBack ((_missionObjs select 0)+(_missionObjs select 1));
@ -127,7 +126,7 @@ if !(_added) exitWith
// Delete the markers directly // Delete the markers directly
{deleteMarker _x;false;} count _markers; {deleteMarker _x;} forEach _markers;
// Reset the mission count // Reset the mission count

View File

@ -27,5 +27,4 @@ DMS_MissionTypesArray = [];
for "_i" from 1 to (_x select 1) do { for "_i" from 1 to (_x select 1) do {
DMS_MissionTypesArray pushBack (_x select 0); DMS_MissionTypesArray pushBack (_x select 0);
}; };
false; } forEach DMS_MissionTypes;
} count DMS_MissionTypes;

View File

@ -126,8 +126,7 @@ if !(_added) exitWith
_cleanup = []; _cleanup = [];
{ {
_cleanup pushBack _x; _cleanup pushBack _x;
false; } forEach _missionAIUnits;
} count _missionAIUnits;
_cleanup pushBack ((_missionObjs select 0)+(_missionObjs select 1)); _cleanup pushBack ((_missionObjs select 0)+(_missionObjs select 1));
@ -135,7 +134,7 @@ if !(_added) exitWith
// Delete the markers directly // Delete the markers directly
{deleteMarker _x;false;} count _markers; {deleteMarker _x;} forEach _markers;
// Reset the mission count // Reset the mission count

View File

@ -30,9 +30,7 @@ if !(DMS_ai_offload_to_client) exitWith {};
{ {
_owner = _x; _owner = _x;
}; };
} forEach allPlayers;
false;
} count allPlayers;
if ((isNull _owner) || {(_owner distance2D _leader)>3500}) then if ((isNull _owner) || {(_owner distance2D _leader)>3500}) then
{ {
@ -49,5 +47,4 @@ if !(DMS_ai_offload_to_client) exitWith {};
}; };
}; };
}; };
false; } forEach allGroups;
} count allGroups;

View File

@ -97,12 +97,10 @@ try
{ {
{ {
_units pushBack _x; _units pushBack _x;
false; } forEach (units _x);
} count (units _x);
}; };
}; };
false; } forEach _inputUnits;
} count _inputUnits;
_OK = _missionObjs params _OK = _missionObjs params
[ [

View File

@ -31,5 +31,4 @@ if ((typeName _this) != "STRING") then
] select (_x == "dynamicTextRequest"); ] select (_x == "dynamicTextRequest");
_args call ExileServer_system_network_send_broadcast; _args call ExileServer_system_network_send_broadcast;
false; } forEach DMS_PlayerNotificationTypes;
} count DMS_PlayerNotificationTypes;

View File

@ -29,14 +29,6 @@ if !((typeName _this) == "ARRAY") then
_this = [_this]; _this = [_this];
}; };
/*
if ([_this,20] call DMS_isPlayerNearbyARRAY) exitWith //<-----Not sure if it's more/less efficient
{
[30, DMS_CleanUp, _this, false] call ExileServer_system_thread_addTask;
};
*/
private ["_skippedObjects","_clean"]; private ["_skippedObjects","_clean"];
_skippedObjects = []; _skippedObjects = [];
@ -85,8 +77,7 @@ _clean =
// Group cleanup should only be called when it has to be deleted regardless, so no need to check for nearby players // Group cleanup should only be called when it has to be deleted regardless, so no need to check for nearby players
{ {
_x call _clean; _x call _clean;
false; } forEach (units _x);
} count (units _x);
if(local _x)then if(local _x)then
{ {
@ -108,9 +99,7 @@ _clean =
}; };
diag_log format ["DMS ERROR :: Attempted to call DMS_CleanUp on non- group or object %1 from array %2",_x,_this]; diag_log format ["DMS ERROR :: Attempted to call DMS_CleanUp on non- group or object %1 from array %2",_x,_this];
}; };
} forEach _this;
false;
} count _this;
if !(_skippedObjects isEqualTo []) then if !(_skippedObjects isEqualTo []) then

View File

@ -50,6 +50,4 @@ if (DMS_CleanUpList isEqualTo []) exitWith {}; // Empty array, no objects to cl
diag_log format ["DMS_DEBUG CleanUpManager :: %1 is not yet ready to clean!",_x]; diag_log format ["DMS_DEBUG CleanUpManager :: %1 is not yet ready to clean!",_x];
}; };
}; };
} forEach DMS_CleanUpList;
false;
} count DMS_CleanUpList;

View File

@ -58,7 +58,6 @@ _success = true;
_success = _completionArgs call ExileServer_util_position_isPlayerNearby; _success = _completionArgs call ExileServer_util_position_isPlayerNearby;
}; };
}; };
false; } forEach _this;
} count _this;
_success; _success;

View File

@ -113,5 +113,4 @@ _index = 0;
}; };
}; };
_index = _index + 1; _index = _index + 1;
false; } forEach DMS_Mission_Arr;
} count DMS_Mission_Arr;

View File

@ -40,7 +40,7 @@ if (isPlayer _player) then
if (((position _x) distance (position _unit)) <= DMS_ai_share_info_distance ) then { if (((position _x) distance (position _unit)) <= DMS_ai_share_info_distance ) then {
_x reveal [_player, 4.0]; _x reveal [_player, 4.0];
}; };
} count allUnits; } forEach allUnits;
}; };
} }
else else
@ -75,8 +75,7 @@ if(DMS_ai_remove_launchers && {_launcher != ""}) then
if(_x == _rockets) then { if(_x == _rockets) then {
_unit removeMagazine _x; _unit removeMagazine _x;
}; };
false; } forEach magazines _unit;
} count magazines _unit;
}; };
if(DMS_RemoveNVG) then if(DMS_RemoveNVG) then

View File

@ -43,8 +43,7 @@ _client = objNull;
{ {
_client = _x; _client = _x;
}; };
false; } forEach allPlayers;
} count allPlayers;
if (!isNull _client) then{ if (!isNull _client) then{
ExileServerOwnershipSwapQueue pushBack [_AI,_client]; ExileServerOwnershipSwapQueue pushBack [_AI,_client];

View File

@ -79,7 +79,7 @@ removeGoggles _unit;
// Give default items // Give default items
if !(DMS_ai_default_items isEqualTo []) then if !(DMS_ai_default_items isEqualTo []) then
{ {
{_unit linkItem _x;false;} count DMS_ai_default_items; {_unit linkItem _x;} forEach DMS_ai_default_items;
}; };
@ -100,10 +100,10 @@ if (!_useCustomGear) then
};// No more idiot-proofing for the following configs };// No more idiot-proofing for the following configs
// Equipment (Stuff that goes in the toolbelt slots) // Equipment (Stuff that goes in the toolbelt slots)
{_unit linkItem _x;false;} count (missionNamespace getVariable [format ["DMS_%1_equipment",_type],[]]); {_unit linkItem _x;} forEach (missionNamespace getVariable [format ["DMS_%1_equipment",_type],[]]);
// Items (Loot stuff that goes in uniform/vest/backpack) // Items (Loot stuff that goes in uniform/vest/backpack)
{_unit addItem _x;false;} count (missionNamespace getVariable [format ["DMS_%1_items",_type],[]]); {_unit addItem _x;} forEach (missionNamespace getVariable [format ["DMS_%1_items",_type],[]]);
// Clothes // Clothes
@ -228,8 +228,7 @@ else
_x = [_x,1]; _x = [_x,1];
}; };
_unit addMagazines _x; _unit addMagazines _x;
false; } forEach _magazines;
} count _magazines;
// Add gun and attachments // Add gun and attachments
@ -239,8 +238,7 @@ else
{ {
_unit addPrimaryWeaponItem _x; _unit addPrimaryWeaponItem _x;
false; } forEach _weaponAttachments;
} count _weaponAttachments;
_unit selectWeapon _weapon; _unit selectWeapon _weapon;
}; };
@ -253,25 +251,22 @@ else
{ {
_unit addPrimaryWeaponItem _x; _unit addPrimaryWeaponItem _x;
false; } forEach _pistolAttachments;
} count _pistolAttachments;
}; };
// Add items // Add items
{ {
_unit addItem _x; _unit addItem _x;
false; } forEach _items;
} count _items;
}; };
{ {
_unit setSkill [(_x select 0),(_x select 1)]; _unit setSkill [(_x select 0),(_x select 1)];
false; } forEach (missionNamespace getVariable [format["DMS_ai_skill_%1",_difficulty],[]]);
} count (missionNamespace getVariable [format["DMS_ai_skill_%1",_difficulty],[]]);
// Soldier killed event handler // Soldier killed event handler
_unit addMPEventHandler ["MPKilled",'[_this, '+str _side+', "soldier"] call DMS_OnKilled;']; _unit addMPEventHandler ["MPKilled",'if (isServer) then {[_this, '+str _side+', "soldier"] call DMS_OnKilled;};'];
_unit enableAI "TARGET"; _unit enableAI "TARGET";
_unit enableAI "AUTOTARGET"; _unit enableAI "AUTOTARGET";

View File

@ -44,12 +44,9 @@ try
{ {
throw _x; throw _x;
}; };
false; } forEach (units _x);
} count (units _x);
}; };
} forEach _this;
false;
} count _this;
_killed = true; _killed = true;
} }

View File

@ -61,8 +61,7 @@ while{!_validspot} do {
{ {
throw ("another mission"); throw ("another mission");
}; };
false; } forEach allMapMarkers;
} count allMapMarkers;
// No exceptions found // No exceptions found
_validspot = true; _validspot = true;

View File

@ -38,9 +38,7 @@ _result = false;
diag_log format["DMS_DEBUG IsPlayerNearbyARRAY :: %1 is within %2m of %3!",_plyr,_radius,_x]; diag_log format["DMS_DEBUG IsPlayerNearbyARRAY :: %1 is within %2m of %3!",_plyr,_radius,_x];
}; };
}; };
false; } forEach _posArray;
} count _posArray;
}; };
false; } forEach allPlayers;
} count allPlayers;
_result _result