1
0
Fork 0

Fix: ScriptTile::PlantTreeRectangle does not check that the end tile is in bounds. (#13004)

If the starting tile is near the edge of the map, the width and height could overflow the map boundary.

In some cases this might result in a different area being planted than expected.
pull/13015/head
Peter Nelson 2024-10-19 20:52:02 +01:00 committed by GitHub
parent 9d2e07b1f6
commit 147ac56f11
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 2 additions and 1 deletions

View File

@ -297,7 +297,8 @@
EnforcePrecondition(false, ::IsValidTile(tile));
EnforcePrecondition(false, width >= 1 && width <= 20);
EnforcePrecondition(false, height >= 1 && height <= 20);
TileIndex end_tile = tile + ::TileDiffXY(width - 1, height - 1);
TileIndex end_tile = TileAddWrap(tile, width - 1, height - 1);
EnforcePrecondition(false, ::IsValidTile(end_tile));
return ScriptObject::Command<CMD_PLANT_TREE>::Do(tile, end_tile, TREE_INVALID, false);
}