(svn r25891) -Feature: Use smallstack to allow for multiple next hops when loading and unloading.

This commit is contained in:
fonsinchen
2013-10-20 13:47:58 +00:00
parent dffc4d411e
commit 54db96be43
7 changed files with 54 additions and 67 deletions

View File

@@ -409,7 +409,7 @@ public:
void SetTransferLoadPlace(TileIndex xy);
bool Stage(bool accepted, StationID current_station, StationID next_station, uint8 order_flags, const GoodsEntry *ge, CargoPayment *payment);
bool Stage(bool accepted, StationID current_station, StationIDStack next_station, uint8 order_flags, const GoodsEntry *ge, CargoPayment *payment);
/**
* Marks all cargo in the vehicle as to be kept. This is mostly useful for
@@ -483,7 +483,7 @@ public:
bool ShiftCargo(Taction &action, StationID next);
template<class Taction>
uint ShiftCargo(Taction action, StationID next, bool include_invalid);
uint ShiftCargo(Taction action, StationIDStack next, bool include_invalid);
void Append(CargoPacket *cp, StationID next);
@@ -492,9 +492,13 @@ public:
* @param next Station the cargo is headed for.
* @return If there is any cargo for that station.
*/
inline bool HasCargoFor(StationID next) const
inline bool HasCargoFor(StationIDStack next) const
{
return this->packets.find(next) != this->packets.end();
while (!next.IsEmpty()) {
if (this->packets.find(next.Pop()) != this->packets.end()) return true;
}
/* Packets for INVALID_STTION can go anywhere. */
return this->packets.find(INVALID_STATION) != this->packets.end();
}
/**
@@ -539,8 +543,8 @@ public:
* amount of cargo to be moved. Second parameter is destination (if
* applicable), return value is amount of cargo actually moved. */
uint Reserve(uint max_move, VehicleCargoList *dest, TileIndex load_place, StationID next);
uint Load(uint max_move, VehicleCargoList *dest, TileIndex load_place, StationID next);
uint Reserve(uint max_move, VehicleCargoList *dest, TileIndex load_place, StationIDStack next);
uint Load(uint max_move, VehicleCargoList *dest, TileIndex load_place, StationIDStack next);
uint Truncate(uint max_move = UINT_MAX, StationCargoAmountMap *cargo_per_source = NULL);
uint Reroute(uint max_move, StationCargoList *dest, StationID avoid, StationID avoid2, const GoodsEntry *ge);