OpenTTD / OpenTTD/OpenTTD

[Bug]: Articulated vehicle bug

Open
#10,193 7 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
C++
Stars
8.3k
Forks
1.3k
Avg merge
1d 20h
Merged PRs (30d)
37

Description

Version of OpenTTD

12.2

Expected result

Articulated train-car of 1+6+1 length should reverse normally

Savegame:
Articulated_vehicle_bug.zip
GRF and sourcefile:
https://github.com/Yozora3/JPplusMetro

Actual result

When articulated train-car of 1+6+1 length is reversed, bounding box flips, causing the graphical bug

Steps to reproduce
  1. Load the savegame with provided GRF file
  2. Reverse the train on the exact position
Possible causes

Pruple
I can confirm that in the grf posted the bounding boxes move when reversing the train...
happens with vehicles from some other grfs too, with certain train vehicle combinations.
Yozora
I have another articulated train with 1+7+1 combination that works perfect
Pruple
does it depend on the length of the train?
Yozora
I think it's connected to odd\even numbers of the middle articulated section
With developer tools I can see that 1+7+1 bounding box is in the middle, while 1+6+1 the position changes with direction of the train
Pruple
there's definitely some rounding error with certain combinations of vehicle lengths and how it calculates where to position the other end of the consist when reversing. 6-6-8 jumps, 6-8-6 doesn't.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by loading the provided Articulated_vehicle_bug.zip savegame with the JPplusMetro GRF, then reproduce the reversal at the exact position described. Compare the bounding-box position for the 1+6+1 and 1+7+1 articulated trains, including the 6-6-8 and 6-8-6 combinations mentioned in the discussion. Done means reversing these combinations no longer causes the bounding box to move or the graphical bug to appear.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
game-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.