From 421d6daaf8688208044f763138e1e5b8d8973b06 Mon Sep 17 00:00:00 2001 From: Peter Nelson Date: Thu, 17 Oct 2024 22:17:49 +0100 Subject: [PATCH] Fix: ScriptTile::PlantTreeRectangle does not check that the end tile is in bounds. 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. --- src/script/api/script_tile.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/script/api/script_tile.cpp b/src/script/api/script_tile.cpp index e4286dd9f1..125b12d2ca 100644 --- a/src/script/api/script_tile.cpp +++ b/src/script/api/script_tile.cpp @@ -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::Do(tile, end_tile, TREE_INVALID, false); }