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

OpenTTD accepts negative / too-high starting years via -t command line parameter #9008

Closed
James103 opened this issue Apr 10, 2021 · 0 comments

Comments

@James103
Copy link
Contributor

James103 commented Apr 10, 2021

Version of OpenTTD

1.11.0, 2020-04-10 master, jgrpp-0.40.5, and all versions in-between/prior

Expected result

-t parameter is clamped to minimum value of 0 and a maximum value of 5000000.

Actual result

-t parameter accepts negative values (and values above 5000000) for the game starting year. When this happens and a new game is started, the following error is generated and (in case of dedicated server) the server aborts:
ERROR: Map generation aborted...?... no suitable town locations

Using the Scenario Editor, it is possible to generate save games that have a negative year in the date, such as that found in the following save games/scenarios:
negative year.zip

This can result in all sorts of undefined behavior, potentially leading to incorrect month names ("Vegetation -3458263" or "Top companies -1398716" or "[tooltip for an item] -5428763"), crashes/assertions (crash.zip), loan interest applying daily, broken temporal progression, etc.

Steps to reproduce

  1. Run openttd -D ::1 -t -4000 which attempts to start a game in the year -3996 (instead of -4000 due to incorrect year to date conversion).
  2. As no town buildings are able to spawn in years prior to the year 0, the map generation fails with ERROR: Map generation aborted...?... no suitable town locations.
  3. Run openttd -t -4000
  4. In game, open the console and run saveconfig then exit.
  5. Run openttd without -t.
  6. Notice that the starting year is properly clamped to 0.
rubidium42 added a commit to rubidium42/OpenTTD that referenced this issue Apr 11, 2021
…ting year

causing all sorts of weird behaviour and crashes in map generation.

Now just set the appropriate setting via IConsoleSetSetting so the validation
and, if needed, clamping is performed on the starting year value.
LordAro pushed a commit to LordAro/OpenTTD that referenced this issue Apr 17, 2021
…penTTD#9014)

An invalid starting year causes all sorts of weird behaviour and crashes in map generation.

Now just set the appropriate setting via IConsoleSetSetting so the validation
and, if needed, clamping is performed on the starting year value.
LordAro pushed a commit that referenced this issue Apr 18, 2021
An invalid starting year causes all sorts of weird behaviour and crashes in map generation.

Now just set the appropriate setting via IConsoleSetSetting so the validation
and, if needed, clamping is performed on the starting year value.
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

No branches or pull requests

1 participant