diff --git a/addons/common/init_perFrameHandler.sqf b/addons/common/init_perFrameHandler.sqf index 8ae7dcf43..d0b10f3f5 100644 --- a/addons/common/init_perFrameHandler.sqf +++ b/addons/common/init_perFrameHandler.sqf @@ -3,8 +3,6 @@ #include "script_component.hpp" -#define DELAY_MONITOR_THRESHOLD 1 // Frames - GVAR(perFrameHandlerArray) = []; GVAR(perFrameHandlersToRemove) = []; GVAR(lastTickTime) = diag_tickTime; @@ -12,8 +10,7 @@ GVAR(lastTickTime) = diag_tickTime; GVAR(waitAndExecArray) = []; GVAR(waitAndExecArrayIsSorted) = false; GVAR(nextFrameNo) = diag_frameno + 1; -// PostInit can be 2 frames after preInit, need to manually set nextFrameNo, so new items get added to buffer B while processing A for the first time: -GVAR(nextFrameBufferA) = [[[], {GVAR(nextFrameNo) = diag_frameno;}]]; +GVAR(nextFrameBufferA) = []; GVAR(nextFrameBufferB) = []; GVAR(waitUntilAndExecArray) = []; @@ -23,6 +20,13 @@ GVAR(waitUntilAndExecArray) = []; private _tickTime = diag_tickTime; call FUNC(missionTimePFH); + // frame number does not match expected; can happen between pre and postInit, save-game load and on closing map + // need to manually set nextFrameNo, so new items get added to buffer B and are not executed this frame + if (diag_frameno != GVAR(nextFrameNo)) then { + TRACE_2("frame mismatch",diag_frameno,GVAR(nextFrameNo)); + GVAR(nextFrameNo) = diag_frameno; + }; + // Execute per frame handlers { _x params ["_function", "_delay", "_delta", "", "_args", "_handle"];