mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
General - Optimize some loops with forEachReversed
(#10191)
This commit is contained in:
parent
3ff635f82d
commit
285f903b14
@ -85,17 +85,17 @@ if (_adjustments isNotEqualTo []) then {
|
|||||||
private _timeInSystem = CBA_missionTime - _timeAdded;
|
private _timeInSystem = CBA_missionTime - _timeAdded;
|
||||||
if (_timeInSystem >= _maxTimeInSystem) then {
|
if (_timeInSystem >= _maxTimeInSystem) then {
|
||||||
_deleted = true;
|
_deleted = true;
|
||||||
_adjustments set [_forEachIndex, objNull];
|
_adjustments deleteAt _forEachIndex;
|
||||||
} else {
|
} else {
|
||||||
private _effectRatio = (((_timeInSystem / _timeTillMaxEffect) ^ 2) min 1) * (_maxTimeInSystem - _timeInSystem) / _maxTimeInSystem;
|
private _effectRatio = (((_timeInSystem / _timeTillMaxEffect) ^ 2) min 1) * (_maxTimeInSystem - _timeInSystem) / _maxTimeInSystem;
|
||||||
if (_hrAdjust != 0) then { _hrTargetAdjustment = _hrTargetAdjustment + _hrAdjust * _effectRatio; };
|
if (_hrAdjust != 0) then { _hrTargetAdjustment = _hrTargetAdjustment + _hrAdjust * _effectRatio; };
|
||||||
if (_painAdjust != 0) then { _painSupressAdjustment = _painSupressAdjustment + _painAdjust * _effectRatio; };
|
if (_painAdjust != 0) then { _painSupressAdjustment = _painSupressAdjustment + _painAdjust * _effectRatio; };
|
||||||
if (_flowAdjust != 0) then { _peripheralResistanceAdjustment = _peripheralResistanceAdjustment + _flowAdjust * _effectRatio; };
|
if (_flowAdjust != 0) then { _peripheralResistanceAdjustment = _peripheralResistanceAdjustment + _flowAdjust * _effectRatio; };
|
||||||
};
|
};
|
||||||
} forEach _adjustments;
|
} forEachReversed _adjustments;
|
||||||
|
|
||||||
if (_deleted) then {
|
if (_deleted) then {
|
||||||
_unit setVariable [VAR_MEDICATIONS, _adjustments - [objNull], true];
|
_unit setVariable [VAR_MEDICATIONS, _adjustments, true];
|
||||||
_syncValues = true;
|
_syncValues = true;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -25,7 +25,6 @@
|
|||||||
_args set [0, CBA_missionTime];
|
_args set [0, CBA_missionTime];
|
||||||
private _isWind = (vectorMagnitude wind > 0);
|
private _isWind = (vectorMagnitude wind > 0);
|
||||||
|
|
||||||
private _deleted = false;
|
|
||||||
{
|
{
|
||||||
_x params ["_bullet", "_airFriction"];
|
_x params ["_bullet", "_airFriction"];
|
||||||
|
|
||||||
@ -33,8 +32,7 @@
|
|||||||
private _bulletSpeedSqr = vectorMagnitudeSqr _bulletVelocity;
|
private _bulletSpeedSqr = vectorMagnitudeSqr _bulletVelocity;
|
||||||
|
|
||||||
if ((!alive _bullet) || {(_bullet isKindOf "BulletBase") && {_bulletSpeedSqr < 10000}}) then {
|
if ((!alive _bullet) || {(_bullet isKindOf "BulletBase") && {_bulletSpeedSqr < 10000}}) then {
|
||||||
GVAR(trackedBullets) set [_forEachIndex, objNull];
|
GVAR(trackedBullets) deleteAt _forEachIndex;
|
||||||
_deleted = true;
|
|
||||||
} else {
|
} else {
|
||||||
if (_isWind) then {
|
if (_isWind) then {
|
||||||
private _trueVelocity = _bulletVelocity vectorDiff wind;
|
private _trueVelocity = _bulletVelocity vectorDiff wind;
|
||||||
@ -50,11 +48,7 @@
|
|||||||
};
|
};
|
||||||
_bullet setVelocity _bulletVelocity;
|
_bullet setVelocity _bulletVelocity;
|
||||||
};
|
};
|
||||||
} forEach GVAR(trackedBullets);
|
} forEachReversed GVAR(trackedBullets);
|
||||||
|
|
||||||
if (_deleted) then {
|
|
||||||
GVAR(trackedBullets) = GVAR(trackedBullets) - [objNull];
|
|
||||||
};
|
|
||||||
|
|
||||||
// END_COUNTER(pfeh);
|
// END_COUNTER(pfeh);
|
||||||
}, GVAR(simulationInterval), [CBA_missionTime]] call CBA_fnc_addPerFrameHandler;
|
}, GVAR(simulationInterval), [CBA_missionTime]] call CBA_fnc_addPerFrameHandler;
|
||||||
|
Loading…
Reference in New Issue
Block a user