diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/cargopacket.cpp | 12 | ||||
-rw-r--r-- | src/cargopacket.h | 1 | ||||
-rw-r--r-- | src/station.cpp | 6 |
3 files changed, 14 insertions, 5 deletions
diff --git a/src/cargopacket.cpp b/src/cargopacket.cpp index 313e7db4f..e9b3f5064 100644 --- a/src/cargopacket.cpp +++ b/src/cargopacket.cpp @@ -62,6 +62,18 @@ CargoPacket::CargoPacket(uint16 count, byte days_in_transit, Money feeder_share, } } +/** + * Invalidates (sets source to INVALID_STATION) all cargo packets from given station + * @param sid the station that gets removed + */ +/* static */ void CargoPacket::InvalidateAllFrom(StationID sid) +{ + CargoPacket *cp; + FOR_ALL_CARGOPACKETS(cp) { + if (cp->source == sid) cp->source_id = INVALID_SOURCE; + } +} + /* * * Cargo list implementation diff --git a/src/cargopacket.h b/src/cargopacket.h index a29a1ff22..ee0e2163a 100644 --- a/src/cargopacket.h +++ b/src/cargopacket.h @@ -116,6 +116,7 @@ public: static void InvalidateAllFrom(SourceType src_type, SourceID src); + static void InvalidateAllFrom(StationID sid); }; /** diff --git a/src/station.cpp b/src/station.cpp index 1ac0341c0..ba0020c73 100644 --- a/src/station.cpp +++ b/src/station.cpp @@ -97,11 +97,7 @@ Station::~Station() this->goods[c].cargo.Truncate(0); } - CargoPacket *cp; - FOR_ALL_CARGOPACKETS(cp) { - /* Don't allow cargo packets with invalid source station */ - if (cp->source == this->index) cp->source = INVALID_STATION; - } + CargoPacket::InvalidateAllFrom(this->index); } |