Index: src/linkgraph/linkgraph.cpp =================================================================== --- src/linkgraph/linkgraph.cpp (revision 26399) +++ src/linkgraph/linkgraph.cpp (working copy) @@ -155,7 +155,7 @@ for (NodeID other = 0; other < this->Size(); ++other) { if (other == id) continue; this->edges[id][other].distance = this->edges[other][id].distance = - DistanceManhattan(xy, Station::Get(this->nodes[other].station)->xy); + DistanceAxeDiag(xy, Station::Get(this->nodes[other].station)->xy); } } @@ -187,7 +187,7 @@ new_edges[new_node].next_edge = INVALID_NODE; for (NodeID i = 0; i <= new_node; ++i) { - uint distance = DistanceManhattan(st->xy, Station::Get(this->nodes[i].station)->xy); + uint distance = DistanceAxeDiag(st->xy, Station::Get(this->nodes[i].station)->xy); new_edges[i].Init(distance); this->edges[i][new_node].Init(distance); } Index: src/map.cpp =================================================================== --- src/map.cpp (revision 26399) +++ src/map.cpp (working copy) @@ -209,6 +209,29 @@ } /** + * Gets the distance taken between the two given tiles + * of vehicle that can move only by axes or diagonals + * @param t0 the start tile + * @param t1 the end tile + * @return the distance + */ +uint DistanceAxeDiag(TileIndex t0, TileIndex t1) +{ + const uint dx = Delta(TileX(t0), TileX(t1)); + const uint dy = Delta(TileY(t0), TileY(t1)); + uint diag, axe; + if (dx < dy) { + diag = dx; + axe = dy - dx; + } else { + diag = dy; + axe = dx - dy; + } + + return diag * /*M_SQRT2*/ 577/408 + axe; +} + +/** * Param the minimum distance to an edge * @param tile the tile to get the distance from * @return the distance from the edge in tiles Index: src/map_func.h =================================================================== --- src/map_func.h (revision 26399) +++ src/map_func.h (working copy) @@ -330,6 +330,7 @@ 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 DistanceAxeDiag(TileIndex t0, TileIndex t1); uint DistanceFromEdge(TileIndex); ///< shortest distance from any edge of the map uint DistanceFromEdgeDir(TileIndex, DiagDirection); ///< distance from the map edge in given direction Index: src/order_cmd.cpp =================================================================== --- src/order_cmd.cpp (revision 26399) +++ src/order_cmd.cpp (working copy) @@ -698,7 +698,7 @@ TileIndex prev_tile = prev->GetLocation(v, true); TileIndex cur_tile = cur->GetLocation(v, true); if (prev_tile == INVALID_TILE || cur_tile == INVALID_TILE) return 0; - return v->type == VEH_AIRCRAFT ? DistanceSquare(prev_tile, cur_tile) : DistanceManhattan(prev_tile, cur_tile); + return v->type == VEH_AIRCRAFT ? DistanceAxeDiag(prev_tile, cur_tile) : DistanceManhattan(prev_tile, cur_tile); } /**