summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2009-07-26 21:50:30 +0000
committerrubidium <rubidium@openttd.org>2009-07-26 21:50:30 +0000
commit2ec12a3f587f4271a2d8ba5e22af233e1094e321 (patch)
tree114688ff4bf43f5c94891a3fa67b5b172d187323
parent47a37b6093c3bb93dba81e4d3440c4098699a849 (diff)
downloadopenttd-2ec12a3f587f4271a2d8ba5e22af233e1094e321.tar.xz
(svn r16966) -Codechange: BEGIN_TILE_LOOP and END_TILE_LOOP reworked into TILE_LOOP, which means no more duplication of parameters between BEGIN_TILE_LOOP and END_TILE_LOOP
-rw-r--r--src/ai/api/ai_industry.cpp8
-rw-r--r--src/ai/api/ai_order.cpp4
-rw-r--r--src/ai/api/ai_tilelist.cpp20
-rw-r--r--src/industry_cmd.cpp28
-rw-r--r--src/map_func.h22
-rw-r--r--src/newgrf_industrytiles.cpp8
-rw-r--r--src/station.cpp4
-rw-r--r--src/station_cmd.cpp24
-rw-r--r--src/station_gui.cpp4
-rw-r--r--src/terraform_cmd.cpp4
-rw-r--r--src/terraform_gui.cpp20
-rw-r--r--src/unmovable_cmd.cpp4
-rw-r--r--src/water_cmd.cpp8
13 files changed, 71 insertions, 87 deletions
diff --git a/src/ai/api/ai_industry.cpp b/src/ai/api/ai_industry.cpp
index 686a5d3fe..670fce050 100644
--- a/src/ai/api/ai_industry.cpp
+++ b/src/ai/api/ai_industry.cpp
@@ -142,11 +142,11 @@
if (!HasHeliport(industry_id)) return INVALID_TILE;
const Industry *ind = ::Industry::Get(industry_id);
- BEGIN_TILE_LOOP(tile_cur, ind->width, ind->height, ind->xy);
+ TILE_LOOP(tile_cur, ind->width, ind->height, ind->xy) {
if (IsTileType(tile_cur, MP_STATION) && IsOilRig(tile_cur)) {
return tile_cur;
}
- END_TILE_LOOP(tile_cur, ind->width, ind->height, ind->xy);
+ }
return INVALID_TILE;
}
@@ -164,11 +164,11 @@
if (!HasDock(industry_id)) return INVALID_TILE;
const Industry *ind = ::Industry::Get(industry_id);
- BEGIN_TILE_LOOP(tile_cur, ind->width, ind->height, ind->xy);
+ TILE_LOOP(tile_cur, ind->width, ind->height, ind->xy) {
if (IsTileType(tile_cur, MP_STATION) && IsOilRig(tile_cur)) {
return tile_cur;
}
- END_TILE_LOOP(tile_cur, ind->width, ind->height, ind->xy);
+ }
return INVALID_TILE;
}
diff --git a/src/ai/api/ai_order.cpp b/src/ai/api/ai_order.cpp
index fcf1658fe..50d94d346 100644
--- a/src/ai/api/ai_order.cpp
+++ b/src/ai/api/ai_order.cpp
@@ -192,9 +192,9 @@ static const Order *ResolveOrder(VehicleID vehicle_id, AIOrder::OrderPosition or
return st->truck_stops->xy;
} else if (st->airport_tile != INVALID_TILE) {
const AirportFTAClass *fta = st->Airport();
- BEGIN_TILE_LOOP(tile, fta->size_x, fta->size_y, st->airport_tile) {
+ TILE_LOOP(tile, fta->size_x, fta->size_y, st->airport_tile) {
if (!::IsHangar(tile)) return tile;
- } END_TILE_LOOP(tile, fta->size_x, fta->size_y, st->airport_tile)
+ }
}
return INVALID_TILE;
}
diff --git a/src/ai/api/ai_tilelist.cpp b/src/ai/api/ai_tilelist.cpp
index 587460a75..cdaaa9b95 100644
--- a/src/ai/api/ai_tilelist.cpp
+++ b/src/ai/api/ai_tilelist.cpp
@@ -34,9 +34,7 @@ void AITileList::AddRectangle(TileIndex t1, TileIndex t2)
uint w = TileX(t2) - TileX(t1) + 1;
uint h = TileY(t2) - TileY(t1) + 1;
- BEGIN_TILE_LOOP(t, w, h, t1) {
- this->AddItem(t);
- } END_TILE_LOOP(t, w, h, t1)
+ TILE_LOOP(t, w, h, t1) this->AddItem(t);
}
void AITileList::AddTile(TileIndex tile)
@@ -56,9 +54,7 @@ void AITileList::RemoveRectangle(TileIndex t1, TileIndex t2)
uint w = TileX(t2) - TileX(t1) + 1;
uint h = TileY(t2) - TileY(t1) + 1;
- BEGIN_TILE_LOOP(t, w, h, t1) {
- this->RemoveItem(t);
- } END_TILE_LOOP(t, w, h, t1)
+ TILE_LOOP(t, w, h, t1) this->RemoveItem(t);
}
void AITileList::RemoveTile(TileIndex tile)
@@ -85,7 +81,7 @@ AITileList_IndustryAccepting::AITileList_IndustryAccepting(IndustryID industry_i
if (!_settings_game.station.modified_catchment) radius = CA_UNMODIFIED;
- BEGIN_TILE_LOOP(cur_tile, i->width + radius * 2, i->height + radius * 2, i->xy - ::TileDiffXY(radius, radius)) {
+ TILE_LOOP(cur_tile, i->width + radius * 2, i->height + radius * 2, i->xy - ::TileDiffXY(radius, radius)) {
if (!::IsValidTile(cur_tile)) continue;
/* Exclude all tiles that belong to this industry */
if (::IsTileType(cur_tile, MP_INDUSTRY) && ::GetIndustryIndex(cur_tile) == industry_id) continue;
@@ -102,7 +98,7 @@ AITileList_IndustryAccepting::AITileList_IndustryAccepting(IndustryID industry_i
}
this->AddTile(cur_tile);
- } END_TILE_LOOP(cur_tile, i->width + radius * 2, i->height + radius * 2, i->xy - ::TileDiffXY(radius, radius))
+ }
}
AITileList_IndustryProducing::AITileList_IndustryProducing(IndustryID industry_id, int radius)
@@ -122,7 +118,7 @@ AITileList_IndustryProducing::AITileList_IndustryProducing(IndustryID industry_i
if (!_settings_game.station.modified_catchment) radius = CA_UNMODIFIED;
- BEGIN_TILE_LOOP(cur_tile, i->width + radius * 2, i->height + radius * 2, i->xy - ::TileDiffXY(radius, radius)) {
+ TILE_LOOP(cur_tile, i->width + radius * 2, i->height + radius * 2, i->xy - ::TileDiffXY(radius, radius)) {
if (!::IsValidTile(cur_tile)) continue;
/* Exclude all tiles that belong to this industry */
if (::IsTileType(cur_tile, MP_INDUSTRY) && ::GetIndustryIndex(cur_tile) == industry_id) continue;
@@ -139,7 +135,7 @@ AITileList_IndustryProducing::AITileList_IndustryProducing(IndustryID industry_i
}
this->AddTile(cur_tile);
- } END_TILE_LOOP(cur_tile, i->width + radius * 2, i->height + radius * 2, i->xy - ::TileDiffXY(radius, radius))
+ }
}
AITileList_StationType::AITileList_StationType(StationID station_id, AIStation::StationType station_type)
@@ -157,10 +153,10 @@ AITileList_StationType::AITileList_StationType(StationID station_id, AIStation::
if ((station_type & AIStation::STATION_AIRPORT) != 0) station_type_value |= (1 << ::STATION_AIRPORT) | (1 << ::STATION_OILRIG);
if ((station_type & AIStation::STATION_DOCK) != 0) station_type_value |= (1 << ::STATION_DOCK) | (1 << ::STATION_OILRIG);
- BEGIN_TILE_LOOP(cur_tile, rect->right - rect->left + 1, rect->bottom - rect->top + 1, ::TileXY(rect->left, rect->top)) {
+ TILE_LOOP(cur_tile, rect->right - rect->left + 1, rect->bottom - rect->top + 1, ::TileXY(rect->left, rect->top)) {
if (!::IsTileType(cur_tile, MP_STATION)) continue;
if (::GetStationIndex(cur_tile) != station_id) continue;
if (!HasBit(station_type_value, ::GetStationType(cur_tile))) continue;
this->AddTile(cur_tile);
- } END_TILE_LOOP(cur_tile, rect->right - rect->left + 1, rect->bottom - rect->top + 1, ::TileXY(rect->left, rect->top))
+ }
}
diff --git a/src/industry_cmd.cpp b/src/industry_cmd.cpp
index 9b16f57de..c9adb7734 100644
--- a/src/industry_cmd.cpp
+++ b/src/industry_cmd.cpp
@@ -136,7 +136,7 @@ Industry::~Industry()
* This means that we do not have to clear tiles either. */
if (this->width == 0) return;
- BEGIN_TILE_LOOP(tile_cur, this->width, this->height, this->xy);
+ TILE_LOOP(tile_cur, this->width, this->height, this->xy) {
if (IsTileType(tile_cur, MP_INDUSTRY)) {
if (GetIndustryIndex(tile_cur) == this->index) {
/* MakeWaterKeepingClass() can also handle 'land' */
@@ -149,17 +149,17 @@ Industry::~Industry()
} else if (IsTileType(tile_cur, MP_STATION) && IsOilRig(tile_cur)) {
DeleteOilRig(tile_cur);
}
- END_TILE_LOOP(tile_cur, this->width, this->height, this->xy);
+ }
if (GetIndustrySpec(this->type)->behaviour & INDUSTRYBEH_PLANT_FIELDS) {
/* Remove the farmland and convert it to regular tiles over time. */
- BEGIN_TILE_LOOP(tile_cur, 42, 42, this->xy - TileDiffXY(21, 21)) {
+ TILE_LOOP(tile_cur, 42, 42, this->xy - TileDiffXY(21, 21)) {
tile_cur = TILE_MASK(tile_cur);
if (IsTileType(tile_cur, MP_CLEAR) && IsClearGround(tile_cur, CLEAR_FIELDS) &&
GetIndustryIndexOfField(tile_cur) == this->index) {
SetIndustryIndexOfField(tile_cur, INVALID_INDUSTRY);
}
- } END_TILE_LOOP(tile_cur, 42, 42, this->xy - TileDiff(21, 21))
+ }
}
/* don't let any disaster vehicle target invalid industry */
@@ -957,10 +957,10 @@ static void PlantFarmField(TileIndex tile, IndustryID industry)
/* check the amount of bad tiles */
count = 0;
- BEGIN_TILE_LOOP(cur_tile, size_x, size_y, tile)
+ TILE_LOOP(cur_tile, size_x, size_y, tile) {
assert(cur_tile < MapSize());
count += IsBadFarmFieldTile(cur_tile);
- END_TILE_LOOP(cur_tile, size_x, size_y, tile)
+ }
if (count * 2 >= size_x * size_y) return;
/* determine type of field */
@@ -969,14 +969,14 @@ static void PlantFarmField(TileIndex tile, IndustryID industry)
field_type = GB(r, 8, 8) * 9 >> 8;
/* make field */
- BEGIN_TILE_LOOP(cur_tile, size_x, size_y, tile)
+ TILE_LOOP(cur_tile, size_x, size_y, tile) {
assert(cur_tile < MapSize());
if (!IsBadFarmFieldTile2(cur_tile)) {
MakeField(cur_tile, field_type, industry);
SetClearCounter(cur_tile, counter);
MarkTileDirtyByTile(cur_tile);
}
- END_TILE_LOOP(cur_tile, size_x, size_y, tile)
+ }
type = 3;
if (_settings_game.game_creation.landscape != LT_ARCTIC && _settings_game.game_creation.landscape != LT_TROPIC) {
@@ -1340,7 +1340,7 @@ static bool CheckCanTerraformSurroundingTiles(TileIndex tile, uint height, int i
if (TileX(tile) == 0 || TileY(tile) == 0 || GetTileType(tile) == MP_VOID) return false;
tile += TileDiffXY(-1, -1);
- BEGIN_TILE_LOOP(tile_walk, size_x, size_y, tile) {
+ TILE_LOOP(tile_walk, size_x, size_y, tile) {
curh = TileHeight(tile_walk);
/* Is the tile clear? */
if ((GetTileType(tile_walk) != MP_CLEAR) && (GetTileType(tile_walk) != MP_TREES))
@@ -1356,7 +1356,7 @@ static bool CheckCanTerraformSurroundingTiles(TileIndex tile, uint height, int i
if (TileX(tile_walk) == 0 || TileY(tile_walk) == 0 || !CheckCanTerraformSurroundingTiles(tile_walk + TileDiffXY(-1, -1), height, internal + 1))
return false;
}
- } END_TILE_LOOP(tile_walk, size_x, size_y, tile);
+ }
return true;
}
@@ -1399,7 +1399,7 @@ static bool CheckIfCanLevelIndustryPlatform(TileIndex tile, DoCommandFlag flags,
CompanyID old_company = _current_company;
_current_company = OWNER_TOWN;
- BEGIN_TILE_LOOP(tile_walk, size_x, size_y, cur_tile) {
+ TILE_LOOP(tile_walk, size_x, size_y, cur_tile) {
curh = TileHeight(tile_walk);
if (curh != h) {
/* This tile needs terraforming. Check if we can do that without
@@ -1415,11 +1415,11 @@ static bool CheckIfCanLevelIndustryPlatform(TileIndex tile, DoCommandFlag flags,
return false;
}
}
- } END_TILE_LOOP(tile_walk, size_x, size_y, cur_tile)
+ }
if (flags & DC_EXEC) {
/* Terraform the land under the industry */
- BEGIN_TILE_LOOP(tile_walk, size_x, size_y, cur_tile) {
+ TILE_LOOP(tile_walk, size_x, size_y, cur_tile) {
curh = TileHeight(tile_walk);
while (curh != h) {
/* We give the terraforming for free here, because we can't calculate
@@ -1428,7 +1428,7 @@ static bool CheckIfCanLevelIndustryPlatform(TileIndex tile, DoCommandFlag flags,
DoCommand(tile_walk, SLOPE_N, (curh > h) ? 0 : 1, flags, CMD_TERRAFORM_LAND);
curh += (curh > h) ? -1 : 1;
}
- } END_TILE_LOOP(tile_walk, size_x, size_y, cur_tile)
+ }
}
_current_company = old_company;
diff --git a/src/map_func.h b/src/map_func.h
index 1deafc00c..09bbc462d 100644
--- a/src/map_func.h
+++ b/src/map_func.h
@@ -327,7 +327,7 @@ uint DistanceMaxPlusManhattan(TileIndex, TileIndex); ///< Max + Manhattan
uint DistanceFromEdge(TileIndex); ///< shortest distance from any edge of the map
/**
- * Starts a loop which iterates to a square of tiles
+ * A loop which iterates to a square of tiles
*
* This macro starts 2 nested loops which iterates over a square of tiles.
*
@@ -336,22 +336,10 @@ uint DistanceFromEdge(TileIndex); ///< shortest distance from any edge of the ma
* @param h The heigth (y-width) of the square
* @param tile The start tile of the square
*/
-#define BEGIN_TILE_LOOP(var, w, h, tile) \
- { \
- int h_cur = h; \
- uint var = tile; \
- do { \
- int w_cur = w; \
- do {
-/**
- * Ends the square-loop used before
- *
- * @see BEGIN_TILE_LOOP
- */
-#define END_TILE_LOOP(var, w, h, tile) \
- } while (++var, --w_cur != 0); \
- } while (var += TileDiffXY(0, 1) - (w), --h_cur != 0); \
- }
+#define TILE_LOOP(var, w, h, tile) \
+ for (uint var = tile, cur_h = (h); cur_h > 0; --cur_h, var += TileDiffXY(0, 1) - (w)) \
+ for (uint cur_w = (w); cur_w > 0; --cur_w, var++)
+
/**
* Convert a DiagDirection to a TileIndexDiff
*
diff --git a/src/newgrf_industrytiles.cpp b/src/newgrf_industrytiles.cpp
index 89c4a0279..1a6537c22 100644
--- a/src/newgrf_industrytiles.cpp
+++ b/src/newgrf_industrytiles.cpp
@@ -389,7 +389,7 @@ bool StartStopIndustryTileAnimation(const Industry *ind, IndustryAnimationTrigge
{
bool ret = true;
uint32 random = Random();
- BEGIN_TILE_LOOP(tile, ind->width, ind->height, ind->xy)
+ TILE_LOOP(tile, ind->width, ind->height, ind->xy) {
if (IsTileType(tile, MP_INDUSTRY) && GetIndustryIndex(tile) == ind->index) {
if (StartStopIndustryTileAnimation(tile, iat, random)) {
SB(random, 0, 16, Random());
@@ -397,7 +397,7 @@ bool StartStopIndustryTileAnimation(const Industry *ind, IndustryAnimationTrigge
ret = false;
}
}
- END_TILE_LOOP(tile, ind->width, ind->height, ind->xy)
+ }
return ret;
}
@@ -433,9 +433,9 @@ void TriggerIndustryTile(TileIndex tile, IndustryTileTrigger trigger)
void TriggerIndustry(Industry *ind, IndustryTileTrigger trigger)
{
- BEGIN_TILE_LOOP(tile, ind->width, ind->height, ind->xy)
+ TILE_LOOP(tile, ind->width, ind->height, ind->xy) {
if (IsTileType(tile, MP_INDUSTRY) && GetIndustryIndex(tile) == ind->index) {
DoTriggerIndustryTile(tile, trigger, ind);
}
- END_TILE_LOOP(tile, ind->width, ind->height, ind->xy)
+ }
}
diff --git a/src/station.cpp b/src/station.cpp
index 84c7efb60..89064f77a 100644
--- a/src/station.cpp
+++ b/src/station.cpp
@@ -415,9 +415,9 @@ bool StationRect::BeforeAddRect(TileIndex tile, int w, int h, StationRectMode mo
int width = right_a - left_a + 1;
int height = bottom_a - top_a + 1;
- BEGIN_TILE_LOOP(tile, width, height, top_left)
+ TILE_LOOP(tile, width, height, top_left) {
if (IsTileType(tile, MP_STATION) && GetStationIndex(tile) == st_id) return true;
- END_TILE_LOOP(tile, width, height, top_left);
+ }
return false;
}
diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp
index 6c783780a..4efd77ca5 100644
--- a/src/station_cmd.cpp
+++ b/src/station_cmd.cpp
@@ -76,7 +76,7 @@ static uint GetNumRoadStopsInStation(const Station *st, RoadStopType type)
static Station *GetStationAround(TileIndex tile, int w, int h, StationID closest_station)
{
/* check around to see if there's any stations there */
- BEGIN_TILE_LOOP(tile_cur, w + 2, h + 2, tile - TileDiffXY(1, 1))
+ TILE_LOOP(tile_cur, w + 2, h + 2, tile - TileDiffXY(1, 1)) {
if (IsTileType(tile_cur, MP_STATION)) {
StationID t = GetStationIndex(tile_cur);
@@ -87,7 +87,7 @@ static Station *GetStationAround(TileIndex tile, int w, int h, StationID closest
return CHECK_STATIONS_ERR;
}
}
- END_TILE_LOOP(tile_cur, w + 2, h + 2, tile - TileDiffXY(1, 1))
+ }
return (closest_station == INVALID_STATION) ? NULL : Station::Get(closest_station);
}
@@ -649,7 +649,7 @@ CommandCost CheckFlatLandBelow(TileIndex tile, uint w, uint h, DoCommandFlag fla
CommandCost cost(EXPENSES_CONSTRUCTION);
int allowed_z = -1;
- BEGIN_TILE_LOOP(tile_cur, w, h, tile) {
+ TILE_LOOP(tile_cur, w, h, tile) {
if (MayHaveBridgeAbove(tile_cur) && IsBridgeAbove(tile_cur)) {
return_cmd_error(STR_ERROR_MUST_DEMOLISH_BRIDGE_FIRST);
}
@@ -709,7 +709,7 @@ CommandCost CheckFlatLandBelow(TileIndex tile, uint w, uint h, DoCommandFlag fla
if (CmdFailed(ret)) return ret;
cost.AddCost(ret);
}
- } END_TILE_LOOP(tile_cur, w, h, tile)
+ }
return cost;
}
@@ -735,12 +735,12 @@ static bool CanExpandRailStation(const Station *st, TileArea &cur_ta, Axis axis)
} else {
/* do not allow modifying non-uniform stations,
* the uniform-stations code wouldn't handle it well */
- BEGIN_TILE_LOOP(t, st->train_station.w, st->train_station.h, st->train_station.tile)
+ TILE_LOOP(t, st->train_station.w, st->train_station.h, st->train_station.tile) {
if (!st->TileBelongsToRailStation(t)) { // there may be adjoined station
_error_message = STR_NONUNIFORM_STATIONS_DISALLOWED;
return false;
}
- END_TILE_LOOP(t, st->train_station.w, st->train_station.h, st->train_station.tile)
+ }
/* check so the orientation is the same */
if (GetRailStationAxis(st->train_station.tile) != axis) {
@@ -1147,7 +1147,7 @@ CommandCost CmdRemoveFromRailroadStation(TileIndex tile, DoCommandFlag flags, ui
SmallVector<Station *, 4> affected_stations;
/* Do the action for every tile into the area */
- BEGIN_TILE_LOOP(tile2, size_x, size_y, tile) {
+ TILE_LOOP(tile2, size_x, size_y, tile) {
/* Make sure the specified tile is a railroad station */
if (!IsRailStationTile(tile2)) {
continue;
@@ -1208,7 +1208,7 @@ CommandCost CmdRemoveFromRailroadStation(TileIndex tile, DoCommandFlag flags, ui
if (IsRailStationTile(v->tile)) SetRailStationPlatformReservation(v->tile, TrackdirToExitdir(ReverseTrackdir(v->GetVehicleTrackdir())), true);
}
}
- } END_TILE_LOOP(tile2, size_x, size_y, tile)
+ }
for (Station **stp = affected_stations.Begin(); stp != affected_stations.End(); stp++) {
Station *st = *stp;
@@ -1837,10 +1837,10 @@ CommandCost CmdBuildAirport(TileIndex tile, DoCommandFlag flags, uint32 p1, uint
{
const byte *b = _airport_sections[p1];
- BEGIN_TILE_LOOP(tile_cur, w, h, tile) {
+ TILE_LOOP(tile_cur, w, h, tile) {
MakeAirport(tile_cur, st->owner, st->index, *b);
b++;
- } END_TILE_LOOP(tile_cur, w, h, tile)
+ }
}
st->UpdateVirtCoord();
@@ -1886,14 +1886,14 @@ static CommandCost RemoveAirport(TileIndex tile, DoCommandFlag flags)
if (a->targetairport == st->index && a->state != FLYING) return CMD_ERROR;
}
- BEGIN_TILE_LOOP(tile_cur, w, h, tile) {
+ TILE_LOOP(tile_cur, w, h, tile) {
if (!EnsureNoVehicleOnGround(tile_cur)) return CMD_ERROR;
if (flags & DC_EXEC) {
DeleteAnimatedTile(tile_cur);
DoClearSquare(tile_cur);
}
- } END_TILE_LOOP(tile_cur, w, h, tile)
+ }
if (flags & DC_EXEC) {
for (uint i = 0; i < afc->nof_depots; ++i) {
diff --git a/src/station_gui.cpp b/src/station_gui.cpp
index 3e171b687..326e50661 100644
--- a/src/station_gui.cpp
+++ b/src/station_gui.cpp
@@ -1132,9 +1132,9 @@ static const Station *FindStationsNearby(TileArea ta, bool distant_join)
_deleted_stations_nearby.Clear();
/* Check the inside, to return, if we sit on another station */
- BEGIN_TILE_LOOP(t, ta.w, ta.h, ta.tile)
+ TILE_LOOP(t, ta.w, ta.h, ta.tile) {
if (t < MapSize() && IsTileType(t, MP_STATION) && Station::IsValidID(GetStationIndex(t))) return Station::GetByTile(t);
- END_TILE_LOOP(t, ta.w, ta.h, ta.tile)
+ }
/* Look for deleted stations */
const BaseStation *st;
diff --git a/src/terraform_cmd.cpp b/src/terraform_cmd.cpp
index adbbdedf7..34b7e19fa 100644
--- a/src/terraform_cmd.cpp
+++ b/src/terraform_cmd.cpp
@@ -385,7 +385,7 @@ CommandCost CmdLevelLand(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32
Money money = GetAvailableMoneyForCommand();
CommandCost cost(EXPENSES_CONSTRUCTION);
- BEGIN_TILE_LOOP(tile2, size_x, size_y, tile) {
+ TILE_LOOP(tile2, size_x, size_y, tile) {
uint curh = TileHeight(tile2);
while (curh != h) {
CommandCost ret = DoCommand(tile2, SLOPE_N, (curh > h) ? 0 : 1, flags & ~DC_EXEC, CMD_TERRAFORM_LAND);
@@ -403,7 +403,7 @@ CommandCost CmdLevelLand(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32
cost.AddCost(ret);
curh += (curh > h) ? -1 : 1;
}
- } END_TILE_LOOP(tile2, size_x, size_y, tile)
+ }
return (cost.GetCost() == 0) ? CMD_ERROR : cost;
}
diff --git a/src/terraform_gui.cpp b/src/terraform_gui.cpp
index 026d663f6..97fb9b92a 100644
--- a/src/terraform_gui.cpp
+++ b/src/terraform_gui.cpp
@@ -58,11 +58,11 @@ static void GenerateDesertArea(TileIndex end, TileIndex start)
size_y = (ey - sy) + 1;
_generating_world = true;
- BEGIN_TILE_LOOP(tile, size_x, size_y, TileXY(sx, sy)) {
+ TILE_LOOP(tile, size_x, size_y, TileXY(sx, sy)) {
SetTropicZone(tile, (_ctrl_pressed) ? TROPICZONE_NORMAL : TROPICZONE_DESERT);
DoCommandP(tile, 0, 0, CMD_LANDSCAPE_CLEAR);
MarkTileDirtyByTile(tile);
- } END_TILE_LOOP(tile, size_x, size_y, 0);
+ }
_generating_world = false;
}
@@ -83,7 +83,7 @@ static void GenerateRockyArea(TileIndex end, TileIndex start)
size_x = (ex - sx) + 1;
size_y = (ey - sy) + 1;
- BEGIN_TILE_LOOP(tile, size_x, size_y, TileXY(sx, sy)) {
+ TILE_LOOP(tile, size_x, size_y, TileXY(sx, sy)) {
switch (GetTileType(tile)) {
case MP_TREES:
if (GetTreeGround(tile) == TREE_GROUND_SHORE) continue;
@@ -96,7 +96,7 @@ static void GenerateRockyArea(TileIndex end, TileIndex start)
}
MarkTileDirtyByTile(tile);
success = true;
- } END_TILE_LOOP(tile, size_x, size_y, 0);
+ }
if (success) SndPlayTileFx(SND_1F_SPLAT, end);
}
@@ -410,22 +410,22 @@ static void CommonRaiseLowerBigLand(TileIndex tile, int mode)
if (mode != 0) {
/* Raise land */
h = 15; // XXX - max height
- BEGIN_TILE_LOOP(tile2, sizex, sizey, tile) {
+ TILE_LOOP(tile2, sizex, sizey, tile) {
h = min(h, TileHeight(tile2));
- } END_TILE_LOOP(tile2, sizex, sizey, tile)
+ }
} else {
/* Lower land */
h = 0;
- BEGIN_TILE_LOOP(tile2, sizex, sizey, tile) {
+ TILE_LOOP(tile2, sizex, sizey, tile) {
h = max(h, TileHeight(tile2));
- } END_TILE_LOOP(tile2, sizex, sizey, tile)
+ }
}
- BEGIN_TILE_LOOP(tile2, sizex, sizey, tile) {
+ TILE_LOOP(tile2, sizex, sizey, tile) {
if (TileHeight(tile2) == h) {
DoCommandP(tile2, SLOPE_N, (uint32)mode, CMD_TERRAFORM_LAND);
}
- } END_TILE_LOOP(tile2, sizex, sizey, tile)
+ }
}
}
diff --git a/src/unmovable_cmd.cpp b/src/unmovable_cmd.cpp
index 15170b90e..832318dd5 100644
--- a/src/unmovable_cmd.cpp
+++ b/src/unmovable_cmd.cpp
@@ -370,9 +370,9 @@ static bool IsRadioTowerNearby(TileIndex tile)
uint w = min(TileX(tile), 4U) + 1 + min(MapMaxX() - TileX(tile), 4U);
uint h = min(TileY(tile), 4U) + 1 + min(MapMaxY() - TileY(tile), 4U);
- BEGIN_TILE_LOOP(tile, w, h, tile_s)
+ TILE_LOOP(tile, w, h, tile_s) {
if (IsTransmitterTile(tile)) return true;
- END_TILE_LOOP(tile, w, h, tile_s)
+ }
return false;
}
diff --git a/src/water_cmd.cpp b/src/water_cmd.cpp
index f236219e5..33c53fff3 100644
--- a/src/water_cmd.cpp
+++ b/src/water_cmd.cpp
@@ -307,7 +307,7 @@ CommandCost CmdBuildCanal(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32
/* Outside the editor you can only drag canals, and not areas */
if (_game_mode != GM_EDITOR && (sx != x && sy != y)) return CMD_ERROR;
- BEGIN_TILE_LOOP(tile, size_x, size_y, TileXY(sx, sy)) {
+ TILE_LOOP(tile, size_x, size_y, TileXY(sx, sy)) {
CommandCost ret;
Slope slope = GetTileSlope(tile, NULL);
@@ -335,7 +335,7 @@ CommandCost CmdBuildCanal(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32
}
cost.AddCost(_price.clear_water);
- } END_TILE_LOOP(tile, size_x, size_y, 0);
+ }
if (cost.GetCost() == 0) {
return_cmd_error(STR_ERROR_ALREADY_BUILT);
@@ -749,11 +749,11 @@ static void FloodVehicles(TileIndex tile)
if (!_settings_game.station.nonuniform_stations && IsTileType(tile, MP_STATION) && GetStationType(tile) == STATION_RAIL) {
const Station *st = Station::GetByTile(tile);
- BEGIN_TILE_LOOP(t, st->train_station.w, st->train_station.h, st->train_station.tile)
+ TILE_LOOP(t, st->train_station.w, st->train_station.h, st->train_station.tile) {
if (st->TileBelongsToRailStation(t)) {
FindVehicleOnPos(tile, &z, &FloodVehicleProc);
}
- END_TILE_LOOP(t, st->train_station.w, st->train_station.h, st->train_station.tile)
+ }
return;
}