mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Safer unit updates
This commit is contained in:
parent
d680789d04
commit
8d6f167d97
@ -19,10 +19,11 @@
|
|||||||
|
|
||||||
params [["_newUnits",[],[[]]],["_blacklist",false,[false]]];
|
params [["_newUnits",[],[[]]],["_blacklist",false,[false]]];
|
||||||
|
|
||||||
// Function only matter on player clients
|
// Function only matters on player clients
|
||||||
if !(hasInterface) exitWith {};
|
if !(hasInterface) exitWith {};
|
||||||
|
|
||||||
if !(_newUnits isEqualTo []) then {
|
// If adding to a list we can exit here, since it won't show up until the UI refreshes anyway
|
||||||
|
if !(_newUnits isEqualTo []) exitWith {
|
||||||
if (_blacklist) then {
|
if (_blacklist) then {
|
||||||
GVAR(unitWhitelist) = GVAR(unitWhitelist) - _newUnits;
|
GVAR(unitWhitelist) = GVAR(unitWhitelist) - _newUnits;
|
||||||
GVAR(unitBlacklist) append _newUnits;
|
GVAR(unitBlacklist) append _newUnits;
|
||||||
@ -32,16 +33,13 @@ if !(_newUnits isEqualTo []) then {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
// Reset the filter list (removes any units that no longer apply)
|
private ["_playerSide","_sides","_filteredUnits"];
|
||||||
GVAR(unitList) = [];
|
|
||||||
|
|
||||||
// Unit filter
|
// Unit setting filter
|
||||||
_newUnits = [[],allPlayers,allUnits] select GVAR(filterUnits);
|
_newUnits = [[],allPlayers,allUnits] select GVAR(filterUnits);
|
||||||
|
|
||||||
// Side filter
|
// Side setting filter
|
||||||
private ["_playerSide","_sides"];
|
|
||||||
_playerSide = side group player;
|
_playerSide = side group player;
|
||||||
|
|
||||||
if (GVAR(filterSides) == 0) then {
|
if (GVAR(filterSides) == 0) then {
|
||||||
_sides = [_playerSide];
|
_sides = [_playerSide];
|
||||||
} else {
|
} else {
|
||||||
@ -56,6 +54,7 @@ if (GVAR(filterSides) == 0) then {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Filter units and append to list
|
// Filter units and append to list
|
||||||
|
_filteredUnits = [];
|
||||||
{
|
{
|
||||||
if (
|
if (
|
||||||
(alive _x) &&
|
(alive _x) &&
|
||||||
@ -64,10 +63,10 @@ if (GVAR(filterSides) == 0) then {
|
|||||||
{simulationEnabled _x} &&
|
{simulationEnabled _x} &&
|
||||||
{!(_x getVariable [QGVAR(isSpectator), false])} // Who watches the watchmen?
|
{!(_x getVariable [QGVAR(isSpectator), false])} // Who watches the watchmen?
|
||||||
) then {
|
) then {
|
||||||
GVAR(unitList) pushBack _x;
|
_filteredUnits pushBack _x;
|
||||||
};
|
};
|
||||||
} forEach (_newUnits - GVAR(unitBlacklist));
|
} forEach (_newUnits - GVAR(unitBlacklist));
|
||||||
|
_filteredUnits append GVAR(unitWhitelist);
|
||||||
|
|
||||||
// Apply whitelist
|
// Replace previous list entirely (removes any no longer valid)
|
||||||
GVAR(unitList) append GVAR(unitWhitelist);
|
GVAR(unitList) = _filteredUnits arrayIntersect _filteredUnits;
|
||||||
GVAR(unitList) = GVAR(unitList) arrayIntersect GVAR(unitList);
|
|
||||||
|
Loading…
Reference in New Issue
Block a user