Skip to content

Commit

Permalink
Merge pull request #312 from CBATeam/delayPfehMissionEvent160
Browse files Browse the repository at this point in the history
Move addMissionEventHandler to postInit
  • Loading branch information
commy2 committed Apr 21, 2016
2 parents 43abf41 + 264f312 commit b7f5051
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 25 deletions.
27 changes: 27 additions & 0 deletions addons/common/XEH_postInit.sqf
Original file line number Diff line number Diff line change
@@ -1,6 +1,33 @@
// #define DEBUG_MODE_FULL
#include "script_component.hpp"

//Install PFEH:
if (isNil {canSuspend}) then {
// pre 1.58
["CBA_PFH", "onEachFrame", {
call FUNC(onFrame);
GVAR(lastFrameRender) = diag_frameNo;
}] call BIS_fnc_addStackedEventHandler;

FUNC(monitorFrameRender) = {
if (abs (diag_frameno - GVAR(lastFrameRender)) > DELAY_MONITOR_THRESHOLD) then {
// Restores the onEachFrame handler
["CBA_PFH", "onEachFrame", {
call FUNC(onFrame);
GVAR(lastFrameRender) = diag_frameNo;
}] call BIS_fnc_addStackedEventHandler;
TRACE_1("PFH restored",nil);
};
};

// Use a trigger, runs every 0.5s, unscheduled execution
GVAR(perFrameTrigger) = createTrigger ["EmptyDetector", [0,0,0], false];
GVAR(perFrameTrigger) setTriggerStatements ['FUNC(monitorFrameRender) call CBA_fnc_directCall', "", ""];
} else {
// 1.58 and later
addMissionEventHandler ["EachFrame", FUNC(onFrame)];
};

LOG(MSG_INIT);

// NOTE: Due to the way the BIS functions initializations work, and the requirement of BIS_functions_mainscope to be a unit (in a group)
Expand Down
25 changes: 0 additions & 25 deletions addons/common/init_perFrameHandler.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -84,31 +84,6 @@ FUNC(onFrame) = {

};

if (isNil {canSuspend}) then {
// pre 1.58
["CBA_PFH", "onEachFrame", {
call FUNC(onFrame);
GVAR(lastFrameRender) = diag_frameNo;
}] call BIS_fnc_addStackedEventHandler;

FUNC(monitorFrameRender) = {
if (abs (diag_frameno - GVAR(lastFrameRender)) > DELAY_MONITOR_THRESHOLD) then {
// Restores the onEachFrame handler
["CBA_PFH", "onEachFrame", {
call FUNC(onFrame);
GVAR(lastFrameRender) = diag_frameNo;
}] call BIS_fnc_addStackedEventHandler;
TRACE_1("PFH restored",nil);
};
};

// Use a trigger, runs every 0.5s, unscheduled execution
GVAR(perFrameTrigger) = createTrigger ["EmptyDetector", [0,0,0], false];
GVAR(perFrameTrigger) setTriggerStatements ['FUNC(monitorFrameRender) call CBA_fnc_directCall', "", ""];
} else {
// 1.58 and later
addMissionEventHandler ["EachFrame", FUNC(onFrame)];
};

// fix for save games. subtract last tickTime from ETA of all PFHs after mission was loaded
addMissionEventHandler ["Loaded", {
Expand Down

0 comments on commit b7f5051

Please sign in to comment.