Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #719 Invalid result for CBA_fnc_getNearest #720

Merged
merged 1 commit into from
Jul 9, 2017

Conversation

nilsms
Copy link
Contributor

@nilsms nilsms commented Jul 5, 2017

Fix #719 Invalid result for CBA_fnc_getNearest
res = [[0,0,0], [[10,10,0],[1,1,0], [5,5,0]]] call CBA_fnc_getNearest;
result before fix => [10,10,0,[1,1,0],[5,5,0]]
result after fix => [1,1,0]

@PabstMirror
Copy link
Contributor

getNearest has 2 return types based on the presence of the radius param

So I think we want something like this

        if (count _this > 2) then {
            _return pushBack _x;
        } else {
            _radius = _distance;
            _return = _x;
        };

from https://github.com/nilsms/CBA_A3/blob/8d3519bf9e6ddf83a97a6a2247cb122ae96b4a2f/addons/common/fnc_getNearest.sqf

isEqualType objNull is the problem, because it doesn't work with arrayPositions as inputs

@nilsms
Copy link
Contributor Author

nilsms commented Jul 5, 2017

Your right, I missed the "or List of entities within given distance" part.

@nilsms
Copy link
Contributor Author

nilsms commented Jul 5, 2017

Quick rewrite of the patch to support returning multiple entities. Tested in game with both array positions and vehicles. Also added test case with radius.

Rewrote the branch commit history, old habit from other projects, not sure what you prefer.

@PabstMirror PabstMirror added this to the 3.4.1 milestone Jul 7, 2017
@Killswitch00 Killswitch00 merged commit be630c0 into CBATeam:master Jul 9, 2017
@nilsms nilsms deleted the fix_getNearest branch July 10, 2017 08:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CBA_fnc_getNearest invalid results
3 participants