-
Notifications
You must be signed in to change notification settings - Fork 148
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
add '_thisArgs', '_thisId', '_thisType' and '_thisFnc' and to CBA events #375
Conversation
@@ -33,7 +33,9 @@ | |||
|
|||
#define CALL_EVENT(params,event) {\ |
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.
Should the macro argument "params" be renamed so as to not collide with the reserved word (command) params
?
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.
Yes. That collided with the params command I added ...
One time event handler printing "hello world"
Problem is that you are modifing an array of GVAR(eventsNamespace) while iterating through it via |
done |
I'm really not sure if any of this is necessary, my main concern is that there will be a performance cost to adding these args. For 10x localEvent calls for something with 3 added ehs: Old: 0.218436 ms 0.216403 ms 0.217628 ms |
Good point. It's performance vs. functionality. I have no idea with what we should go here. |
ACE calls multiple EHs for each bullet fired, so 50% increase isn't good I think we can do most of what we need by using a function wrapper. Check out my demo code here (not tested, more of an idea): https://github.com/CBATeam/CBA_A3/compare/addEventHandlerWrapper?expand=1 |
Is it a 50% increase even when measuring with the actual event function you are calling? |
|
My point was that |
@PabstMirror I read the link you posted.
I'd still have to copy the array though, but that is only once per event call and not once per event per call. |
An alternative/wrapper function sounds like the best way forward, so as to not compromise performance of the original function. Now, to think of a suitable name... |
Done. I'm going with |
Closes: #374
Adds the same meta data
CBA_fnc_addBISEventHandler
has to the CBA events.CBA_fnc_addEventHandler
to assign arguments to the event._thisArgs
- Arguments passed when adding the event handler._thisId
- Id that can be used to remove the event viaCBA_fnc_removeEventHandler
_thisType
- the name of the event ("testEvent" in["testEvent", ...] call CBA_fnc_addEventHandler
)_thisFnc
- function that is executed when the event happensNote: If the arguments passed to
CBA_fnc_addEventHandler
are an array, they are stored as array reference and not as copy. That means you can modify these arguments even after the event was added.Needs some more testing, will do later ...