From f34f329a539c3e7ae2eb3ec5599179fc40a67783 Mon Sep 17 00:00:00 2001 From: Jonathan G Rennison Date: Fri, 1 Mar 2019 18:40:07 +0000 Subject: [PATCH] Check that tile area is valid in CmdBuildRailStation --- src/station_cmd.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp index 4f313dc92f..b4456d4a8c 100644 --- a/src/station_cmd.cpp +++ b/src/station_cmd.cpp @@ -1333,6 +1333,9 @@ CommandCost CmdBuildRailStation(TileIndex tile_org, DoCommandFlag flags, uint32 w_org = numtracks; } + /* Check if the first tile and the last tile are valid */ + if (!IsValidTile(tile_org) || TileAddWrap(tile_org, w_org - 1, h_org - 1) == INVALID_TILE) return CMD_ERROR; + bool reuse = (station_to_join != NEW_STATION); if (!reuse) station_to_join = INVALID_STATION; bool distant_join = (station_to_join != INVALID_STATION);