mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-06 22:28:56 +00:00
(svn r5617) if cascade -> switch
This commit is contained in:
parent
4612836b40
commit
fbcdf3c24e
@ -641,40 +641,48 @@ static void ProcessRoadVehOrder(Vehicle *v)
|
|||||||
}
|
}
|
||||||
|
|
||||||
v->current_order = *order;
|
v->current_order = *order;
|
||||||
v->dest_tile = 0;
|
|
||||||
|
|
||||||
if (order->type == OT_GOTO_STATION) {
|
switch (order->type) {
|
||||||
const Station* st = GetStation(order->station);
|
case OT_GOTO_STATION: {
|
||||||
const RoadStop* rs;
|
const RoadStop* rs;
|
||||||
TileIndex dest;
|
|
||||||
uint mindist;
|
|
||||||
|
|
||||||
if (order->station == v->last_station_visited) {
|
if (order->station == v->last_station_visited) {
|
||||||
v->last_station_visited = INVALID_STATION;
|
v->last_station_visited = INVALID_STATION;
|
||||||
}
|
|
||||||
|
|
||||||
rs = GetPrimaryRoadStop(st, v->cargo_type == CT_PASSENGERS ? RS_BUS : RS_TRUCK);
|
|
||||||
|
|
||||||
if (rs == NULL) {
|
|
||||||
// There is no stop left at the station, so don't even TRY to go there
|
|
||||||
v->cur_order_index++;
|
|
||||||
InvalidateVehicleOrder(v);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
dest = rs->xy;
|
|
||||||
mindist = DistanceManhattan(v->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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rs = GetPrimaryRoadStop(
|
||||||
|
GetStation(order->station),
|
||||||
|
v->cargo_type == CT_PASSENGERS ? RS_BUS : RS_TRUCK
|
||||||
|
);
|
||||||
|
|
||||||
|
if (rs != NULL) {
|
||||||
|
TileIndex dest = rs->xy;
|
||||||
|
uint mindist = DistanceManhattan(v->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 {
|
||||||
|
// There is no stop left at the station, so don't even TRY to go there
|
||||||
|
v->cur_order_index++;
|
||||||
|
v->dest_tile = 0;
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
v->dest_tile = dest;
|
|
||||||
} else if (order->type == OT_GOTO_DEPOT) {
|
case OT_GOTO_DEPOT:
|
||||||
v->dest_tile = GetDepot(order->station)->xy;
|
v->dest_tile = GetDepot(order->station)->xy;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
v->dest_tile = 0;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
InvalidateVehicleOrder(v);
|
InvalidateVehicleOrder(v);
|
||||||
|
Loading…
Reference in New Issue
Block a user