summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/ai/api/ai_industry.cpp4
-rw-r--r--src/ai/api/ai_tilelist.cpp4
-rw-r--r--src/industry_cmd.cpp2
-rw-r--r--src/map_func.h10
-rw-r--r--src/newgrf_industrytiles.cpp4
-rw-r--r--src/newgrf_station.cpp4
-rw-r--r--src/station_cmd.cpp4
-rw-r--r--src/station_gui.cpp2
-rw-r--r--src/water_cmd.cpp2
9 files changed, 23 insertions, 13 deletions
diff --git a/src/ai/api/ai_industry.cpp b/src/ai/api/ai_industry.cpp
index cf715d34e..6fb208ce9 100644
--- a/src/ai/api/ai_industry.cpp
+++ b/src/ai/api/ai_industry.cpp
@@ -162,7 +162,7 @@
if (!HasHeliport(industry_id)) return INVALID_TILE;
const Industry *ind = ::Industry::Get(industry_id);
- TILE_LOOP(tile_cur, ind->location.w, ind->location.h, ind->location.tile) {
+ TILE_AREA_LOOP(tile_cur, ind->location) {
if (IsTileType(tile_cur, MP_STATION) && IsOilRig(tile_cur)) {
return tile_cur;
}
@@ -184,7 +184,7 @@
if (!HasDock(industry_id)) return INVALID_TILE;
const Industry *ind = ::Industry::Get(industry_id);
- TILE_LOOP(tile_cur, ind->location.w, ind->location.h, ind->location.tile) {
+ TILE_AREA_LOOP(tile_cur, ind->location) {
if (IsTileType(tile_cur, MP_STATION) && IsOilRig(tile_cur)) {
return tile_cur;
}
diff --git a/src/ai/api/ai_tilelist.cpp b/src/ai/api/ai_tilelist.cpp
index 2cf5ca661..d32b22270 100644
--- a/src/ai/api/ai_tilelist.cpp
+++ b/src/ai/api/ai_tilelist.cpp
@@ -86,7 +86,7 @@ AITileList_IndustryAccepting::AITileList_IndustryAccepting(IndustryID industry_i
if (!_settings_game.station.modified_catchment) radius = CA_UNMODIFIED;
- TILE_LOOP(cur_tile, i->location.w + radius * 2, i->location.h+ radius * 2, i->location.tile - ::TileDiffXY(radius, radius)) {
+ TILE_LOOP(cur_tile, i->location.w + radius * 2, i->location.h + radius * 2, i->location.tile - ::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;
@@ -123,7 +123,7 @@ AITileList_IndustryProducing::AITileList_IndustryProducing(IndustryID industry_i
if (!_settings_game.station.modified_catchment) radius = CA_UNMODIFIED;
- TILE_LOOP(cur_tile, i->location.w + radius * 2, i->location.h+ radius * 2, i->location.tile - ::TileDiffXY(radius, radius)) {
+ TILE_LOOP(cur_tile, i->location.w + radius * 2, i->location.h + radius * 2, i->location.tile - ::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;
diff --git a/src/industry_cmd.cpp b/src/industry_cmd.cpp
index 8527cd3fd..82c1ef855 100644
--- a/src/industry_cmd.cpp
+++ b/src/industry_cmd.cpp
@@ -144,7 +144,7 @@ Industry::~Industry()
* This means that we do not have to clear tiles either. */
if (this->location.w == 0) return;
- TILE_LOOP(tile_cur, this->location.w, this->location.h, this->location.tile) {
+ TILE_AREA_LOOP(tile_cur, this->location) {
if (IsTileType(tile_cur, MP_INDUSTRY)) {
if (GetIndustryIndex(tile_cur) == this->index) {
/* MakeWaterKeepingClass() can also handle 'land' */
diff --git a/src/map_func.h b/src/map_func.h
index 806220ccc..5acabc11d 100644
--- a/src/map_func.h
+++ b/src/map_func.h
@@ -348,6 +348,16 @@ uint DistanceFromEdge(TileIndex); ///< shortest distance from any edge of the ma
for (uint cur_w = (w); cur_w > 0; --cur_w, var++)
/**
+ * A loop which iterates over the tiles of a TileArea
+ *
+ * This macro starts 2 nested loops which iterates over a square of tiles.
+ *
+ * @param var The name of the variable which contains the current tile
+ * @param ta The tile area to search over
+ */
+#define TILE_AREA_LOOP(var, ta) TILE_LOOP(var, ta.w, ta.h, ta.tile)
+
+/**
* Convert a DiagDirection to a TileIndexDiff
*
* @param dir The DiagDirection
diff --git a/src/newgrf_industrytiles.cpp b/src/newgrf_industrytiles.cpp
index e0e883b27..51084e415 100644
--- a/src/newgrf_industrytiles.cpp
+++ b/src/newgrf_industrytiles.cpp
@@ -396,7 +396,7 @@ bool StartStopIndustryTileAnimation(const Industry *ind, IndustryAnimationTrigge
{
bool ret = true;
uint32 random = Random();
- TILE_LOOP(tile, ind->location.w, ind->location.h, ind->location.tile) {
+ TILE_AREA_LOOP(tile, ind->location) {
if (IsTileType(tile, MP_INDUSTRY) && GetIndustryIndex(tile) == ind->index) {
if (StartStopIndustryTileAnimation(tile, iat, random)) {
SB(random, 0, 16, Random());
@@ -441,7 +441,7 @@ void TriggerIndustryTile(TileIndex tile, IndustryTileTrigger trigger)
void TriggerIndustry(Industry *ind, IndustryTileTrigger trigger)
{
- TILE_LOOP(tile, ind->location.w, ind->location.h, ind->location.tile) {
+ TILE_AREA_LOOP(tile, ind->location) {
if (IsTileType(tile, MP_INDUSTRY) && GetIndustryIndex(tile) == ind->index) {
DoTriggerIndustryTile(tile, trigger, ind);
}
diff --git a/src/newgrf_station.cpp b/src/newgrf_station.cpp
index 5aa42d022..d6f747303 100644
--- a/src/newgrf_station.cpp
+++ b/src/newgrf_station.cpp
@@ -837,7 +837,7 @@ void DeallocateSpecFromStation(BaseStation *st, byte specindex)
ETileArea area = ETileArea(st, INVALID_TILE, TA_WHOLE);
/* Check all tiles over the station to check if the specindex is still in use */
- TILE_LOOP(tile, area.w, area.h, area.tile) {
+ TILE_AREA_LOOP(tile, area) {
if (st->TileBelongsToRailStation(tile) && GetCustomStationSpecIndex(tile) == specindex) {
return;
}
@@ -1076,7 +1076,7 @@ void StationAnimationTrigger(const BaseStation *st, TileIndex tile, StatAnimTrig
ETileArea area = ETileArea(st, tile, tas[trigger]);
/* Check all tiles over the station to check if the specindex is still in use */
- TILE_LOOP(tile, area.w, area.h, area.tile) {
+ TILE_AREA_LOOP(tile, area) {
if (st->TileBelongsToRailStation(tile)) {
const StationSpec *ss = GetStationSpec(tile);
if (ss != NULL && HasBit(ss->anim_triggers, trigger)) {
diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp
index fdf8b1f29..8b7bf5345 100644
--- a/src/station_cmd.cpp
+++ b/src/station_cmd.cpp
@@ -1223,7 +1223,7 @@ CommandCost RemoveFromRailBaseStation(TileArea ta, SmallVector<T *, 4> &affected
CommandCost total_cost(EXPENSES_CONSTRUCTION);
/* Do the action for every tile into the area */
- TILE_LOOP(tile, ta.w, ta.h, ta.tile) {
+ TILE_AREA_LOOP(tile, ta) {
/* Make sure the specified tile is a rail station */
if (!HasStationTileRail(tile)) continue;
@@ -1388,7 +1388,7 @@ CommandCost RemoveRailStation(T *st, DoCommandFlag flags)
CommandCost cost(EXPENSES_CONSTRUCTION);
/* clear all areas of the station */
- TILE_LOOP(tile, ta.w, ta.h, ta.tile) {
+ TILE_AREA_LOOP(tile, ta) {
/* for nonuniform stations, only remove tiles that are actually train station tiles */
if (!st->TileBelongsToRailStation(tile)) continue;
diff --git a/src/station_gui.cpp b/src/station_gui.cpp
index 9843e16f6..104a53c72 100644
--- a/src/station_gui.cpp
+++ b/src/station_gui.cpp
@@ -1211,7 +1211,7 @@ static const T *FindStationsNearby(TileArea ta, bool distant_join)
_deleted_stations_nearby.Clear();
/* Check the inside, to return, if we sit on another station */
- TILE_LOOP(t, ta.w, ta.h, ta.tile) {
+ TILE_AREA_LOOP(t, ta) {
if (t < MapSize() && IsTileType(t, MP_STATION) && T::IsValidID(GetStationIndex(t))) return T::GetByTile(t);
}
diff --git a/src/water_cmd.cpp b/src/water_cmd.cpp
index befe7df8a..c2e245985 100644
--- a/src/water_cmd.cpp
+++ b/src/water_cmd.cpp
@@ -761,7 +761,7 @@ 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);
- TILE_LOOP(t, st->train_station.w, st->train_station.h, st->train_station.tile) {
+ TILE_AREA_LOOP(t, st->train_station) {
if (st->TileBelongsToRailStation(t)) {
FindVehicleOnPos(tile, &z, &FloodVehicleProc);
}