summaryrefslogtreecommitdiff
path: root/src/linkgraph
diff options
context:
space:
mode:
authorfonsinchen <fonsinchen@openttd.org>2014-03-17 20:33:26 +0000
committerfonsinchen <fonsinchen@openttd.org>2014-03-17 20:33:26 +0000
commitafd1263ce1b52c8e04eec2dd88738ed322ada467 (patch)
tree3b0b47d0aebfb7a87950733885291924bc0743f3 /src/linkgraph
parent26262e035a1cee7eca955cb8977b51caa90d4dbd (diff)
downloadopenttd-afd1263ce1b52c8e04eec2dd88738ed322ada467.tar.xz
(svn r26411) -Change [FS#5941]: Use better distance metric for link graph (MildaIV)
Diffstat (limited to 'src/linkgraph')
-rw-r--r--src/linkgraph/demands.cpp2
-rw-r--r--src/linkgraph/linkgraph.cpp4
2 files changed, 3 insertions, 3 deletions
diff --git a/src/linkgraph/demands.cpp b/src/linkgraph/demands.cpp
index 87426326a..80a0f5677 100644
--- a/src/linkgraph/demands.cpp
+++ b/src/linkgraph/demands.cpp
@@ -271,7 +271,7 @@ void DemandCalculator::CalcDemand(LinkGraphJob &job, Tscaler scaler)
* @param job Job to calculate the demands for.
*/
DemandCalculator::DemandCalculator(LinkGraphJob &job) :
- max_distance(MapSizeX() + MapSizeY() - 2)
+ max_distance(DistanceMaxPlusManhattan(TileXY(0,0), TileXY(MapMaxX(), MapMaxY())))
{
const LinkGraphSettings &settings = job.Settings();
CargoID cargo = job.Cargo();
diff --git a/src/linkgraph/linkgraph.cpp b/src/linkgraph/linkgraph.cpp
index e8c792c37..d41c3494d 100644
--- a/src/linkgraph/linkgraph.cpp
+++ b/src/linkgraph/linkgraph.cpp
@@ -155,7 +155,7 @@ void LinkGraph::UpdateDistances(NodeID id, TileIndex xy)
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);
+ DistanceMaxPlusManhattan(xy, Station::Get(this->nodes[other].station)->xy);
}
}
@@ -187,7 +187,7 @@ NodeID LinkGraph::AddNode(const Station *st)
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 = DistanceMaxPlusManhattan(st->xy, Station::Get(this->nodes[i].station)->xy);
new_edges[i].Init(distance);
this->edges[i][new_node].Init(distance);
}