clear_cmd.c
changeset 5385 3868f2e6db9b
parent 4815 d702c4027451
equal deleted inserted replaced
5384:10b6d955e1ac 5385:3868f2e6db9b
    10 #include "player.h"
    10 #include "player.h"
    11 #include "tile.h"
    11 #include "tile.h"
    12 #include "viewport.h"
    12 #include "viewport.h"
    13 #include "command.h"
    13 #include "command.h"
    14 #include "tunnel_map.h"
    14 #include "tunnel_map.h"
       
    15 #include "bridge_map.h"
    15 #include "variables.h"
    16 #include "variables.h"
    16 #include "table/sprites.h"
    17 #include "table/sprites.h"
    17 #include "unmovable_map.h"
    18 #include "unmovable_map.h"
    18 #include "genworld.h"
    19 #include "genworld.h"
    19 #include "industry.h"
    20 #include "industry.h"
   274 		if (!TerraformTileHeight(&ts, t, TileHeight(t) + direction)) {
   275 		if (!TerraformTileHeight(&ts, t, TileHeight(t) + direction)) {
   275 			return CMD_ERROR;
   276 			return CMD_ERROR;
   276 		}
   277 		}
   277 	}
   278 	}
   278 
   279 
   279 	if (direction == -1) {
   280 	{
   280 		/* Check if tunnel would take damage */
   281 		/* Check if tunnel would take damage */
   281 		int count;
   282 		int count;
   282 		TileIndex *ti = ts.tile_table;
   283 		TileIndex *ti = ts.tile_table;
   283 
   284 
   284 		for (count = ts.tile_table_count; count != 0; count--, ti++) {
   285 		for (count = ts.tile_table_count; count != 0; count--, ti++) {
   285 			uint z, t;
       
   286 			TileIndex tile = *ti;
   286 			TileIndex tile = *ti;
   287 
   287 
   288 			z = TerraformGetHeightOfTile(&ts, tile + TileDiffXY(0, 0));
   288 			if (MayHaveBridgeAbove(tile) && IsBridgeAbove(tile)) {
   289 			t = TerraformGetHeightOfTile(&ts, tile + TileDiffXY(1, 0));
   289 				return_cmd_error(STR_5007_MUST_DEMOLISH_BRIDGE_FIRST);
   290 			if (t <= z) z = t;
   290 			}
   291 			t = TerraformGetHeightOfTile(&ts, tile + TileDiffXY(1, 1));
   291 
   292 			if (t <= z) z = t;
   292 			if (direction == -1) {
   293 			t = TerraformGetHeightOfTile(&ts, tile + TileDiffXY(0, 1));
   293 				uint z, t;
   294 			if (t <= z) z = t;
   294 
   295 
   295 				z = TerraformGetHeightOfTile(&ts, tile + TileDiffXY(0, 0));
   296 			if (IsTunnelInWay(tile, z * TILE_HEIGHT)) {
   296 				t = TerraformGetHeightOfTile(&ts, tile + TileDiffXY(1, 0));
   297 				return_cmd_error(STR_1002_EXCAVATION_WOULD_DAMAGE);
   297 				if (t <= z) z = t;
       
   298 				t = TerraformGetHeightOfTile(&ts, tile + TileDiffXY(1, 1));
       
   299 				if (t <= z) z = t;
       
   300 				t = TerraformGetHeightOfTile(&ts, tile + TileDiffXY(0, 1));
       
   301 				if (t <= z) z = t;
       
   302 
       
   303 				if (IsTunnelInWay(tile, z * TILE_HEIGHT)) {
       
   304 					return_cmd_error(STR_1002_EXCAVATION_WOULD_DAMAGE);
       
   305 				}
   298 			}
   306 			}
   299 		}
   307 		}
   300 	}
   308 	}
   301 
   309 
   302 	if (flags & DC_EXEC) {
   310 	if (flags & DC_EXEC) {
   532 			DrawGroundSprite(_clear_land_sprites_3[GetClearDensity(ti->tile)] + _tileh_to_sprite[ti->tileh]);
   540 			DrawGroundSprite(_clear_land_sprites_3[GetClearDensity(ti->tile)] + _tileh_to_sprite[ti->tileh]);
   533 			break;
   541 			break;
   534 	}
   542 	}
   535 
   543 
   536 	DrawClearLandFence(ti);
   544 	DrawClearLandFence(ti);
       
   545 	DrawBridgeMiddle(ti);
   537 }
   546 }
   538 
   547 
   539 static uint GetSlopeZ_Clear(TileIndex tile, uint x, uint y)
   548 static uint GetSlopeZ_Clear(TileIndex tile, uint x, uint y)
   540 {
   549 {
   541 	uint z;
   550 	uint z;