Replace forEach with Count

Use count where you do not need _forEachIndex variable, it's quicker
than forEach.
This commit is contained in:
icomrade
2014-05-27 15:37:57 -04:00
parent 91d246e64e
commit e54b9983dd
210 changed files with 890 additions and 890 deletions

View File

@@ -10,7 +10,7 @@ if(isNull(_object)) exitWith {
};
_type = _this select 1;
_parachuteWest = ((typeOf _object == "ParachuteWest") or (typeOf _object == "ParachuteC"));
_parachuteWest = ((typeOf _object == "ParachuteWest") || (typeOf _object == "ParachuteC"));
_isbuildable = (typeOf _object) in dayz_allowedObjects;
_isNotOk = false;
_firstTime = false;
@@ -25,7 +25,7 @@ if ((typeName _objectID != "string") || (typeName _uid != "string")) then
_objectID = "0";
_uid = "0";
};
if (!_parachuteWest and !(locked _object)) then {
if (!_parachuteWest && !(locked _object)) then {
if (_objectID == "0" && _uid == "0") then
{
_object_position = getPosATL _object;
@@ -33,8 +33,8 @@ if (!_parachuteWest and !(locked _object)) then {
};
};
// do not update if buildable and not ok
if (_isNotOk and _isbuildable) exitWith { };
// do not update if buildable && not ok
if (_isNotOk && _isbuildable) exitWith { };
// delete if still not ok
if (_isNotOk) exitWith { deleteVehicle _object; diag_log(format["Deleting object %1 with invalid ID at pos [%2,%3,%4]",typeOf _object,_object_position select 0,_object_position select 1, _object_position select 2]); };
@@ -90,7 +90,7 @@ _object_damage = {
_selection = getText (configFile >> "CfgVehicles" >> (typeOf _object) >> "HitPoints" >> _x >> "name");
if (_hit > 0) then {_array set [count _array,[_selection,_hit]]};
_object setHit ["_selection", _hit];
} forEach _hitpoints;
} count _hitpoints;
_key = format["CHILD:306:%1:%2:%3:",_objectID,_array,_damage];
//diag_log ("HIVE: WRITE: "+ str(_key));
@@ -110,7 +110,7 @@ _object_killed = {
if (_hit > 0) then {_array set [count _array,[_selection,_hit]]};
_hit = 1;
_object setHit ["_selection", _hit];
} forEach _hitpoints;
} count _hitpoints;
if (_objectID == "0") then {
_key = format["CHILD:306:%1:%2:%3:",_uid,_array,_damage];
@@ -145,7 +145,7 @@ _object_repair = {
_selection = getText (configFile >> "CfgVehicles" >> (typeOf _object) >> "HitPoints" >> _x >> "name");
if (_hit > 0) then {_array set [count _array,[_selection,_hit]]};
_object setHit ["_selection", _hit];
} forEach _hitpoints;
} count _hitpoints;
_key = format["CHILD:306:%1:%2:%3:",_objectID,_array,_damage];
//diag_log ("HIVE: WRITE: "+ str(_key));