Headless - Fix unable to transfer groups (#10203)

* Fix headless unable to transfer groups

* Switch events to use `CBA_fnc_ownerEvent`

* Update variable definitions

---------

Co-authored-by: PabstMirror <pabstmirror@gmail.com>
Co-authored-by: johnb432 <58661205+johnb432@users.noreply.github.com>
This commit is contained in:
Tim Beswick 2024-08-15 08:31:51 +01:00 committed by GitHub
parent 3728bc4b8b
commit f3e2e11693
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -74,13 +74,9 @@ private _numTransferredHC1 = 0;
private _numTransferredHC2 = 0;
private _numTransferredHC3 = 0;
private _units = [];
private _transfer = false;
private _previousOwner = -1;
// Transfer AI groups
{
_units = units _x;
private _units = units _x;
// No transfer if empty group or if group is blacklisted
if (_units isEqualTo [] || {_x getVariable [QXGVAR(blacklist), false]}) then {
@ -92,6 +88,8 @@ private _previousOwner = -1;
continue;
};
private _transfer = true;
{
// No transfer if already transferred
if (!_force && {(owner _x) in [_idHC1, _idHC2, _idHC3]}) exitWith {
@ -126,7 +124,7 @@ private _previousOwner = -1;
};
// Round robin between HCs if load balance enabled, else pass all to one HC
_previousOwner = groupOwner _x;
private _previousOwner = groupOwner _x;
switch (_currentHC) do {
case 1: {
@ -145,11 +143,13 @@ private _previousOwner = -1;
// Don't transfer if it's already local to HC1
if (_previousOwner == _idHC1) exitWith {};
[QGVAR(groupTransferPre), [_x, _HC1, _previousOwner, _idHC1], [_previousOwner, _idHC1]] call CBA_fnc_targetEvent; // API
[QGVAR(groupTransferPre), [_x, _HC1, _previousOwner, _idHC1], _previousOwner] call CBA_fnc_ownerEvent; // API
[QGVAR(groupTransferPre), [_x, _HC1, _previousOwner, _idHC1], _idHC1] call CBA_fnc_ownerEvent; // API
private _transferred = _x setGroupOwner _idHC1;
[QGVAR(groupTransferPost), [_x, _HC1, _previousOwner, _idHC1, _transferred], [_previousOwner, _idHC1]] call CBA_fnc_targetEvent; // API
[QGVAR(groupTransferPost), [_x, _HC1, _previousOwner, _idHC1, _transferred], _previousOwner] call CBA_fnc_ownerEvent; // API
[QGVAR(groupTransferPost), [_x, _HC1, _previousOwner, _idHC1, _transferred], _idHC1] call CBA_fnc_ownerEvent; // API
if (_transferred) then {
_numTransferredHC1 = _numTransferredHC1 + 1;
@ -171,11 +171,13 @@ private _previousOwner = -1;
// Don't transfer if it's already local to HC2
if (_previousOwner == _idHC2) exitWith {};
[QGVAR(groupTransferPre), [_x, _HC2, _previousOwner, _idHC2], [_previousOwner, _idHC2]] call CBA_fnc_targetEvent; // API
[QGVAR(groupTransferPre), [_x, _HC2, _previousOwner, _idHC2], _previousOwner] call CBA_fnc_ownerEvent; // API
[QGVAR(groupTransferPre), [_x, _HC2, _previousOwner, _idHC2], _idHC2] call CBA_fnc_ownerEvent; // API
private _transferred = _x setGroupOwner _idHC2;
[QGVAR(groupTransferPost), [_x, _HC2, _previousOwner, _idHC2, _transferred], [_previousOwner, _idHC2]] call CBA_fnc_targetEvent; // API
[QGVAR(groupTransferPost), [_x, _HC2, _previousOwner, _idHC2, _transferred], _previousOwner] call CBA_fnc_ownerEvent; // API
[QGVAR(groupTransferPost), [_x, _HC2, _previousOwner, _idHC2, _transferred], _idHC2] call CBA_fnc_ownerEvent; // API
if (_transferred) then {
_numTransferredHC2 = _numTransferredHC2 + 1;
@ -197,11 +199,13 @@ private _previousOwner = -1;
// Don't transfer if it's already local to HC3
if (_previousOwner == _idHC3) exitWith {};
[QGVAR(groupTransferPre), [_x, _HC3, _previousOwner, _idHC3], [_previousOwner, _idHC3]] call CBA_fnc_targetEvent; // API
[QGVAR(groupTransferPre), [_x, _HC3, _previousOwner, _idHC3], _previousOwner] call CBA_fnc_ownerEvent; // API
[QGVAR(groupTransferPre), [_x, _HC3, _previousOwner, _idHC3], _idHC3] call CBA_fnc_ownerEvent; // API
private _transferred = _x setGroupOwner _idHC2;
[QGVAR(groupTransferPost), [_x, _HC3, _previousOwner, _idHC3, _transferred], [_previousOwner, _idHC3]] call CBA_fnc_targetEvent; // API
[QGVAR(groupTransferPost), [_x, _HC3, _previousOwner, _idHC3, _transferred], _previousOwner] call CBA_fnc_ownerEvent; // API
[QGVAR(groupTransferPost), [_x, _HC3, _previousOwner, _idHC3, _transferred], _idHC3] call CBA_fnc_ownerEvent; // API
if (_transferred) then {
_numTransferredHC3 = _numTransferredHC3 + 1;