mirror of https://github.com/OpenTTD/OpenTTD
(svn r21484) -Codechange: use TILE_AREA_LOOP in CommonRaiseLowerBigLand
parent
15b4941401
commit
02451d8af6
|
@ -396,9 +396,6 @@ static byte _terraform_size = 1;
|
||||||
*/
|
*/
|
||||||
static void CommonRaiseLowerBigLand(TileIndex tile, int mode)
|
static void CommonRaiseLowerBigLand(TileIndex tile, int mode)
|
||||||
{
|
{
|
||||||
int sizex, sizey;
|
|
||||||
uint h;
|
|
||||||
|
|
||||||
if (_terraform_size == 1) {
|
if (_terraform_size == 1) {
|
||||||
StringID msg =
|
StringID msg =
|
||||||
mode ? STR_ERROR_CAN_T_RAISE_LAND_HERE : STR_ERROR_CAN_T_LOWER_LAND_HERE;
|
mode ? STR_ERROR_CAN_T_RAISE_LAND_HERE : STR_ERROR_CAN_T_LOWER_LAND_HERE;
|
||||||
|
@ -406,29 +403,29 @@ static void CommonRaiseLowerBigLand(TileIndex tile, int mode)
|
||||||
DoCommandP(tile, SLOPE_N, (uint32)mode, CMD_TERRAFORM_LAND | CMD_MSG(msg), CcTerraform);
|
DoCommandP(tile, SLOPE_N, (uint32)mode, CMD_TERRAFORM_LAND | CMD_MSG(msg), CcTerraform);
|
||||||
} else {
|
} else {
|
||||||
assert(_terraform_size != 0);
|
assert(_terraform_size != 0);
|
||||||
/* check out for map overflows */
|
TileArea ta(tile, _terraform_size, _terraform_size);
|
||||||
sizex = min(MapSizeX() - TileX(tile), _terraform_size);
|
ta.ClampToMap();
|
||||||
sizey = min(MapSizeY() - TileY(tile), _terraform_size);
|
|
||||||
|
|
||||||
if (sizex == 0 || sizey == 0) return;
|
if (ta.w == 0 || ta.h == 0) return;
|
||||||
|
|
||||||
SndPlayTileFx(SND_1F_SPLAT, tile);
|
SndPlayTileFx(SND_1F_SPLAT, tile);
|
||||||
|
|
||||||
|
uint h;
|
||||||
if (mode != 0) {
|
if (mode != 0) {
|
||||||
/* Raise land */
|
/* Raise land */
|
||||||
h = 15; // XXX - max height
|
h = MAX_TILE_HEIGHT;
|
||||||
TILE_LOOP(tile2, sizex, sizey, tile) {
|
TILE_AREA_LOOP(tile2, ta) {
|
||||||
h = min(h, TileHeight(tile2));
|
h = min(h, TileHeight(tile2));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/* Lower land */
|
/* Lower land */
|
||||||
h = 0;
|
h = 0;
|
||||||
TILE_LOOP(tile2, sizex, sizey, tile) {
|
TILE_AREA_LOOP(tile2, ta) {
|
||||||
h = max(h, TileHeight(tile2));
|
h = max(h, TileHeight(tile2));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TILE_LOOP(tile2, sizex, sizey, tile) {
|
TILE_AREA_LOOP(tile2, ta) {
|
||||||
if (TileHeight(tile2) == h) {
|
if (TileHeight(tile2) == h) {
|
||||||
DoCommandP(tile2, SLOPE_N, (uint32)mode, CMD_TERRAFORM_LAND);
|
DoCommandP(tile2, SLOPE_N, (uint32)mode, CMD_TERRAFORM_LAND);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue