diff options
-rw-r--r-- | map.h | 14 | ||||
-rw-r--r-- | npf.c | 6 | ||||
-rw-r--r-- | yapf/unittest/test_yapf.h | 2 |
3 files changed, 11 insertions, 11 deletions
@@ -119,9 +119,11 @@ static inline TileIndexDiff ToTileIndexDiff(TileIndexDiffC tidc) uint TileAddWrap(TileIndex tile, int addx, int addy); -static inline TileIndexDiffC TileIndexDiffCByDir(uint dir) { - extern const TileIndexDiffC _tileoffs_by_dir[4]; - return _tileoffs_by_dir[dir]; +static inline TileIndexDiffC TileIndexDiffCByDiagDir(uint dir) { + extern const TileIndexDiffC _tileoffs_by_diagdir[4]; + + assert(dir < lengthof(_tileoffs_by_diagdir)); + return _tileoffs_by_diagdir[dir]; } /* Returns tile + the diff given in diff. If the result tile would end up @@ -157,8 +159,7 @@ uint DistanceFromEdge(TileIndex); // shortest distance from any edge of the map } while (var += TileDiffXY(0, 1) - (w), --h_cur != 0); \ } -typedef enum DiagDirection DiagDirection; -static inline TileIndexDiff TileOffsByDiagDir(DiagDirection dir) +static inline TileIndexDiff TileOffsByDiagDir(uint dir) { extern const TileIndexDiffC _tileoffs_by_diagdir[4]; @@ -166,8 +167,7 @@ static inline TileIndexDiff TileOffsByDiagDir(DiagDirection dir) return ToTileIndexDiff(_tileoffs_by_diagdir[dir]); } -typedef enum Direction Direction; -static inline TileIndexDiff TileOffsByDir(Direction dir) +static inline TileIndexDiff TileOffsByDir(uint dir) { extern const TileIndexDiffC _tileoffs_by_dir[8]; @@ -563,16 +563,16 @@ static void NPFFollowTrack(AyStar* aystar, OpenListNode* current) * outside of the depot. But, because the code layout is cleaner this * way, we will just pretend we are reversed already */ src_trackdir = ReverseTrackdir(src_trackdir); - dst_tile = AddTileIndexDiffCWrap(src_tile, TileIndexDiffCByDir(exitdir)); + dst_tile = AddTileIndexDiffCWrap(src_tile, TileIndexDiffCByDiagDir(exitdir)); } else { dst_tile = INVALID_TILE; /* Road vehicle heading inwards: dead end */ } } else { - dst_tile = AddTileIndexDiffCWrap(src_tile, TileIndexDiffCByDir(exitdir)); + dst_tile = AddTileIndexDiffCWrap(src_tile, TileIndexDiffCByDiagDir(exitdir)); } } else { /* This a normal tile, a bridge, a tunnel exit, etc. */ - dst_tile = AddTileIndexDiffCWrap(src_tile, TileIndexDiffCByDir(TrackdirToExitdir(src_trackdir))); + dst_tile = AddTileIndexDiffCWrap(src_tile, TileIndexDiffCByDiagDir(TrackdirToExitdir(src_trackdir))); } if (dst_tile == INVALID_TILE) { /* We reached the border of the map */ diff --git a/yapf/unittest/test_yapf.h b/yapf/unittest/test_yapf.h index 952040faa..685e6fcf7 100644 --- a/yapf/unittest/test_yapf.h +++ b/yapf/unittest/test_yapf.h @@ -169,7 +169,7 @@ struct CYapfTestBaseT int z_org = Map::MapZ(x_org, y_org); DiagDirection exitdir = TrackdirToExitdir(org.m_key.m_td); - TileIndexDiffC diff = TileIndexDiffCByDir(exitdir); + TileIndexDiffC diff = TileIndexDiffCByDiagDir(exitdir); int x_new = x_org + diff.x; int y_new = y_org + diff.y; int z_new = Map::MapZ(x_new, y_new); |