Skip to content
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

Move addMissionEventHandler to postInit #312

Merged
merged 1 commit into from
Apr 21, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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