mirror of
https://github.com/OpenTTD/OpenTTD
synced 2026-01-18 09:52:44 +01:00
Codechange: Remove StationIDStack and SmallStack.
Use a std::vector or std::span instead.
This commit is contained in:
committed by
Peter Nelson
parent
5c89dff677
commit
fd32d1447e
@@ -361,14 +361,14 @@ VehicleOrderID OrderList::GetNextDecisionNode(VehicleOrderID next, uint hops) co
|
||||
* @pre The vehicle is currently loading and v->last_station_visited is meaningful.
|
||||
* @note This function may draw a random number. Don't use it from the GUI.
|
||||
*/
|
||||
StationIDStack OrderList::GetNextStoppingStation(const Vehicle *v, VehicleOrderID first, uint hops) const
|
||||
std::vector<StationID> OrderList::GetNextStoppingStation(const Vehicle *v, VehicleOrderID first, uint hops) const
|
||||
{
|
||||
VehicleOrderID next = first;
|
||||
if (first == INVALID_VEH_ORDER_ID) {
|
||||
next = v->cur_implicit_order_index;
|
||||
if (next >= this->GetNumOrders()) {
|
||||
next = this->GetFirstOrder();
|
||||
if (next == INVALID_VEH_ORDER_ID) return StationID::Invalid();
|
||||
if (next == INVALID_VEH_ORDER_ID) return {};
|
||||
} else {
|
||||
/* GetNext never returns INVALID_VEH_ORDER_ID if there is a valid station in the list.
|
||||
* As the given "next" is already valid and a station in the list, we
|
||||
@@ -392,9 +392,9 @@ StationIDStack OrderList::GetNextStoppingStation(const Vehicle *v, VehicleOrderI
|
||||
} else if (skip_to == INVALID_VEH_ORDER_ID || skip_to == first) {
|
||||
next = (advance == first) ? INVALID_VEH_ORDER_ID : advance;
|
||||
} else {
|
||||
StationIDStack st1 = this->GetNextStoppingStation(v, skip_to, hops);
|
||||
StationIDStack st2 = this->GetNextStoppingStation(v, advance, hops);
|
||||
while (!st2.IsEmpty()) st1.Push(st2.Pop());
|
||||
std::vector<StationID> st1 = this->GetNextStoppingStation(v, skip_to, hops);
|
||||
std::vector<StationID> st2 = this->GetNextStoppingStation(v, advance, hops);
|
||||
std::copy(st2.rbegin(), st2.rend(), std::back_inserter(st1));
|
||||
return st1;
|
||||
}
|
||||
++hops;
|
||||
@@ -404,11 +404,11 @@ StationIDStack OrderList::GetNextStoppingStation(const Vehicle *v, VehicleOrderI
|
||||
if (next == INVALID_VEH_ORDER_ID || ((orders[next].IsType(OT_GOTO_STATION) || orders[next].IsType(OT_IMPLICIT)) &&
|
||||
orders[next].GetDestination() == v->last_station_visited &&
|
||||
(orders[next].GetUnloadType() & (OUFB_TRANSFER | OUFB_UNLOAD)) != 0)) {
|
||||
return StationID::Invalid();
|
||||
return {};
|
||||
}
|
||||
} while (orders[next].IsType(OT_GOTO_DEPOT) || orders[next].GetDestination() == v->last_station_visited);
|
||||
|
||||
return orders[next].GetDestination().ToStationID();
|
||||
return {orders[next].GetDestination().ToStationID()};
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user