Page MenuHomeFeedback Tracker

Calling BIS_fnc_inTrigger resizes the input position array from 3 to 2.
New, WishlistPublic

Description

Calling BIS_fnc_inTrigger resizes the input position array from 3 to 2.

Details

Legacy ID
191334004
Severity
None
Resolution
Open
Reproducibility
Always
Category
Scripting
Steps To Reproduce
  1. Open Editor on VR map
  2. Place a standard trigger away from the player and name it "testTrigger"
  3. Place rifleman player unit on map
  4. Once in-game as player in the debug console input: "tPos = [0,0,0]; tPos2 = tPos; tReturn = [testTrigger, tPos] call BIS_fnc_inTrigger;"
  5. Add watches for the tPos and tPos2 variables, I expect tPos and tPos2 to equal [0,0,0] after executing this code
  6. Execute the code
  7. You'll see tPos and tPos2 are not equal to [0,0,0] as the use of the resize command has changed tPos and tPos2 to [0,0]

Event Timeline

JonBonsTAW set Category to Scripting.
JonBonsTAW set Reproducibility to Always.
JonBonsTAW set Severity to None.
JonBonsTAW set Resolution to Open.
JonBonsTAW set Legacy ID to 191334004.May 8 2016, 12:49 PM
JonBonsTAW added a subscriber: JonBonsTAW.

This appears to be because the BIS_fnc_inTrigger function utilizes the resize command which seems to be modifying all references to the array instead of making a copy and changing just that one variable.

If I execute this code: tPos = [0,0,0]; tPos2 = tPos; tPos resize 2;

I would expect tPos to equal [0,0] but I do not expect tPos2 to equal [0,0] as well.

A temporary fix for this is to make a copy of the array when setting tPos2.

Example: tPos = [0,0,0]; tPos2 = +tPos; tPos resize 2;

In the above example tPos is [0,0] and tPos2 is [0,0,0] which is what I expected from the examples above.

This behavior also happens with any engine commands that modify an array by reference.