Fix #10602: Error adding track scenery additions far from station start

Issue caused due to stuffing a temporary unsigned variable in a signed variable. This fix is not a permanent fix and this field in the future should be split up into two separate fields: tile position and relative tile position.

Co-authored-by: Gymnasiast <m.o.steenbeek@gmail.com>
This commit is contained in:
Duncan 2020-03-13 08:32:05 +00:00 committed by GitHub
parent de6e6e9d8f
commit 3003e1de75
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 1 deletions

View File

@ -528,7 +528,9 @@ rct_string_id TrackDesign::CreateTrackDesignScenery()
}
}
CoordsXY sceneryMapPos{ scenery.x * 32 - gTrackPreviewOrigin.x, scenery.y * 32 - gTrackPreviewOrigin.y };
// Cast the value into a uint8_t as this value is not signed yet.
auto sceneryPos = TileCoordsXY(static_cast<uint8_t>(scenery.x), static_cast<uint8_t>(scenery.y)).ToCoordsXY();
CoordsXY sceneryMapPos = sceneryPos - gTrackPreviewOrigin;
CoordsXY rotatedSceneryMapPos = sceneryMapPos.Rotate(0 - _saveDirection);
TileCoordsXY sceneryTilePos{ rotatedSceneryMapPos };