mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
One PFEH for execNextFrame and waitAndExec
This commit is contained in:
parent
eb7a38e137
commit
3e396b416a
@ -3,6 +3,27 @@
|
|||||||
|
|
||||||
//IGNORE_PRIVATE_WARNING("_handleNetEvent", "_handleRequestAllSyncedEvents", "_handleRequestSyncedEvent", "_handleSyncedEvent");
|
//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
|
// Listens for global "SettingChanged" events, to update the force status locally
|
||||||
["SettingChanged", {
|
["SettingChanged", {
|
||||||
PARAMS_2(_name,_value);
|
PARAMS_2(_name,_value);
|
||||||
|
@ -287,7 +287,12 @@ PREP(_handleRequestSyncedEvent);
|
|||||||
PREP(_handleRequestAllSyncedEvents);
|
PREP(_handleRequestAllSyncedEvents);
|
||||||
|
|
||||||
GVAR(syncedEvents) = HASH_CREATE;
|
GVAR(syncedEvents) = HASH_CREATE;
|
||||||
|
|
||||||
|
//GVARS for execNextFrame and waitAndExec
|
||||||
GVAR(waitAndExecArray) = [];
|
GVAR(waitAndExecArray) = [];
|
||||||
|
GVAR(nextFrameNo) = diag_frameno;
|
||||||
|
GVAR(nextFrameBufferA) = [];
|
||||||
|
GVAR(nextFrameBufferB) = [];
|
||||||
|
|
||||||
// @TODO: Generic local-managed global-synced objects (createVehicleLocal)
|
// @TODO: Generic local-managed global-synced objects (createVehicleLocal)
|
||||||
|
|
||||||
|
@ -14,21 +14,8 @@
|
|||||||
|
|
||||||
PARAMS_2(_func,_params);
|
PARAMS_2(_func,_params);
|
||||||
|
|
||||||
[
|
if (diag_frameno != GVAR(nextFrameNo)) then {
|
||||||
{
|
GVAR(nextFrameBufferA) pushBack [_params, _func];
|
||||||
EXPLODE_2_PVT(_this,_params,_pfhId);
|
} else {
|
||||||
EXPLODE_2_PVT(_params,_delayedExecParams,_startFrame);
|
GVAR(nextFrameBufferB) pushBack [_params, _func];
|
||||||
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
|
|
||||||
|
@ -22,16 +22,3 @@ PARAMS_3(_func,_params,_delay);
|
|||||||
|
|
||||||
GVAR(waitAndExecArray) pushBack [(ACE_time + _delay), _func, _params];
|
GVAR(waitAndExecArray) pushBack [(ACE_time + _delay), _func, _params];
|
||||||
GVAR(waitAndExecArray) sort true;
|
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;
|
|
||||||
};
|
|
||||||
|
Loading…
Reference in New Issue
Block a user