diff --git a/addons/headless/XEH_PREP.hpp b/addons/headless/XEH_PREP.hpp index af36e76402a..e1c65cc083d 100644 --- a/addons/headless/XEH_PREP.hpp +++ b/addons/headless/XEH_PREP.hpp @@ -1,8 +1,8 @@ +ACEX_PREP(blacklist); ACEX_PREP(endMissionNoPlayers); ACEX_PREP(handleConnectHC); ACEX_PREP(handleDisconnect); ACEX_PREP(handleSpawn); -ACEX_PREP(modifyUnitsBlacklist); ACEX_PREP(moduleInit); ACEX_PREP(rebalance); ACEX_PREP(transferGroups); diff --git a/addons/headless/XEH_postInit.sqf b/addons/headless/XEH_postInit.sqf index 5cf4090c9ff..bf7ac3797ca 100644 --- a/addons/headless/XEH_postInit.sqf +++ b/addons/headless/XEH_postInit.sqf @@ -11,18 +11,11 @@ // Add disconnect EH addMissionEventHandler ["HandleDisconnect", {call FUNC(handleDisconnect)}]; - [QGVAR(transferGroupsToServer), { - params ["_groups"]; - - // Filter out any invalid entries - GVAR(headlessClients) = GVAR(headlessClients) select {!isNull _x}; - - private _idsHC = GVAR(headlessClients) apply {owner _x}; + [QGVAR(transferGroupsToOwner), { + params ["_groups", "_owner"]; { - if (groupOwner _x in _idsHC) then { - _x setGroupOwner 2; - }; + _x setGroupOwner _owner; } forEach _groups; }] call CBA_fnc_addEventHandler; } else { diff --git a/addons/headless/functions/fnc_modifyUnitsBlacklist.sqf b/addons/headless/functions/fnc_blacklist.sqf similarity index 65% rename from addons/headless/functions/fnc_modifyUnitsBlacklist.sqf rename to addons/headless/functions/fnc_blacklist.sqf index 249ed6da01b..1e1f5ca93d3 100644 --- a/addons/headless/functions/fnc_modifyUnitsBlacklist.sqf +++ b/addons/headless/functions/fnc_blacklist.sqf @@ -6,43 +6,45 @@ * Arguments: * 0: Units * 1: Add (true) or remove (false) from blacklist (default: true) - * 2: Transfer to server if blacklisted (default: true) + * 2: Owner to transfer units to (default: -1) * * Return Value: * None * * Example: - * [cursorObject, true] call ace_headless_fnc_modifyUnitsBlacklist + * [cursorObject, true] call ace_headless_fnc_blacklist * * Public: Yes */ -params [["_units", objNull, [objNull, grpNull, []]], ["_blacklist", true, [false]], ["_transferToServer", true, [false]]]; +params [["_units", objNull, [objNull, grpNull, []]], ["_blacklist", true, [false]], ["_newOwner", -1, [false]]]; if !(_units isEqualType []) then { _units = [_units]; }; +// Make sure passed arguments are objects or groups _units = _units select {_x isEqualType objNull || {_x isEqualType grpNull}}; _units = _units select {!isNull _x}; if (_units isEqualTo []) exitWith {}; +private _transfer = _blacklist && {_newOwner > 1}; private _groups = []; { _x setVariable [QXGVAR(blacklist), _blacklist, true]; - if (_blacklist && _transferToServer) then { + if (_transfer) then { if (_x isEqualType objNull) then { - _groups pushBack _x; + _groups pushBack group _x; } else { - _groups pushBack group _x + _groups pushBack _x; }; }; } forEach _units; // Try to move AI back to server -if (_blacklist && _transferToServer) then { - [QGVAR(transferGroupsToServer), [_groups arrayIntersect _groups]] call CBA_fnc_serverEvent; +if (_transfer) then { + [QGVAR(transferGroupsToOwner), [_groups arrayIntersect _groups, _newOwner]] call CBA_fnc_serverEvent; };