function Utils::AreOtherStationsNearby(tile, cargoClass, stationId) { local stationType = cargoClass == AICargo.CC_PASSENGERS ? AIStation.STATION_BUS_STOP : AIStation.STATION_TRUCK_STOP; //check if there are other stations squareSize squares nearby local squareSize = AIStation.GetCoverageRadius(stationType); if (stationId == null) { squareSize = squareSize * 2; } local square = AITileList(); if(!AIController.GetSetting("is_friendly")) { //dont care about enemy stations when is_friendly is off square.AddRectangle(Utils.getValidOffsetTile(tile, (-1) * squareSize, (-1) * squareSize), Utils.getValidOffsetTile(tile, squareSize, squareSize)); //if another road station of mine is nearby return true for(local tile = square.Begin(); square.HasNext(); tile = square.Next()) { if(Utils.isTileMyRoadStation(tile, cargoClass)) { //negate second expression to merge your stations return true; } } } else { square.AddRectangle(Utils.getValidOffsetTile(tile, (-1) * squareSize, (-1) * squareSize), Utils.getValidOffsetTile(tile, squareSize, squareSize)); //if any other station is nearby, except my own airports, return true for (local tile = square.Begin(); square.HasNext(); tile = square.Next()) { if(AITile.IsStationTile(tile)) { if (AITile.GetOwner(tile) != AICompany.ResolveCompanyID(AICompany.COMPANY_SELF)) { return true; } else { local stationTiles = AITileList_StationType(AIStation.GetStationID(tile), stationType); if (stationTiles.HasItem(tile)) { return true; } } } } } if(!((AITile.IsBuildable(tile) || AIRoad.IsRoadTile(tile)) && AITile.GetSlope(tile) == AITile.SLOPE_FLAT)) { return true; } return false; };