Index: station_cmd.c =================================================================== --- station_cmd.c (revision 7130) +++ station_cmd.c (working copy) @@ -220,24 +220,23 @@ static bool CheckStationSpreadOut(Station *st, TileIndex tile, int w, int h) { - StationID station_index = st->index; - uint i; - uint x1 = TileX(tile); - uint y1 = TileY(tile); - uint x2 = x1 + w - 1; - uint y2 = y1 + h - 1; + TileIndex stationTile = st->xy; + uint x1 = TileX(stationTile); + uint y1 = TileY(stationTile); + uint x2 = TileX(tile); + uint y2 = TileY(tile); uint t; + + if (x2 < x1) { // The tile we are checking is before the station + t = x2; + x2 = x1; + x1 = t; + } - for (i = 0; i != MapSize(); i++) { - if (IsTileType(i, MP_STATION) && _m[i].m2 == station_index) { - t = TileX(i); - if (t < x1) x1 = t; - if (t > x2) x2 = t; - - t = TileY(i); - if (t < y1) y1 = t; - if (t > y2) y2 = t; - } + if (y2 < y1) { // The tile we are checking is before the station + t = y2; + y2 = y1; + y1 = t; } if (y2 - y1 >= _patches.station_spread || x2 - x1 >= _patches.station_spread) {