diff options
author | fonsinchen <fonsinchen@openttd.org> | 2013-10-20 13:47:58 +0000 |
---|---|---|
committer | fonsinchen <fonsinchen@openttd.org> | 2013-10-20 13:47:58 +0000 |
commit | 54db96be43bbb94f3d5193647be2f787a192f358 (patch) | |
tree | 170110df7e7d1653f10bf55acb686495e019dc67 /src/cargopacket.h | |
parent | dffc4d411e64269f5dd6678a8a5d599dd50bc82c (diff) | |
download | openttd-54db96be43bbb94f3d5193647be2f787a192f358.tar.xz |
(svn r25891) -Feature: Use smallstack to allow for multiple next hops when loading and unloading.
Diffstat (limited to 'src/cargopacket.h')
-rw-r--r-- | src/cargopacket.h | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/src/cargopacket.h b/src/cargopacket.h index c4ea9e144..3ae9e9927 100644 --- a/src/cargopacket.h +++ b/src/cargopacket.h @@ -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); |