src/clear_cmd.cpp
changeset 6718 ac9a2ab07d64
parent 6683 b88ae30866ce
child 6943 1914f26aee04
equal deleted inserted replaced
6717:804853737caa 6718:ac9a2ab07d64
   289 		TileIndex *ti = ts.tile_table;
   289 		TileIndex *ti = ts.tile_table;
   290 
   290 
   291 		for (count = ts.tile_table_count; count != 0; count--, ti++) {
   291 		for (count = ts.tile_table_count; count != 0; count--, ti++) {
   292 			TileIndex tile = *ti;
   292 			TileIndex tile = *ti;
   293 
   293 
   294 			if (MayHaveBridgeAbove(tile) && IsBridgeAbove(tile)) {
   294 			uint z_min = TerraformGetHeightOfTile(&ts, tile + TileDiffXY(0, 0));
       
   295 			uint z_max = z_min;
       
   296 			uint t = TerraformGetHeightOfTile(&ts, tile + TileDiffXY(1, 0));
       
   297 			z_min = min(z_min, t);
       
   298 			z_max = max(z_max, t);
       
   299 			t = TerraformGetHeightOfTile(&ts, tile + TileDiffXY(1, 1));
       
   300 			z_min = min(z_min, t);
       
   301 			z_max = max(z_max, t);
       
   302 			t = TerraformGetHeightOfTile(&ts, tile + TileDiffXY(0, 1));
       
   303 			z_min = min(z_min, t);
       
   304 			z_max = max(z_max, t);
       
   305 
       
   306 			if (direction == 1 && MayHaveBridgeAbove(tile) && IsBridgeAbove(tile) &&
       
   307 					GetBridgeHeight(GetSouthernBridgeEnd(tile)) <= z_max * TILE_HEIGHT) {
   295 				return_cmd_error(STR_5007_MUST_DEMOLISH_BRIDGE_FIRST);
   308 				return_cmd_error(STR_5007_MUST_DEMOLISH_BRIDGE_FIRST);
   296 			}
   309 			}
   297 
   310 			if (direction == -1 && IsTunnelInWay(tile, z_min * TILE_HEIGHT)) {
   298 			if (direction == -1) {
   311 				return_cmd_error(STR_1002_EXCAVATION_WOULD_DAMAGE);
   299 				uint z, t;
       
   300 
       
   301 				z = TerraformGetHeightOfTile(&ts, tile + TileDiffXY(0, 0));
       
   302 				t = TerraformGetHeightOfTile(&ts, tile + TileDiffXY(1, 0));
       
   303 				if (t <= z) z = t;
       
   304 				t = TerraformGetHeightOfTile(&ts, tile + TileDiffXY(1, 1));
       
   305 				if (t <= z) z = t;
       
   306 				t = TerraformGetHeightOfTile(&ts, tile + TileDiffXY(0, 1));
       
   307 				if (t <= z) z = t;
       
   308 
       
   309 				if (IsTunnelInWay(tile, z * TILE_HEIGHT)) {
       
   310 					return_cmd_error(STR_1002_EXCAVATION_WOULD_DAMAGE);
       
   311 				}
       
   312 			}
   312 			}
   313 		}
   313 		}
   314 	}
   314 	}
   315 
   315 
   316 	if (flags & DC_EXEC) {
   316 	if (flags & DC_EXEC) {