Skip to content
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

Fix: allow input of numbers greater than INT32_MAX for GiveMoney #8499

Merged
merged 1 commit into from Jan 5, 2021

Conversation

TrueBrain
Copy link
Member

Fixes #7750.

Motivation / Problem

You could wire INT32_MAX+1 to another player, which resulted in -1, which is clamped to 0. The expectation of course is to wire the upper-bound, 20,000,000.

Description

Based on patch by JGR. Basically, use strtoull to parse string to int, instead of atoi.

Now no matter what you input, it is converted to an unsigned long, and casted into Money, meaning it will max-out (instead of bottom-out). Which is much more in line with what a player would expect.

Limitations

  • You can still wire 0 to another player. This was already the case, and this still is the case after this PR.

Checklist for review

Some things are not automated, and forgotten often. This list is a reminder for the reviewers.

  • The bug fix is important enough to be backported? (label: 'backport requested')
  • This PR affects the save game format? (label 'savegame upgrade')
  • This PR affects the GS/AI API? (label 'needs review: Script API')
    • ai_changelog.hpp, gs_changelog.hpp need updating.
    • The compatibility wrappers (compat_*.nut) need updating.
  • This PR affects the NewGRF API? (label 'needs review: NewGRF')

@TrueBrain TrueBrain merged commit f2fa2a1 into OpenTTD:master Jan 5, 2021
@TrueBrain TrueBrain deleted the you-like-money branch January 5, 2021 18:00
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.

Overflow issue when sending money in multiplayer
2 participants