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

use mission event for PlayerConnected #306

Merged
merged 4 commits into from
Apr 22, 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
5 changes: 5 additions & 0 deletions addons/common/XEH_preInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,9 @@ GVAR(addons) = _addons;
// BWC
#include "backwards_comp.sqf"

// band aid - remove this once they fix PlayerConnected mission event handler
// https://forums.bistudio.com/topic/143930-general-discussion-dev-branch/page-942#entry3003074
[QGVAR(OPC_FIX), "onPlayerConnected", {}] call BIS_fnc_addStackedEventHandler;
[QGVAR(OPC_FIX), "onPlayerConnected"] call BIS_fnc_removeStackedEventHandler;

ADDON = true;
14 changes: 11 additions & 3 deletions addons/common/init_perFrameHandler.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,17 @@ if (isMultiplayer) then {
GVAR(lastTickTime) = _tickTime;
};

["CBA_SynchMissionTime", "onPlayerConnected", {
_owner publicVariableClient "CBA_missionTime";
}] call BIS_fnc_addStackedEventHandler;
if (isNil {canSuspend}) then {
// pre v1.58
["CBA_SynchMissionTime", "onPlayerConnected", {
_owner publicVariableClient "CBA_missionTime";
}] call BIS_fnc_addStackedEventHandler;
} else {
// v1.58 and later
addMissionEventHandler ["PlayerConnected", {
(_this select 4) publicVariableClient "CBA_missionTime";
}];
};
} else {
CBA_missionTime = -1;

Expand Down
41 changes: 30 additions & 11 deletions addons/network/XEH_postServerInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,37 @@ LOG(MSG_INIT);
// Why would we send __SERVER__ to an on PLAYER connected event,
// [["__SERVER__","0",objNull,true]] call CBA_fnc_globalEvent;

// OPC gets _id, _uid, _name
[QUOTE(GVAR(opc)), "onPlayerConnected", {
if (_name=="__SERVER__") exitWith {};
_obj=objNull;
{
if (_name == name _x) then
if (isNil {canSuspend}) then {
// pre v1.58
// OPC gets _id, _uid, _name
[QUOTE(GVAR(opc)), "onPlayerConnected", {
if (_name=="__SERVER__") exitWith {};
_obj=objNull;
{
_obj=_x;
if (_name == name _x) then
{
_obj=_x;
};
} forEach playableUnits;
if (!isNull _obj) then {[_name, _uid, _obj] call FUNC(opc);};
}] call BIS_fnc_addStackedEventhandler;
} else {
// v1.58 and later
addMissionEventHandler ["PlayerConnected", {
params ["_id", "_uid", "_name", "_jip", "_owner"];

if (_name == "__SERVER__") exitWith {};

private _object = objNull;
{
if (name _x == _name) exitWith { _object = _x; };
} forEach playableUnits;

if (!isNull _object) then {
[_name, _uid, _object] call FUNC(opc);
};
} forEach playableUnits;
if (!isNull _obj) then {[_name, _uid, _obj] call FUNC(opc);};
}] call BIS_fnc_addStackedEventhandler;
}];
};

// Announce the completion of the initialization of the script
ADDON = true;
ADDON = true;