Fix .arm reading issue when world color exceeds [0, 1] range #2656
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR fixes #2650.
arm.utils.color_to_int()
is meant to convert a 4-component color into a 32 bit integer value (for direct use askha.Color
*) but it could happen that the resulting value was bigger than that. As a result, the integer would be exported as unsigned 64 bit in the .arm file and because the reader in Iron currently does not implement this (0xcf
prefix) the parser returned a wrong result.Haxe still doesn't seem to have a UInt64 type on all targets, and even the Int64 type is simulated on some platforms IIRC. Armory doesn't seem to use them at the moment, but should we still read two 32 bit integers in case of 64 bit numbers and output a garbage value just to make sure that the parser can continue correctly (+ output a warning)? It's then easier in the future to find any similar issues. I'm also not sure btw if the uint32 case is correctly implemented (it's using
readInt32()
), but I don't know of any issues with that.* this is why we can clamp the function's input value, it's only used for background clearing on the forward RP. Converting the return value into a 32 bit int would introduce overflow situations.