Skip to content

Commit

Permalink
fix for a CBA_missionTime initialization race condition (#1047)
Browse files Browse the repository at this point in the history
  • Loading branch information
commy2 committed Feb 9, 2019
1 parent d1f5de1 commit 27149d9
Showing 1 changed file with 20 additions and 10 deletions.
30 changes: 20 additions & 10 deletions addons/common/init_perFrameHandler.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -119,19 +119,29 @@ if (isMultiplayer) then {

// multiplayer client
0 spawn {
"CBA_missionTime" addPublicVariableEventHandler {
CBA_missionTime = _this select 1;
isNil {
private _fnc_init = {
CBA_missionTime = _this select 1;

GVAR(lastTickTime) = diag_tickTime; // prevent time skip on clients
GVAR(lastTickTime) = diag_tickTime; // prevent time skip on clients

[QFUNC(missionTimePFH), {
if (time != GVAR(lastTime)) then {
CBA_missionTime = CBA_missionTime + (_tickTime - GVAR(lastTickTime));
GVAR(lastTime) = time; // used to detect paused game
};
[QFUNC(missionTimePFH), {
if (time != GVAR(lastTime)) then {
CBA_missionTime = CBA_missionTime + (_tickTime - GVAR(lastTickTime));
GVAR(lastTime) = time; // used to detect paused game
};

GVAR(lastTickTime) = _tickTime;
}] call CBA_fnc_compileFinal;
GVAR(lastTickTime) = _tickTime;
}] call CBA_fnc_compileFinal;

};

"CBA_missionTime" addPublicVariableEventHandler _fnc_init;

if (CBA_missionTime != -1) then {
WARNING_1("CBA_missionTime packet arrived prematurely. Installing update handler manually. Transferred value was %1.",CBA_missionTime);
[nil, CBA_missionTime] call _fnc_init;
};
};
};
};
Expand Down

0 comments on commit 27149d9

Please sign in to comment.