clear_cmd.c
changeset 3977 edb5b94e2094
parent 3933 a5f08e17f4a0
child 4000 bab1ebc37da0
equal deleted inserted replaced
3976:b52d2c1acc5c 3977:edb5b94e2094
     9 #include "player.h"
     9 #include "player.h"
    10 #include "tile.h"
    10 #include "tile.h"
    11 #include "viewport.h"
    11 #include "viewport.h"
    12 #include "command.h"
    12 #include "command.h"
    13 #include "tunnel_map.h"
    13 #include "tunnel_map.h"
    14 #include "bridge_map.h"
       
    15 #include "variables.h"
    14 #include "variables.h"
    16 #include "table/sprites.h"
    15 #include "table/sprites.h"
    17 #include "unmovable_map.h"
    16 #include "unmovable_map.h"
    18 
    17 
    19 typedef struct TerraformerHeightMod {
    18 typedef struct TerraformerHeightMod {
   256 
   255 
   257 				if (IsPlainRailTile(tile)) {
   256 				if (IsPlainRailTile(tile)) {
   258 					extern const TrackBits _valid_tileh_slopes[2][15];
   257 					extern const TrackBits _valid_tileh_slopes[2][15];
   259 					if (GetTrackBits(tile) & ~_valid_tileh_slopes[0][r]) return_cmd_error(STR_1008_MUST_REMOVE_RAILROAD_TRACK);
   258 					if (GetTrackBits(tile) & ~_valid_tileh_slopes[0][r]) return_cmd_error(STR_1008_MUST_REMOVE_RAILROAD_TRACK);
   260 				} else return_cmd_error(STR_5800_OBJECT_IN_THE_WAY);
   259 				} else return_cmd_error(STR_5800_OBJECT_IN_THE_WAY);
   261 			}
       
   262 
       
   263 			if (MayHaveBridgeAbove(tile) && IsBridgeAbove(tile)) {
       
   264 				byte height = GetBridgeHeight(GetNorthernBridgeEnd(tile), GetBridgeAxis(tile));
       
   265 
       
   266 				height /= TILE_HEIGHT;
       
   267 
       
   268 				if (a >= height || b >= height || c >= height || d >= height) return_cmd_error(STR_5007_MUST_DEMOLISH_BRIDGE_FIRST);
       
   269 			}
   260 			}
   270 
   261 
   271 			if (direction == -1 && IsTunnelInWay(tile, min)) return_cmd_error(STR_1002_EXCAVATION_WOULD_DAMAGE);
   262 			if (direction == -1 && IsTunnelInWay(tile, min)) return_cmd_error(STR_1002_EXCAVATION_WOULD_DAMAGE);
   272 
   263 
   273 			_terraform_err_tile = 0;
   264 			_terraform_err_tile = 0;
   508 			DrawGroundSprite(_clear_land_sprites_3[GetClearDensity(ti->tile)] + _tileh_to_sprite[ti->tileh]);
   499 			DrawGroundSprite(_clear_land_sprites_3[GetClearDensity(ti->tile)] + _tileh_to_sprite[ti->tileh]);
   509 			break;
   500 			break;
   510 	}
   501 	}
   511 
   502 
   512 	DrawClearLandFence(ti);
   503 	DrawClearLandFence(ti);
   513 	DrawBridgeMiddle(ti);
       
   514 }
   504 }
   515 
   505 
   516 static uint GetSlopeZ_Clear(const TileInfo* ti)
   506 static uint GetSlopeZ_Clear(const TileInfo* ti)
   517 {
   507 {
   518 	return GetPartialZ(ti->x & 0xF, ti->y & 0xF, ti->tileh) + ti->z;
   508 	return GetPartialZ(ti->x & 0xF, ti->y & 0xF, ti->tileh) + ti->z;