diff options
-rw-r--r-- | src/cargopacket.cpp | 21 | ||||
-rw-r--r-- | src/cargopacket.h | 12 | ||||
-rw-r--r-- | src/station_cmd.cpp | 2 |
3 files changed, 22 insertions, 13 deletions
diff --git a/src/cargopacket.cpp b/src/cargopacket.cpp index e2dbf900d..f2614c9b7 100644 --- a/src/cargopacket.cpp +++ b/src/cargopacket.cpp @@ -26,18 +26,20 @@ void InitializeCargoPackets() _cargopacket_pool.CleanPool(); } -CargoPacket::CargoPacket(StationID source, uint16 count, SourceType source_type, SourceID source_id) : +CargoPacket::CargoPacket() +{ + this->source_type = ST_INDUSTRY; + this->source_id = INVALID_SOURCE; +} + +CargoPacket::CargoPacket(StationID source, TileIndex source_xy, uint16 count, SourceType source_type, SourceID source_id) : count(count), source_id(source_id), - source(source) + source(source), + source_xy(source_xy) { - this->source_type = source_type; - - if (source != INVALID_STATION) { - assert(count != 0); - this->source_xy = Station::Get(source)->xy; - this->loaded_at_xy = this->source_xy; - } + assert(count != 0); + this->source_type = source_type; } CargoPacket::CargoPacket(uint16 count, byte days_in_transit, StationID source, TileIndex source_xy, TileIndex loaded_at_xy, Money feeder_share, SourceType source_type, SourceID source_id) : @@ -49,6 +51,7 @@ CargoPacket::CargoPacket(uint16 count, byte days_in_transit, StationID source, T source_xy(source_xy), loaded_at_xy(loaded_at_xy) { + assert(count != 0); this->source_type = source_type; } diff --git a/src/cargopacket.h b/src/cargopacket.h index 13970e18e..17528e516 100644 --- a/src/cargopacket.h +++ b/src/cargopacket.h @@ -57,14 +57,20 @@ public: static const uint16 MAX_COUNT = UINT16_MAX; /** + * Create a new packet for savegame loading. + */ + CargoPacket(); + + /** * Creates a new cargo packet - * @param source the source of the packet + * @param source the source station of the packet + * @param source_xy the source location of the packet * @param count the number of cargo entities to put in this packet * @param source_type the 'type' of source the packet comes from (for subsidies) * @param source_id the actual source of the packet (for subsidies) - * @pre count != 0 || source == INVALID_STATION + * @pre count != 0 */ - CargoPacket(StationID source = INVALID_STATION, uint16 count = 0, SourceType source_type = ST_INDUSTRY, SourceID source_id = INVALID_SOURCE); + CargoPacket(StationID source, TileIndex source_xy, uint16 count, SourceType source_type, SourceID source_id); /** * Creates a new cargo packet. Initializes the fields that cannot be changed later. diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp index 42c57f1f1..746202868 100644 --- a/src/station_cmd.cpp +++ b/src/station_cmd.cpp @@ -2911,7 +2911,7 @@ void ModifyStationRatingAround(TileIndex tile, Owner owner, int amount, uint rad static void UpdateStationWaiting(Station *st, CargoID type, uint amount, SourceType source_type, SourceID source_id) { - st->goods[type].cargo.Append(new CargoPacket(st->index, amount, source_type, source_id)); + st->goods[type].cargo.Append(new CargoPacket(st->index, st->xy, amount, source_type, source_id)); SetBit(st->goods[type].acceptance_pickup, GoodsEntry::PICKUP); StationAnimationTrigger(st, st->xy, STAT_ANIM_NEW_CARGO, type); |