mirror of https://github.com/OpenTTD/OpenTTD
(svn r26411) -Change [FS#5941]: Use better distance metric for link graph (MildaIV)
parent
26262e035a
commit
afd1263ce1
|
@ -271,7 +271,7 @@ void DemandCalculator::CalcDemand(LinkGraphJob &job, Tscaler scaler)
|
||||||
* @param job Job to calculate the demands for.
|
* @param job Job to calculate the demands for.
|
||||||
*/
|
*/
|
||||||
DemandCalculator::DemandCalculator(LinkGraphJob &job) :
|
DemandCalculator::DemandCalculator(LinkGraphJob &job) :
|
||||||
max_distance(MapSizeX() + MapSizeY() - 2)
|
max_distance(DistanceMaxPlusManhattan(TileXY(0,0), TileXY(MapMaxX(), MapMaxY())))
|
||||||
{
|
{
|
||||||
const LinkGraphSettings &settings = job.Settings();
|
const LinkGraphSettings &settings = job.Settings();
|
||||||
CargoID cargo = job.Cargo();
|
CargoID cargo = job.Cargo();
|
||||||
|
|
|
@ -155,7 +155,7 @@ void LinkGraph::UpdateDistances(NodeID id, TileIndex xy)
|
||||||
for (NodeID other = 0; other < this->Size(); ++other) {
|
for (NodeID other = 0; other < this->Size(); ++other) {
|
||||||
if (other == id) continue;
|
if (other == id) continue;
|
||||||
this->edges[id][other].distance = this->edges[other][id].distance =
|
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;
|
new_edges[new_node].next_edge = INVALID_NODE;
|
||||||
|
|
||||||
for (NodeID i = 0; i <= new_node; ++i) {
|
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);
|
new_edges[i].Init(distance);
|
||||||
this->edges[i][new_node].Init(distance);
|
this->edges[i][new_node].Init(distance);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue