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

Advanced Ballistics - Improve Performance in handleFirePFH #7699

Merged
merged 4 commits into from
Jun 13, 2020
Merged
Changes from 2 commits
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
20 changes: 12 additions & 8 deletions addons/advanced_ballistics/functions/fnc_handleFirePFH.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,11 @@
* Public: No
*/

private _deleted = false;
{
_x params ["_bullet","_caliber","_bulletTraceVisible","_index"];

if (!alive _bullet) then {
GVAR(allBullets) deleteAt (GVAR(allBullets) find _x);
} else {
if (alive _bullet) then {
private _bulletVelocity = velocity _bullet;
private _bulletPosition = getPosASL _bullet;

Expand All @@ -29,11 +28,16 @@
};

_bullet setVelocity (_bulletVelocity vectorAdd (parseSimpleArray ("ace_advanced_ballistics" callExtension format["simulate:%1:%2:%3:%4:%5:%6", _index, _bulletVelocity, _bulletPosition, wind, ASLToATL(_bulletPosition) select 2, CBA_missionTime toFixed 6])));
} else {
GVAR(allBullets) set [_forEachIndex, objNull];
_deleted = true;
};
nil
} count +GVAR(allBullets);
} forEach GVAR(allBullets);

if (GVAR(allBullets) isEqualTo []) then {
[_this select 1] call CBA_fnc_removePerFrameHandler;
GVAR(BulletPFH) = nil;
if (_deleted) then {
GVAR(allBullets) = GVAR(allBullets) - [objNull];
kymckay marked this conversation as resolved.
Show resolved Hide resolved
if (GVAR(allBullets) isEqualTo []) then {
[_this select 1] call CBA_fnc_removePerFrameHandler;
GVAR(BulletPFH) = nil;
};
};