-
Notifications
You must be signed in to change notification settings - Fork 149
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
don't skip next PFH if current one is removed while iterating through #950
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,13 +29,19 @@ if (_handle < 0 || {_handle >= count GVAR(PFHhandles)}) exitWith {}; | |
[{ | ||
params ["_handle"]; | ||
|
||
GVAR(perFrameHandlerArray) deleteAt (GVAR(PFHhandles) select _handle); | ||
GVAR(PFHhandles) set [_handle, nil]; | ||
GVAR(perFrameHandlerArray) set [GVAR(PFHhandles) select _handle select 0, {}]; | ||
|
||
{ | ||
_x params ["", "", "", "", "", "_handle"]; | ||
GVAR(PFHhandles) set [_handle, _forEachIndex]; | ||
} forEach GVAR(perFrameHandlerArray); | ||
[{ | ||
params ["_handle"]; | ||
|
||
GVAR(perFrameHandlerArray) deleteAt (GVAR(PFHhandles) select _handle); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @commy2 Yeah reading again after a sleep I don't think it would break anymore (since this line becomes There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The only exception would be, if you were to remove the same handle twice in the same frame and also addEventHandler in the next frame, would it be possible that the same index ( There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is all changed now. |
||
GVAR(PFHhandles) set [_handle, nil]; | ||
|
||
{ | ||
_x params ["", "", "", "", "", "_handle"]; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. reusing _handle here looks confusing to some people. But these people don't look at CBA code anyway. (I pressed send review and wanted to submit the comment after that.. But who could've guessed that the comment is discarded when you submit the review.) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I just indented the previous code. The function is simple enough I'd say. |
||
GVAR(PFHhandles) set [_handle, _forEachIndex]; | ||
} forEach GVAR(perFrameHandlerArray); | ||
}, _handle] call CBA_fnc_execNextFrame; | ||
}, _handle] call CBA_fnc_directCall; | ||
|
||
nil |
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.
Fun fact.
call
doesn't exit early if it has no code. It will actually really build a callstack and everything required. And then execute the empty code and exit right after.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.
I wouldn't have implemented it any other way tbh. For simplicity.