summaryrefslogtreecommitdiff
path: root/src/pathfinder
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2010-12-16 23:24:30 +0000
committerrubidium <rubidium@openttd.org>2010-12-16 23:24:30 +0000
commit29fc9b1d48a90669cc6bf7d78f531194b4b6d87d (patch)
treec79d09a52349a80863aae9a970af1ab4890564a9 /src/pathfinder
parent01f924daad730bc385368883b95aaa48f1fc4c4f (diff)
downloadopenttd-29fc9b1d48a90669cc6bf7d78f531194b4b6d87d.tar.xz
(svn r21533) -Codechange: replace some magic numbers with less magic constants
Diffstat (limited to 'src/pathfinder')
-rw-r--r--src/pathfinder/opf/opf_ship.cpp20
1 files changed, 11 insertions, 9 deletions
diff --git a/src/pathfinder/opf/opf_ship.cpp b/src/pathfinder/opf/opf_ship.cpp
index cb96f4cf8..4557e3a3f 100644
--- a/src/pathfinder/opf/opf_ship.cpp
+++ b/src/pathfinder/opf/opf_ship.cpp
@@ -118,16 +118,18 @@ static void OPFShipFollowTrack(TileIndex tile, DiagDirection direction, TrackPat
TPFModeShip(tpf, tile, direction);
}
-static const byte _ship_search_directions[6][4] = {
- { 0, 9, 2, 9 },
- { 9, 1, 9, 3 },
- { 9, 0, 3, 9 },
- { 1, 9, 9, 2 },
- { 3, 2, 9, 9 },
- { 9, 9, 1, 0 },
+/** Directions to search towards given track bits and the ship's enter direction. */
+static const DiagDirection _ship_search_directions[6][4] = {
+ { DIAGDIR_NE, INVALID_DIAGDIR, DIAGDIR_SW, INVALID_DIAGDIR },
+ { INVALID_DIAGDIR, DIAGDIR_SE, INVALID_DIAGDIR, DIAGDIR_NW },
+ { INVALID_DIAGDIR, DIAGDIR_NE, DIAGDIR_NW, INVALID_DIAGDIR },
+ { DIAGDIR_SE, INVALID_DIAGDIR, INVALID_DIAGDIR, DIAGDIR_SW },
+ { DIAGDIR_NW, DIAGDIR_SW, INVALID_DIAGDIR, INVALID_DIAGDIR },
+ { INVALID_DIAGDIR, INVALID_DIAGDIR, DIAGDIR_SE, DIAGDIR_NE },
};
-static const byte _pick_shiptrack_table[6] = {1, 3, 2, 2, 0, 0};
+/** Track to "direction (& 3)" mapping. */
+static const byte _pick_shiptrack_table[6] = {DIR_NE, DIR_SE, DIR_E, DIR_E, DIR_N, DIR_N};
static uint FindShipTrack(const Ship *v, TileIndex tile, DiagDirection dir, TrackBits bits, TileIndex skiptile, Track *track)
{
@@ -147,7 +149,7 @@ static uint FindShipTrack(const Ship *v, TileIndex tile, DiagDirection dir, Trac
pfs.best_bird_dist = UINT_MAX;
pfs.best_length = UINT_MAX;
- OPFShipFollowTrack(tile, (DiagDirection)_ship_search_directions[i][dir], &pfs);
+ OPFShipFollowTrack(tile, _ship_search_directions[i][dir], &pfs);
if (best_track != INVALID_TRACK) {
if (pfs.best_bird_dist != 0) {