src/station_cmd.cpp
changeset 8377 23835ad7ab64
parent 8306 22e1344c5457
child 8386 bed99ec71cb0
equal deleted inserted replaced
8376:aab0b14b96e3 8377:23835ad7ab64
  1355 	/* Not allowed to build over this road */
  1355 	/* Not allowed to build over this road */
  1356 	if (build_over_road) {
  1356 	if (build_over_road) {
  1357 		if (IsTileOwner(tile, OWNER_TOWN) && !_patches.road_stop_on_town_road) return_cmd_error(STR_DRIVE_THROUGH_ERROR_ON_TOWN_ROAD);
  1357 		if (IsTileOwner(tile, OWNER_TOWN) && !_patches.road_stop_on_town_road) return_cmd_error(STR_DRIVE_THROUGH_ERROR_ON_TOWN_ROAD);
  1358 		if (GetRoadTileType(tile) != ROAD_TILE_NORMAL) return CMD_ERROR;
  1358 		if (GetRoadTileType(tile) != ROAD_TILE_NORMAL) return CMD_ERROR;
  1359 
  1359 
       
  1360 		RoadTypes cur_rts = GetRoadTypes(tile);
       
  1361 
       
  1362 		/* there is a road, check if we can build road+tram stop over it */
       
  1363 		if (HasBit(cur_rts, ROADTYPE_ROAD)) {
       
  1364 			Owner road_owner = GetRoadOwner(tile, ROADTYPE_ROAD);
       
  1365 			if (road_owner != OWNER_TOWN && road_owner != OWNER_NONE && !CheckOwnership(road_owner)) return CMD_ERROR;
       
  1366 		}
       
  1367 
       
  1368 		/* there is a tram, check if we can build road+tram stop over it */
       
  1369 		if (HasBit(cur_rts, ROADTYPE_TRAM)) {
       
  1370 			Owner tram_owner = GetRoadOwner(tile, ROADTYPE_TRAM);
       
  1371 			if (tram_owner != OWNER_NONE && !CheckOwnership(tram_owner)) return CMD_ERROR;
       
  1372 		}
       
  1373 
  1360 		/* Don't allow building the roadstop when vehicles are already driving on it */
  1374 		/* Don't allow building the roadstop when vehicles are already driving on it */
  1361 		if (!EnsureNoVehicleOnGround(tile)) return CMD_ERROR;
  1375 		if (!EnsureNoVehicleOnGround(tile)) return CMD_ERROR;
  1362 
       
  1363 		RoadTypes cur_rts = GetRoadTypes(tile);
       
  1364 		if (GetRoadOwner(tile, ROADTYPE_ROAD) != OWNER_TOWN && HasBit(cur_rts, ROADTYPE_ROAD) && !CheckOwnership(GetRoadOwner(tile, ROADTYPE_ROAD))) return CMD_ERROR;
       
  1365 		if (HasBit(cur_rts, ROADTYPE_TRAM) && !CheckOwnership(GetRoadOwner(tile, ROADTYPE_TRAM))) return CMD_ERROR;
       
  1366 
  1376 
  1367 		/* Do not remove roadtypes! */
  1377 		/* Do not remove roadtypes! */
  1368 		rts |= cur_rts;
  1378 		rts |= cur_rts;
  1369 	}
  1379 	}
  1370 	cost = CheckFlatLandBelow(tile, 1, 1, flags, is_drive_through ? 5 << p1 : 1 << p1, NULL, !build_over_road);
  1380 	cost = CheckFlatLandBelow(tile, 1, 1, flags, is_drive_through ? 5 << p1 : 1 << p1, NULL, !build_over_road);