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

CBA_fnc_getPos returning array reference instead of an array-copy #584

Closed
highhead opened this issue Feb 9, 2017 · 4 comments
Closed

CBA_fnc_getPos returning array reference instead of an array-copy #584

highhead opened this issue Feb 9, 2017 · 4 comments
Labels
Milestone

Comments

@highhead
Copy link

highhead commented Feb 9, 2017

CBA_fnc_getPos is returning the feeded array reference instead of an array-copy,
which f.e. then bugs out CBA_fnc_RandPos which will alter the originally passed position instead of only returning a new one. The latter related to this commit, where the array-copy has been removed:

8a4d6c2#diff-bee87607846a78814c6fe5729a46a521L24 - line 24

In our case (ALiVE), the usage of the function also causes positions beeing altered in our hashes data.

@PabstMirror
Copy link
Contributor

I think getPos returning an input reference is ok and we just need to fix randPos

@PabstMirror PabstMirror added this to the 3.2 milestone Feb 9, 2017
@marceldev89
Copy link

IMO, the fix should be done in fnc_getPos. It makes no sense for _somePos call CBA_fnc_getPos; to return a reference.

highhead added a commit to ALiVEOS/ALiVE.OS that referenced this issue Feb 9, 2017
…c objectives being moved to weird positions). Fixed recruits being created over water.
DarrellJMartin pushed a commit to ALiVEOS/ALiVE.OS that referenced this issue Feb 10, 2017
…c objectives being moved to weird positions). Fixed recruits being created over water.
@commy2
Copy link
Contributor

commy2 commented Feb 10, 2017

@highhead @marceldev89
CBA_fnc_getPos and CBA_fnc_randPos are very old functions and their age is showing with them. The first one has problems with being inconsistent in that it reports AGL under some and AGLS under different conditions. There is no real way to tell which is the expected behavior and this cannot be fixed if we want to keep backwards compatibility.
CBA_fnc_randPos is a function that isn't really needed anymore in A3. Instead you should use the alternative syntax of getPos:

_position getPos [random _radius, random 360]

https://community.bistudio.com/wiki/getPos#Alternative_Syntax

commy2 added a commit that referenced this issue Feb 10, 2017
@commy2
Copy link
Contributor

commy2 commented Feb 11, 2017

To get a uniform distribution:

_position getPos [_radius * sqrt (random 1), random 360]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants