Skip to content

Proper overflow handling#2734

Merged
7 commits merged intoEasyRPG:masterfrom
Ghabry:maniac/numbers
Mar 25, 2022
Merged

Proper overflow handling#2734
7 commits merged intoEasyRPG:masterfrom
Ghabry:maniac/numbers

Conversation

@Ghabry
Copy link
Member

@Ghabry Ghabry commented Feb 24, 2022

When variables overflow the value is now correctly clamped.

Mostly required by Maniac Patch because it uses the entire integer range but also broke with multiply in normal maker (see fixed issue).

Also implemented the "Input numbers via numpad" extension from newer Maniac versions.

Fix #2650

@Ghabry
Copy link
Member Author

Ghabry commented Feb 26, 2022

Undefined behaviour at its finest and only in release:
abs(INT_MIN) is again INT_MIN because it overflows and max(abs(INT_MAX), abs(INT_MIN)) returns a max value of INT_MIN... wtf?! :)

Changed to long long to ensure it fits ^^

@ghost ghost self-requested a review February 28, 2022 22:45
@ghost ghost added the Awaiting Rebase Pull requests with conflicting files due to former merge label Mar 24, 2022
@Ghabry Ghabry removed the Awaiting Rebase Pull requests with conflicting files due to former merge label Mar 24, 2022
@ghost ghost merged commit 5749e48 into EasyRPG:master Mar 25, 2022
@Ghabry Ghabry deleted the maniac/numbers branch May 29, 2022 16:07
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

Incorrect handling of overflow

1 participant