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: don't allow free-wagon-chains to exceed max-train-length #8533

Merged
merged 1 commit into from Jan 11, 2021

Conversation

TrueBrain
Copy link
Member

@TrueBrain TrueBrain commented Jan 8, 2021

This doesn't fix #8295, but prevents any future AIs from ever getting in this state.

Motivation / Problem

In #8295 the AI created a very very very long free-wagon chain. This made me wonder why this was allowed. Trains are limited by a max length after all, so why not free-wagon chains?

This PR limits free-wagon chains under the same conditions trains are limited.

Description

This makes no sense, that a free-wagon-chain could be larger than
the maximum length of a train, as you cannot put an engine in
front of that anyway. And it prevents run-away AIs making very
silly long free-wagon-chains.

Limitations

  • Ideally, it would stop just before the train limit, so you can always put an engine in front of it. But as this limit is based on pixel-length, and engines can have all sorts of lengths, I made the choice not to do that.

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')

src/train_cmd.cpp Outdated Show resolved Hide resolved
src/train_cmd.cpp Outdated Show resolved Hide resolved
This makes no sense, that a free-wagon-chain could be larger than
the maximum length of a train, as you cannot put an engine in
front of that anyway. And it prevents run-away AIs making very
silly long free-wagon-chains.
@TrueBrain TrueBrain added this to the 1.11.0 milestone Jan 8, 2021
@TrueBrain TrueBrain merged commit cd36e17 into OpenTTD:master Jan 11, 2021
@TrueBrain TrueBrain deleted the max-free-chain branch January 11, 2021 19:58
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.

None yet

3 participants