summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCharles Pigott <charlespigott@googlemail.com>2021-08-31 21:40:59 +0100
committerCharles Pigott <charlespigott@googlemail.com>2021-09-11 23:10:50 +0100
commitd4588df9f9f7efd534c73e9170fb51f112bf676f (patch)
tree647a4a049b7549094e921c4d2ec1d50707c1a5bf /src
parent16dca0d7bc7a16f97067eb24722a90928b76efb5 (diff)
downloadopenttd-d4588df9f9f7efd534c73e9170fb51f112bf676f.tar.xz
Fix #9527: Crash when trying to place multitile objects at map edge
Diffstat (limited to 'src')
-rw-r--r--src/object_cmd.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/object_cmd.cpp b/src/object_cmd.cpp
index 556e5af5c..dc517dc5f 100644
--- a/src/object_cmd.cpp
+++ b/src/object_cmd.cpp
@@ -220,6 +220,9 @@ CommandCost CmdBuildObject(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
int size_x = GB(spec->size, HasBit(view, 0) ? 4 : 0, 4);
int size_y = GB(spec->size, HasBit(view, 0) ? 0 : 4, 4);
TileArea ta(tile, size_x, size_y);
+ for (TileIndex t : ta) {
+ if (!IsValidTile(t)) return_cmd_error(STR_ERROR_TOO_CLOSE_TO_EDGE_OF_MAP_SUB); // Might be off the map
+ }
if (type == OBJECT_OWNED_LAND) {
/* Owned land is special as it can be placed on any slope. */