mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-01-31 03:12:41 +00:00
(svn r3960) -Fix: Correctly implement minimum search, so road vehicles head twoards the closest station, not the last one in the list. Backport of r3751 from trunk
This commit is contained in:
parent
818a5a596f
commit
1856976d8e
@ -634,7 +634,8 @@ static void ProcessRoadVehOrder(Vehicle *v)
|
|||||||
st = GetStation(order->station);
|
st = GetStation(order->station);
|
||||||
|
|
||||||
{
|
{
|
||||||
uint mindist = 0xFFFFFFFF;
|
TileIndex dest;
|
||||||
|
uint mindist;
|
||||||
RoadStopType type;
|
RoadStopType type;
|
||||||
RoadStop *rs;
|
RoadStop *rs;
|
||||||
|
|
||||||
@ -649,12 +650,17 @@ static void ProcessRoadVehOrder(Vehicle *v)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (rs = GetPrimaryRoadStop(st, type); rs != NULL; rs = rs->next) {
|
dest = rs->xy;
|
||||||
if (DistanceManhattan(v->tile, rs->xy) < mindist) {
|
mindist = DistanceManhattan(v->tile, rs->xy);
|
||||||
v->dest_tile = rs->xy;
|
for (rs = rs->next; rs != NULL; rs = rs->next) {
|
||||||
|
uint dist = DistanceManhattan(v->tile, rs->xy);
|
||||||
|
|
||||||
|
if (dist < mindist) {
|
||||||
|
mindist = dist;
|
||||||
|
dest = rs->xy;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
v->dest_tile = dest;
|
||||||
}
|
}
|
||||||
} else if (order->type == OT_GOTO_DEPOT) {
|
} else if (order->type == OT_GOTO_DEPOT) {
|
||||||
v->dest_tile = GetDepot(order->station)->xy;
|
v->dest_tile = GetDepot(order->station)->xy;
|
||||||
|
Loading…
Reference in New Issue
Block a user