src/unmovable_cmd.cpp
branchNewGRF_ports
changeset 6870 ca3fd1fbe311
parent 6868 7eb395287b3d
child 6871 5a9dc001e1ad
equal deleted inserted replaced
6869:76282d3b748d 6870:ca3fd1fbe311
    22 #include "unmovable_map.h"
    22 #include "unmovable_map.h"
    23 #include "variables.h"
    23 #include "variables.h"
    24 #include "table/unmovable_land.h"
    24 #include "table/unmovable_land.h"
    25 #include "genworld.h"
    25 #include "genworld.h"
    26 #include "bridge.h"
    26 #include "bridge.h"
       
    27 #include "autoslope.h"
    27 
    28 
    28 /** Destroy a HQ.
    29 /** Destroy a HQ.
    29  * During normal gameplay you can only implicitely destroy a HQ when you are
    30  * During normal gameplay you can only implicitely destroy a HQ when you are
    30  * rebuilding it. Otherwise, only water can destroy it.
    31  * rebuilding it. Otherwise, only water can destroy it.
    31  * @param pid Player requesting the destruction of his HQ
    32  * @param pid Player requesting the destruction of his HQ
   108 	}
   109 	}
   109 
   110 
   110 	return cost;
   111 	return cost;
   111 }
   112 }
   112 
   113 
       
   114 static Foundation GetFoundation_Unmovable(TileIndex tile, Slope tileh);
       
   115 
   113 static void DrawTile_Unmovable(TileInfo *ti)
   116 static void DrawTile_Unmovable(TileInfo *ti)
   114 {
   117 {
   115 
   118 
   116 	switch (GetUnmovableType(ti->tile)) {
   119 	switch (GetUnmovableType(ti->tile)) {
   117 		case UNMOVABLE_TRANSMITTER:
   120 		case UNMOVABLE_TRANSMITTER:
   130 			);
   133 			);
   131 			break;
   134 			break;
   132 		}
   135 		}
   133 
   136 
   134 		case UNMOVABLE_STATUE:
   137 		case UNMOVABLE_STATUE:
       
   138 			/* This should prevent statues from sinking into the ground when on a slope. */
       
   139 			if (ti->tileh != SLOPE_FLAT) DrawFoundation(ti, GetFoundation_Unmovable(ti->tile, ti->tileh));
       
   140 
   135 			DrawGroundSprite(SPR_CONCRETE_GROUND, PAL_NONE);
   141 			DrawGroundSprite(SPR_CONCRETE_GROUND, PAL_NONE);
   136 
   142 
   137 			AddSortableSpriteToDraw(SPR_STATUE_COMPANY, PLAYER_SPRITE_COLOR(GetTileOwner(ti->tile)), ti->x, ti->y, 16, 16, 25, ti->z, HASBIT(_transparent_opt, TO_STRUCTURES));
   143 			AddSortableSpriteToDraw(SPR_STATUE_COMPANY, PLAYER_SPRITE_COLOR(GetTileOwner(ti->tile)), ti->x, ti->y, 16, 16, 25, ti->z, HASBIT(_transparent_opt, TO_STRUCTURES));
   138 			break;
   144 			break;
   139 
   145 
   140 		case UNMOVABLE_OWNED_LAND:
   146 		case UNMOVABLE_OWNED_LAND:
   141 			DrawClearLandTile(ti, 0);
   147 			DrawClearLandTile(ti, 0);
   142 
   148 
   143 			AddSortableSpriteToDraw(
   149 			AddSortableSpriteToDraw(
   144 				SPR_BOUGHT_LAND, PLAYER_SPRITE_COLOR(GetTileOwner(ti->tile)),
   150 				SPR_BOUGHT_LAND, PLAYER_SPRITE_COLOR(GetTileOwner(ti->tile)),
   145 				ti->x + TILE_SIZE / 2, ti->y + TILE_SIZE / 2, 1, 1, 10, GetSlopeZ(ti->x + TILE_SIZE / 2, ti->y + TILE_SIZE / 2)
   151 				ti->x + TILE_SIZE / 2, ti->y + TILE_SIZE / 2, 1, 1, BB_HEIGHT_UNDER_BRIDGE, GetSlopeZ(ti->x + TILE_SIZE / 2, ti->y + TILE_SIZE / 2)
   146 			);
   152 			);
   147 			DrawBridgeMiddle(ti);
   153 			DrawBridgeMiddle(ti);
   148 			break;
   154 			break;
   149 
   155 
   150 		default: {
   156 		default: {
   400 
   406 
   401 static CommandCost TerraformTile_Unmovable(TileIndex tile, uint32 flags, uint z_new, Slope tileh_new)
   407 static CommandCost TerraformTile_Unmovable(TileIndex tile, uint32 flags, uint z_new, Slope tileh_new)
   402 {
   408 {
   403 	/* Owned land remains unsold */
   409 	/* Owned land remains unsold */
   404 	if (IsOwnedLand(tile) && CheckTileOwnership(tile)) return CommandCost();
   410 	if (IsOwnedLand(tile) && CheckTileOwnership(tile)) return CommandCost();
       
   411 
       
   412 	if (AutoslopeEnabled() && (IsStatue(tile) || IsCompanyHQ(tile))) {
       
   413 		if (!IsSteepSlope(tileh_new) && (z_new + GetSlopeMaxZ(tileh_new) == GetTileMaxZ(tile))) return _price.terraform;
       
   414 	}
   405 
   415 
   406 	return DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
   416 	return DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
   407 }
   417 }
   408 
   418 
   409 extern const TileTypeProcs _tile_type_unmovable_procs = {
   419 extern const TileTypeProcs _tile_type_unmovable_procs = {