Skip to content

isTerrainValid validation for terrain types table fails with multiple entries#45

Merged
mrSkortch merged 1 commit into
mrSkortch:developmentfrom
MorpheusXAUT:development
Jun 22, 2020
Merged

isTerrainValid validation for terrain types table fails with multiple entries#45
mrSkortch merged 1 commit into
mrSkortch:developmentfrom
MorpheusXAUT:development

Conversation

@MorpheusXAUT
Copy link
Copy Markdown
Contributor

Providing a table of terrain types compares the terrainTypes table index against DCS' SurfaceType enum values, always including the LAND surface type if more than one terrainType was provided.

Example:

-- _terrainPoint is a random point (vec2) on land, e.g. in the Caucasus mountains
mist.isTerrainValid(_terrainPoint, 'LAND') -- returns true
mist.isTerrainValid(_terrainPoint, 'WATER') -- returns false
mist.isTerrainValid(_terrainPoint, 'SHALLOW_WATER') -- returns false
mist.isTerrainValid(_terrainPoint, {'WATER', 'SHALLOW_WATER'}) -- return true, comparison with index of terrainTypes table matches 1, including SurfaceType.WATER in the types checked against

I assume the second check when validating the provided terrainTypes table is intended to allow the enum's values to be provided as well, e.g. as mist.isTerrainTypes(_terrainPoint, {'WATER', 3}), however the comparison incorrectly checks the table's index against the enum's values.
This PR fixes the comparison, checking the assummed intended terrainTypes value against the SurfaceType enum value.

Happy to provide a short demo mission/script to showcase the issue if required 😄

terrainTypes table index is no longer being compared with SurfaceType enum values, leading to incorrect type inclusions
@mrSkortch mrSkortch merged commit 50ddf1f into mrSkortch:development Jun 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants