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

fix for a CBA_missionTime initialization race condition #1047

Merged
merged 1 commit into from
Feb 9, 2019
Merged
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
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