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);