Codechange: Use TileAddBy(Diag)Dir when possible.

This commit is contained in:
J0anJosep 2018-04-29 13:50:52 +02:00 committed by frosch
parent 944f785be8
commit 79a551a83c
6 changed files with 6 additions and 7 deletions

View File

@ -269,7 +269,7 @@ bool CircularTileSearch(TileIndex *tile, uint size, TestTileOnSearchProc proc, v
/* If tile test is not successful, get one tile up, /* If tile test is not successful, get one tile up,
* ready for a test in first circle around center tile */ * 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); return CircularTileSearch(tile, size / 2, 1, 1, proc, user_data);
} else { } else {
return CircularTileSearch(tile, size / 2, 0, 0, proc, user_data); return CircularTileSearch(tile, size / 2, 0, 0, proc, user_data);

View File

@ -219,8 +219,7 @@ protected:
} }
/* normal or station tile, do one step */ /* normal or station tile, do one step */
TileIndexDiff diff = TileOffsByDiagDir(m_exitdir); m_new_tile = TileAddByDiagDir(m_old_tile, m_exitdir);
m_new_tile = TILE_ADD(m_old_tile, diff);
/* special handling for stations */ /* special handling for stations */
if (IsRailTT() && HasStationTileRail(m_new_tile)) { if (IsRailTT() && HasStationTileRail(m_new_tile)) {

View File

@ -69,7 +69,7 @@ public:
} }
/* move back to the old tile/trackdir (where ship is coming from) */ /* 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(); Trackdir trackdir = v->GetVehicleTrackdir();
assert(IsValidTrackdir(trackdir)); assert(IsValidTrackdir(trackdir));

View File

@ -1449,7 +1449,7 @@ again:
/* Vehicle has arrived at a bay in a road stop */ /* Vehicle has arrived at a bay in a road stop */
if (IsDriveThroughStopTile(v->tile)) { 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. */ /* 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) { if (RoadStop::IsDriveThroughRoadStopContinuation(v->tile, next_tile) && (GetRoadTypes(next_tile) & v->compatible_roadtypes) != 0) {

View File

@ -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; 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; 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<T>, &ctx); CircularTileSearch(&tile, max_dist, ta.w, ta.h, AddNearbyStation<T>, &ctx);
return NULL; return NULL;

View File

@ -1218,7 +1218,7 @@ void ConvertGroundTilesIntoWaterTiles()
default: default:
uint dir; uint dir;
FOR_EACH_SET_BIT(dir, _flood_from_dirs[slope & ~SLOPE_STEEP]) { 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; Slope slope_dest = GetTileSlope(dest) & ~SLOPE_STEEP;
if (slope_dest == SLOPE_FLAT || IsSlopeWithOneCornerRaised(slope_dest)) { if (slope_dest == SLOPE_FLAT || IsSlopeWithOneCornerRaised(slope_dest)) {
MakeShore(tile); MakeShore(tile);