-
Notifications
You must be signed in to change notification settings - Fork 36
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
Suspected integer underflow when switch returns a negative number #196
Comments
A minimal reproducer would be beneficial (for regression testing, if nothing else) |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Yeah we need a test file, to at least check NFO output, and to test a fixed BTW after checking nml source, it seems binary and ternary ops use signed comparison, so the issue is at another level. |
Test grf: nml_underflow.zip |
Ok I think I see the issue when looking at NFO
only 15bits of the return value are checked, and I think sign bit is dropped too. I think you can also confirm it's the issue by checking for 32766 (0x7FFE) without using |
Sorry for the late reply and thanks for the ping on the livestream. I forgot about this one. I can confirm that |
15 bit callback results strikes again? :) |
I am creating a house set which uses the
construction_check
callback to allow or deny construction based on a land value I calculate from various tile attributes. If I use a negative modifier, say a switch which checks if the tile is desert and returnsreturn: -2;
, the house is allowed to build even if I require a value of >=10000. As -2 is obviously not >= 10000, I believe this is an integer underflow caused by returning a negative value.I would be happy to build a simple GRF to demonstrate this, if requested.
The expected behavior, assuming a switch to a signed integer isn't feasible, would be for NMLC to return an error if the user attempts to return a negative number.
The text was updated successfully, but these errors were encountered: