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

Incorrect autoreplace behaviour when temporary free-wagon chains exceed the train length limit #9264

Closed
JGRennison opened this issue May 14, 2021 · 1 comment

Comments

@JGRennison
Copy link
Contributor

Version of OpenTTD

1da0ba9

Expected result

Autoreplace operates correctly.

Actual result

Autoreplace operates incorrectly when a free-wagon chain is created that temporarily exceeds the train length limit by more a vehicle length, such that attempts to sell or move a vehicle in the free wagon chain fail as the remaining chain length still exceeds the limit.

This can manifest as:

  • If wagon removal is off, an ever-growing wagon chain which the player is not charged for can be created by requesting an autoreplace of short wagons with long ones. (See group A in the save).
  • If wagon removal is on, an assertion failure can be triggered if the depot already contains a free wagon chain of the maximum length. (See group B in the save).
    assert(ret.Succeeded());
  • Otherwise valid autoreplace operations can be blocked with a train too long error message if the depot already contains a free wagon chain of the maximum length. (See groups C vs D in the save).

Steps to reproduce

Autoreplace Testing Ltd, 1980-03-12.sav.zip

@James103
Copy link
Contributor

Also for the case of group A, the "infinite free wagons" trick can and will reduce the game to <1 TPS and <1 FPS after some time has passed. The same trick can even cause the same crash as in #8295 (stack overflow in Vehicle::PreDestructor), which the free wagon chain limit was supposed to protect against.

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

2 participants