diff options
author | matthijs <matthijs@openttd.org> | 2005-04-11 19:14:48 +0000 |
---|---|---|
committer | matthijs <matthijs@openttd.org> | 2005-04-11 19:14:48 +0000 |
commit | b02dde198240a27f53ca196e1d9bdff89ca2edcf (patch) | |
tree | 2cfb3fe1eaa3454e6c943f30efc3944c2eba1a02 /map.h | |
parent | a714444a8eed4e9eb7cba177026171e034ce3b7f (diff) | |
download | openttd-b02dde198240a27f53ca196e1d9bdff89ca2edcf.tar.xz |
(svn r2181) - Add: DistanceTrack() to calculate the distance over optimally laid out tracks.
- Codechange: [NPF] Removed unused heuristic function NPFCalcTileHeuristic().
- Codechange: [NPF] Use DistanceTrack() instead of DistanceManhattan() for ship and train heuristic.
- Codechange: Renamed variables x and y to dx and dy in some of the distance calculation functions.
Diffstat (limited to 'map.h')
-rw-r--r-- | map.h | 9 |
1 files changed, 8 insertions, 1 deletions
@@ -102,10 +102,11 @@ static inline TileIndex AddTileIndexDiffCWrap(TileIndex tile, TileIndexDiffC dif } // Functions to calculate distances -uint DistanceManhattan(TileIndex, TileIndex); // also known as L1-Norm +uint DistanceManhattan(TileIndex, TileIndex); // also known as L1-Norm. Is the shortest distance one could go over diagonal tracks (or roads) uint DistanceSquare(TileIndex, TileIndex); // euclidian- or L2-Norm squared uint DistanceMax(TileIndex, TileIndex); // also known as L-Infinity-Norm uint DistanceMaxPlusManhattan(TileIndex, TileIndex); // Max + Manhattan +uint DistanceTrack(TileIndex, TileIndex); // Returns the shortest distance one could go over tracks uint DistanceFromEdge(TileIndex); // shortest distance from any edge of the map @@ -117,4 +118,10 @@ static inline TileIndexDiff TileOffsByDir(uint dir) return ToTileIndexDiff(_tileoffs_by_dir[dir]); } +/* Approximation of the length of a straight track, relative to a diagonal + * track (ie the size of a tile side). #defined instead of const so it can + * stay integer. (no runtime float operations) Is this needed? + * This value should be sqrt(2)/2 ~ 0.7071 */ +#define STRAIGHT_TRACK_LENGTH (7071/10000) + #endif |