One PFEH for execNextFrame and waitAndExec

This commit is contained in:
PabstMirror 2015-06-11 02:45:42 -05:00
parent eb7a38e137
commit 3e396b416a
4 changed files with 31 additions and 31 deletions

View File

@ -3,6 +3,27 @@
//IGNORE_PRIVATE_WARNING("_handleNetEvent", "_handleRequestAllSyncedEvents", "_handleRequestSyncedEvent", "_handleSyncedEvent");
//Singe PFEH to handle execNextFrame and waitAndExec:
[{
private ["_entry"];
//Handle the waitAndExec array:
while {((count GVAR(waitAndExecArray)) > 0) && {((GVAR(waitAndExecArray) select 0) select 0) <= ACE_Time}} do {
_entry = GVAR(waitAndExecArray) deleteAt 0;
(_entry select 2) call (_entry select 1);
};
//Handle the execNextFrame array:
{
(_x select 0) call (_x select 1);
} forEach GVAR(nextFrameBufferA);
//Swap double-buffer:
GVAR(nextFrameBufferA) = GVAR(nextFrameBufferB);
GVAR(nextFrameBufferB) = [];
GVAR(nextFrameNo) = diag_frameno + 1;
}, 0, []] call CBA_fnc_addPerFrameHandler;
// Listens for global "SettingChanged" events, to update the force status locally
["SettingChanged", {
PARAMS_2(_name,_value);

View File

@ -287,7 +287,12 @@ PREP(_handleRequestSyncedEvent);
PREP(_handleRequestAllSyncedEvents);
GVAR(syncedEvents) = HASH_CREATE;
//GVARS for execNextFrame and waitAndExec
GVAR(waitAndExecArray) = [];
GVAR(nextFrameNo) = diag_frameno;
GVAR(nextFrameBufferA) = [];
GVAR(nextFrameBufferB) = [];
// @TODO: Generic local-managed global-synced objects (createVehicleLocal)

View File

@ -14,21 +14,8 @@
PARAMS_2(_func,_params);
[
{
EXPLODE_2_PVT(_this,_params,_pfhId);
EXPLODE_2_PVT(_params,_delayedExecParams,_startFrame);
EXPLODE_2_PVT(_delayedExecParams,_func,_funcParams);
// Exit if we are still on the same frame
if (diag_frameno == _startFrame) exitWith {};
// Remove the PFH
[_pfhId] call cba_fnc_removePerFrameHandler;
// Execute the function
_funcParams call _func;
},
0,
[_this, diag_frameno]
] call CBA_fnc_addPerFrameHandler
if (diag_frameno != GVAR(nextFrameNo)) then {
GVAR(nextFrameBufferA) pushBack [_params, _func];
} else {
GVAR(nextFrameBufferB) pushBack [_params, _func];
};

View File

@ -22,16 +22,3 @@ PARAMS_3(_func,_params,_delay);
GVAR(waitAndExecArray) pushBack [(ACE_time + _delay), _func, _params];
GVAR(waitAndExecArray) sort true;
if ((count GVAR(waitAndExecArray)) == 1) then {
[{
while {((count GVAR(waitAndExecArray)) > 0) && {((GVAR(waitAndExecArray) select 0) select 0) <= ACE_Time}} do {
private ["_entry"];
_entry = GVAR(waitAndExecArray) deleteAt 0;
(_entry select 2) call (_entry select 1);
};
if ((count GVAR(waitAndExecArray)) == 0) then {
[(_this select 1)] call cba_fnc_removePerFrameHandler;
};
}, 0, []] call CBA_fnc_addPerFrameHandler;
};