summaryrefslogtreecommitdiff
path: root/src/terraform_gui.cpp
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2010-12-12 18:05:34 +0000
committerrubidium <rubidium@openttd.org>2010-12-12 18:05:34 +0000
commit02451d8af609ba32f9bf0c61bb1726f7add2f62e (patch)
treef90f27d1e8f819ffab518c072b750069afd4b191 /src/terraform_gui.cpp
parent15b4941401f71657d08d0beb16bbeee864261916 (diff)
downloadopenttd-02451d8af609ba32f9bf0c61bb1726f7add2f62e.tar.xz
(svn r21484) -Codechange: use TILE_AREA_LOOP in CommonRaiseLowerBigLand
Diffstat (limited to 'src/terraform_gui.cpp')
-rw-r--r--src/terraform_gui.cpp19
1 files changed, 8 insertions, 11 deletions
diff --git a/src/terraform_gui.cpp b/src/terraform_gui.cpp
index 5f4d15a44..3c7dc199e 100644
--- a/src/terraform_gui.cpp
+++ b/src/terraform_gui.cpp
@@ -396,9 +396,6 @@ static byte _terraform_size = 1;
*/
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;
@@ -406,29 +403,29 @@ static void CommonRaiseLowerBigLand(TileIndex tile, int mode)
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);
}