Skip to content

Commit

Permalink
Merge pull request #3658 from acemod/fixPlayerChangedEvent
Browse files Browse the repository at this point in the history
Wait until postInit to install playerChanged event
  • Loading branch information
commy2 committed Apr 4, 2016
2 parents 357045a + f8b46e8 commit a8c0840
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 24 deletions.
6 changes: 0 additions & 6 deletions addons/common/XEH_postInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -332,12 +332,6 @@ GVAR(OldVisibleMap) = false;
GVAR(OldInventoryDisplayIsOpen) = nil; //@todo check this
GVAR(OldIsCamera) = false;

// clean up playerChanged eventhandler from preinit and put it in the same PFH as the other events to reduce overhead and guarantee advantageous execution order
if (!isNil QGVAR(PreInit_playerChanged_PFHID)) then {
[GVAR(PreInit_playerChanged_PFHID)] call CBA_fnc_removePerFrameHandler;
GVAR(PreInit_playerChanged_PFHID) = nil;
};

// PFH to raise varios events
[{
BEGIN_COUNTER(stateChecker);
Expand Down
19 changes: 1 addition & 18 deletions addons/common/XEH_preInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -47,29 +47,12 @@ GVAR(statusEffect_Names) = [];
GVAR(statusEffect_isGlobal) = [];

//////////////////////////////////////////////////
// Set up PlayerChanged eventhandler for pre init
// Set up PlayerChanged eventhandler for pre init (EH is installed in postInit)
//////////////////////////////////////////////////

ACE_player = objNull;
uiNamespace setVariable ["ACE_player", objNull];

// @todo check if this can be removed
if (hasInterface) then {
// PFH to update the ACE_player variable
GVAR(PreInit_playerChanged_PFHID) = [{
if !(ACE_player isEqualTo (call FUNC(player))) then {
private _oldPlayer = ACE_player;

ACE_player = call FUNC(player);
uiNamespace setVariable ["ACE_player", ACE_player];

// Raise ACE event
["playerChanged", [ACE_player, _oldPlayer]] call FUNC(localEvent);
};
}, 0, []] call CBA_fnc_addPerFrameHandler;
};


//////////////////////////////////////////////////
// Time handling
//////////////////////////////////////////////////
Expand Down

0 comments on commit a8c0840

Please sign in to comment.