Skip to content

Commit

Permalink
Replaced transferToServer with ownerID
Browse files Browse the repository at this point in the history
  • Loading branch information
johnb432 committed Mar 27, 2024
1 parent 25133da commit 6dbe908
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 19 deletions.
2 changes: 1 addition & 1 deletion addons/headless/XEH_PREP.hpp
Original file line number Diff line number Diff line change
@@ -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);
13 changes: 3 additions & 10 deletions addons/headless/XEH_postInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,43 +6,45 @@
* Arguments:
* 0: Units <OBJECT, GROUP, ARRAY>
* 1: Add (true) or remove (false) from blacklist <BOOL> (default: true)
* 2: Transfer to server if blacklisted <BOOL> (default: true)
* 2: Owner to transfer units to <NUMBER> (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;
};

0 comments on commit 6dbe908

Please sign in to comment.