File diff r18259:00667dab1f07 → r18260:9616113792ef
src/station_cmd.cpp
Show inline comments
 
@@ -643,49 +643,49 @@ static void DeleteStationIfEmpty(BaseSta
 
	/* station remains but it probably lost some parts - station sign should stay in the station boundaries */
 
	UpdateStationSignCoord(st);
 
}
 

	
 
CommandCost ClearTile_Station(TileIndex tile, DoCommandFlag flags);
 

	
 
/**
 
 * Checks if the given tile is buildable, flat and has a certain height.
 
 * @param tile TileIndex to check.
 
 * @param invalid_dirs Prohibited directions for slopes (set of #DiagDirection).
 
 * @param allowed_z Height allowed for the tile. If allowed_z is negative, it will be set to the height of this tile.
 
 * @param allow_steep Whether steep slopes are allowed.
 
 * @param check_bridge Check for the existance of a bridge.
 
 * @return The cost in case of success, or an error code if it failed.
 
 */
 
CommandCost CheckBuildableTile(TileIndex tile, uint invalid_dirs, int &allowed_z, bool allow_steep, bool check_bridge = true)
 
{
 
	if (check_bridge && MayHaveBridgeAbove(tile) && IsBridgeAbove(tile)) {
 
		return_cmd_error(STR_ERROR_MUST_DEMOLISH_BRIDGE_FIRST);
 
	}
 

	
 
	CommandCost ret = EnsureNoVehicleOnGround(tile);
 
	if (ret.Failed()) return ret;
 

	
 
	uint z;
 
	int z;
 
	Slope tileh = GetTileSlope(tile, &z);
 

	
 
	/* Prohibit building if
 
	 *   1) The tile is "steep" (i.e. stretches two height levels).
 
	 *   2) The tile is non-flat and the build_on_slopes switch is disabled.
 
	 */
 
	if ((!allow_steep && IsSteepSlope(tileh)) ||
 
			((!_settings_game.construction.build_on_slopes) && tileh != SLOPE_FLAT)) {
 
		return_cmd_error(STR_ERROR_FLAT_LAND_REQUIRED);
 
	}
 

	
 
	CommandCost cost(EXPENSES_CONSTRUCTION);
 
	int flat_z = z + GetSlopeMaxZ(tileh);
 
	if (tileh != SLOPE_FLAT) {
 
		/* Forbid building if the tile faces a slope in a invalid direction. */
 
		for (DiagDirection dir = DIAGDIR_BEGIN; dir != DIAGDIR_END; dir++) {
 
			if (HasBit(invalid_dirs, dir) && !CanBuildDepotByTileh(dir, tileh)) {
 
				return_cmd_error(STR_ERROR_FLAT_LAND_REQUIRED);
 
			}
 
		}
 
		cost.AddCost(_price[PR_BUILD_FOUNDATION]);
 
	}
 

	
 
	/* The level of this tile must be equal to allowed_z. */
 
@@ -2563,49 +2563,49 @@ static void DrawTile_Station(TileInfo *t
 
			case APT_GRASS_FENCE_NE_FLAG_2:
 
				t = &_station_display_datas_airport_flag_grass_fence_ne_2[GetAnimationFrame(ti->tile)];
 
				break;
 
		}
 
	}
 

	
 
	Owner owner = GetTileOwner(ti->tile);
 

	
 
	PaletteID palette;
 
	if (Company::IsValidID(owner)) {
 
		palette = COMPANY_SPRITE_COLOUR(owner);
 
	} else {
 
		/* Some stations are not owner by a company, namely oil rigs */
 
		palette = PALETTE_TO_GREY;
 
	}
 

	
 
	if (layout == NULL && (t == NULL || t->seq == NULL)) t = GetStationTileLayout(GetStationType(ti->tile), GetStationGfx(ti->tile));
 

	
 
	/* don't show foundation for docks */
 
	if (ti->tileh != SLOPE_FLAT && !IsDock(ti->tile)) {
 
		if (statspec != NULL && HasBit(statspec->flags, SSF_CUSTOM_FOUNDATIONS)) {
 
			/* Station has custom foundations.
 
			 * Check whether the foundation continues beyond the tile's upper sides. */
 
			uint edge_info = 0;
 
			uint z;
 
			int z;
 
			Slope slope = GetFoundationPixelSlope(ti->tile, &z);
 
			if (!HasFoundationNW(ti->tile, slope, z)) SetBit(edge_info, 0);
 
			if (!HasFoundationNE(ti->tile, slope, z)) SetBit(edge_info, 1);
 
			SpriteID image = GetCustomStationFoundationRelocation(statspec, st, ti->tile, tile_layout, edge_info);
 

	
 
			if (HasBit(statspec->flags, SSF_EXTENDED_FOUNDATIONS)) {
 
				/* Station provides extended foundations. */
 

	
 
				static const uint8 foundation_parts[] = {
 
					0, 0, 0, 0, // Invalid,  Invalid,   Invalid,   SLOPE_SW
 
					0, 1, 2, 3, // Invalid,  SLOPE_EW,  SLOPE_SE,  SLOPE_WSE
 
					0, 4, 5, 6, // Invalid,  SLOPE_NW,  SLOPE_NS,  SLOPE_NWS
 
					7, 8, 9     // SLOPE_NE, SLOPE_ENW, SLOPE_SEN
 
				};
 

	
 
				AddSortableSpriteToDraw(image + foundation_parts[ti->tileh], PAL_NONE, ti->x, ti->y, 16, 16, 7, ti->z);
 
			} else {
 
				/* Draw simple foundations, built up from 8 possible foundation sprites. */
 

	
 
				/* Each set bit represents one of the eight composite sprites to be drawn.
 
				 * 'Invalid' entries will not drawn but are included for completeness. */
 
				static const uint8 composite_foundation_parts[] = {
 
					/* Invalid  (00000000), Invalid   (11010001), Invalid   (11100100), SLOPE_SW  (11100000) */
 
					   0x00,                0xD1,                 0xE4,                 0xE0,