From 79a551a83ceda50b1b95d2a5519dbcbc6f700d2b Mon Sep 17 00:00:00 2001 From: J0anJosep Date: Sun, 29 Apr 2018 13:50:52 +0200 Subject: [PATCH] Codechange: Use TileAddBy(Diag)Dir when possible. --- src/map.cpp | 2 +- src/pathfinder/follow_track.hpp | 3 +-- src/pathfinder/yapf/yapf_ship.cpp | 2 +- src/roadveh_cmd.cpp | 2 +- src/station_gui.cpp | 2 +- src/water_cmd.cpp | 2 +- 6 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/map.cpp b/src/map.cpp index 986aa1bbbf..85590c3e88 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -269,7 +269,7 @@ bool CircularTileSearch(TileIndex *tile, uint size, TestTileOnSearchProc proc, v /* If tile test is not successful, get one tile up, * ready for a test in first circle around center tile */ - *tile = TILE_ADD(*tile, TileOffsByDir(DIR_N)); + *tile = TileAddByDir(*tile, DIR_N); return CircularTileSearch(tile, size / 2, 1, 1, proc, user_data); } else { return CircularTileSearch(tile, size / 2, 0, 0, proc, user_data); diff --git a/src/pathfinder/follow_track.hpp b/src/pathfinder/follow_track.hpp index 9f19b029c0..d9a70b7fca 100644 --- a/src/pathfinder/follow_track.hpp +++ b/src/pathfinder/follow_track.hpp @@ -219,8 +219,7 @@ protected: } /* normal or station tile, do one step */ - TileIndexDiff diff = TileOffsByDiagDir(m_exitdir); - m_new_tile = TILE_ADD(m_old_tile, diff); + m_new_tile = TileAddByDiagDir(m_old_tile, m_exitdir); /* special handling for stations */ if (IsRailTT() && HasStationTileRail(m_new_tile)) { diff --git a/src/pathfinder/yapf/yapf_ship.cpp b/src/pathfinder/yapf/yapf_ship.cpp index e4b99462d2..df6cd468ce 100644 --- a/src/pathfinder/yapf/yapf_ship.cpp +++ b/src/pathfinder/yapf/yapf_ship.cpp @@ -69,7 +69,7 @@ public: } /* move back to the old tile/trackdir (where ship is coming from) */ - TileIndex src_tile = TILE_ADD(tile, TileOffsByDiagDir(ReverseDiagDir(enterdir))); + TileIndex src_tile = TileAddByDiagDir(tile, ReverseDiagDir(enterdir)); Trackdir trackdir = v->GetVehicleTrackdir(); assert(IsValidTrackdir(trackdir)); diff --git a/src/roadveh_cmd.cpp b/src/roadveh_cmd.cpp index 7adc532b6b..fcabf477f6 100644 --- a/src/roadveh_cmd.cpp +++ b/src/roadveh_cmd.cpp @@ -1449,7 +1449,7 @@ again: /* Vehicle has arrived at a bay in a road stop */ if (IsDriveThroughStopTile(v->tile)) { - TileIndex next_tile = TILE_ADD(v->tile, TileOffsByDir(v->direction)); + TileIndex next_tile = TileAddByDir(v->tile, v->direction); /* Check if next inline bay is free and has compatible road. */ if (RoadStop::IsDriveThroughRoadStopContinuation(v->tile, next_tile) && (GetRoadTypes(next_tile) & v->compatible_roadtypes) != 0) { diff --git a/src/station_gui.cpp b/src/station_gui.cpp index aa20170180..c1927bdccb 100644 --- a/src/station_gui.cpp +++ b/src/station_gui.cpp @@ -2208,7 +2208,7 @@ static const T *FindStationsNearby(TileArea ta, bool distant_join) if (distant_join && min(ta.w, ta.h) >= _settings_game.station.station_spread) return NULL; uint max_dist = distant_join ? _settings_game.station.station_spread - min(ta.w, ta.h) : 1; - TileIndex tile = TILE_ADD(ctx.tile, TileOffsByDir(DIR_N)); + TileIndex tile = TileAddByDir(ctx.tile, DIR_N); CircularTileSearch(&tile, max_dist, ta.w, ta.h, AddNearbyStation, &ctx); return NULL; diff --git a/src/water_cmd.cpp b/src/water_cmd.cpp index 07b6a95507..737257a823 100644 --- a/src/water_cmd.cpp +++ b/src/water_cmd.cpp @@ -1218,7 +1218,7 @@ void ConvertGroundTilesIntoWaterTiles() default: uint dir; FOR_EACH_SET_BIT(dir, _flood_from_dirs[slope & ~SLOPE_STEEP]) { - TileIndex dest = TILE_ADD(tile, TileOffsByDir((Direction)dir)); + TileIndex dest = TileAddByDir(tile, (Direction)dir); Slope slope_dest = GetTileSlope(dest) & ~SLOPE_STEEP; if (slope_dest == SLOPE_FLAT || IsSlopeWithOneCornerRaised(slope_dest)) { MakeShore(tile);