Laser - Fix seeker owner return value (#8862)

* Fix laser seeker return value

Back to consistent with the documentation

* Pick the owner with most hits instead of the last one in the hashmap
This commit is contained in:
zharf 2022-04-07 01:02:39 +03:00 committed by GitHub
parent 020cf2ddd8
commit 72774c909a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -164,8 +164,9 @@ if ((count _spots) > 0) then {
{ {
_x params ["_xPos", "_owner"]; _x params ["_xPos", "_owner"];
_finalPos = _finalPos vectorAdd _xPos; _finalPos = _finalPos vectorAdd _xPos;
private _count = _ownersHash getOrDefault [hashValue _owner, 0]; private _value = _ownersHash getOrDefault [hashValue _owner, [0, _owner]];
_ownersHash set [hashValue _owner, _count + 1]; _value set [0, 1 + _value#0];
_ownersHash set [hashValue _owner, _value];
} forEach _finalBucket; } forEach _finalBucket;
_finalPos = _finalPos vectorMultiply (1 / (count _finalBucket)); _finalPos = _finalPos vectorMultiply (1 / (count _finalBucket));
@ -174,8 +175,10 @@ if ((count _spots) > 0) then {
{ {
//IGNORE_PRIVATE_WARNING ["_x", "_y"]; //IGNORE_PRIVATE_WARNING ["_x", "_y"];
if (_y > _maxOwnerCount) then { _y params ["_count", "_owner"];
_finalOwner = _x; if (_count > _maxOwnerCount) then {
_maxOwnerCount = _count;
_finalOwner = _owner;
}; };
} forEach _ownersHash; } forEach _ownersHash;
}; };