Changeset - r16741:f602dc909b5e
[Not reviewed]
master
0 1 0
rubidium - 14 years ago 2010-12-12 18:05:34
rubidium@openttd.org
(svn r21484) -Codechange: use TILE_AREA_LOOP in CommonRaiseLowerBigLand
1 file changed with 8 insertions and 11 deletions:
0 comments (0 inline, 0 general)
src/terraform_gui.cpp
Show inline comments
 
@@ -393,45 +393,42 @@ static byte _terraform_size = 1;
 
 *         larger chunks at the same time OR remove altogether, as we have 'level land' ?
 
 * @param tile The top-left tile where the terraforming will start
 
 * @param mode 1 for raising, 0 for lowering land
 
 */
 
static void CommonRaiseLowerBigLand(TileIndex tile, int mode)
 
{
 
	int sizex, sizey;
 
	uint h;
 

	
 
	if (_terraform_size == 1) {
 
		StringID msg =
 
			mode ? STR_ERROR_CAN_T_RAISE_LAND_HERE : STR_ERROR_CAN_T_LOWER_LAND_HERE;
 

	
 
		DoCommandP(tile, SLOPE_N, (uint32)mode, CMD_TERRAFORM_LAND | CMD_MSG(msg), CcTerraform);
 
	} else {
 
		assert(_terraform_size != 0);
 
		/* check out for map overflows */
 
		sizex = min(MapSizeX() - TileX(tile), _terraform_size);
 
		sizey = min(MapSizeY() - TileY(tile), _terraform_size);
 
		TileArea ta(tile, _terraform_size, _terraform_size);
 
		ta.ClampToMap();
 

	
 
		if (sizex == 0 || sizey == 0) return;
 
		if (ta.w == 0 || ta.h == 0) return;
 

	
 
		SndPlayTileFx(SND_1F_SPLAT, tile);
 

	
 
		uint h;
 
		if (mode != 0) {
 
			/* Raise land */
 
			h = 15; // XXX - max height
 
			TILE_LOOP(tile2, sizex, sizey, tile) {
 
			h = MAX_TILE_HEIGHT;
 
			TILE_AREA_LOOP(tile2, ta) {
 
				h = min(h, TileHeight(tile2));
 
			}
 
		} else {
 
			/* Lower land */
 
			h = 0;
 
			TILE_LOOP(tile2, sizex, sizey, tile) {
 
			TILE_AREA_LOOP(tile2, ta) {
 
				h = max(h, TileHeight(tile2));
 
			}
 
		}
 

	
 
		TILE_LOOP(tile2, sizex, sizey, tile) {
 
		TILE_AREA_LOOP(tile2, ta) {
 
			if (TileHeight(tile2) == h) {
 
				DoCommandP(tile2, SLOPE_N, (uint32)mode, CMD_TERRAFORM_LAND);
 
			}
 
		}
 
	}
 
}
0 comments (0 inline, 0 general)