Skip to content

Commit 70853fd

Browse files
authored
Merge pull request #3455 from jaj22/fix-distance-player-disconnect
Bugfix and optimizations to spawner selection
2 parents 4243022 + d2efe67 commit 70853fd

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

A3A/addons/core/functions/Base/fn_distance.sqf

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -416,15 +416,16 @@ do
416416
{
417417
_counter = 0;
418418

419-
// only count one spawner per vehicle
420-
_occupants = units Occupants select { _x getVariable ["spawner", false] and _x == effectiveCommander vehicle _x };
421-
_invaders = units Invaders select { _x getVariable ["spawner", false] and _x == effectiveCommander vehicle _x };
419+
// Only count one spawner per vehicle. SimpleVM is much faster with split selects
420+
_occupants = units Occupants select { _x getVariable ["spawner", false] } select { _x == effectiveCommander vehicle _x };
421+
_invaders = units Invaders select { _x getVariable ["spawner", false] } select { _x == effectiveCommander vehicle _x };
422422

423+
// No effective-commander optimization for players because it breaks on disconnection
424+
_teamplayer = units teamPlayer select { _x getVariable ["spawner", false] };
423425
// Exclude players in fast-moving fixed-wing aircraft
424-
_teamplayer = units teamPlayer select {
426+
_teamplayer = _teamplayer select {
425427
private _veh = vehicle _x;
426-
_x getVariable ["spawner", false] and _x == effectiveCommander _veh
427-
and (_veh == _x or {!(_veh isKindOf "Plane" and (!isTouchingGround _veh or speed _veh > 80))})
428+
!(_veh isKindOf "Plane") or {isTouchingGround _veh or speed _veh < 80}
428429
};
429430
// Add in rebel-controlled UAVs
430431
_teamplayer append (allUnitsUAV select { side group _x == teamPlayer });
@@ -434,8 +435,7 @@ do
434435
{
435436
private _rp = _x getVariable ["owner", _x]; // real player unit in remote-control case
436437
private _veh = vehicle _rp;
437-
if (_rp != effectiveCommander _veh) then { continue };
438-
if (_veh == _rp or {!(_veh isKindOf "Air" and speed _veh > 50)}) then { _players pushBack _rp };
438+
if (!(_veh isKindOf "Air") or { speed _veh < 50 }) then { _players pushBack _rp };
439439
} forEach (allPlayers - entities "HeadlessClient_F");
440440
};
441441

0 commit comments

Comments
 (0)