-
Notifications
You must be signed in to change notification settings - Fork 740
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
Pass functions by "reference" to bis event handlers #4898
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't look right.
addons/hearing/XEH_postInit.sqf
Outdated
_player setVariable [QGVAR(firedEH), _firedEH]; | ||
private _explosionEH = _player addEventHandler ["Explosion", LINKFUNC(explosionNear)]; | ||
private _explosionEH = _player addEventHandler ["Explosion", {call (explosionNear)}]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
?
addons/hearing/XEH_postInit.sqf
Outdated
@@ -60,9 +60,9 @@ GVAR(lastPlayerVehicle) = objNull; | |||
}; | |||
// Don't add a new EH if the unit respawned | |||
if ((_player getVariable [QGVAR(firedEH), -1]) == -1) then { | |||
private _firedEH = _player addEventHandler ["FiredNear", LINKFUNC(firedNear)]; | |||
private _firedEH = _player addEventHandler ["FiredNear", {call (firedNear)}]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
?
addons/hearing/XEH_postInit.sqf
Outdated
@@ -35,7 +35,7 @@ GVAR(lastPlayerVehicle) = objNull; | |||
TRACE_2("removed veh eh",_firedEH,GVAR(lastPlayerVehicle)); | |||
}; | |||
if ((!isNull _vehicle) && {_player != _vehicle}) then { | |||
private _firedEH = _vehicle addEventHandler ["FiredNear", LINKFUNC(firedNear)]; | |||
private _firedEH = _vehicle addEventHandler ["FiredNear", {call (firedNear)}]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
?
For reference: https://feedback.bistudio.com/T123355 |
* Pass functions by "reference" to bis event handlers * Add Doc * Fix Conflicts: addons/laserpointer/XEH_postInit.sqf
Thanks to a discovery from @dedmen (ref CBATeam/CBA_A3#588)
Passing a large code function to a BIS EH has a significant performance cost.
Using interact_menu as an example.
So an extra processing time of ~0.3 ms when passing the entire function vs passing a short bit of code that calls the function.