From f11cebfe9b09bf5cf815d37ca6a19212755251ab Mon Sep 17 00:00:00 2001 From: rubidium Date: Sun, 18 Oct 2009 17:52:44 +0000 Subject: (svn r17807) -Codechange: move all 'updates' just after the 'load' constructor of CargoPackets to the constructor call itself --- src/cargopacket.cpp | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'src/cargopacket.cpp') diff --git a/src/cargopacket.cpp b/src/cargopacket.cpp index e9b3f5064..12e7dde29 100644 --- a/src/cargopacket.cpp +++ b/src/cargopacket.cpp @@ -40,11 +40,14 @@ CargoPacket::CargoPacket(StationID source, uint16 count, SourceType source_type, } } -CargoPacket::CargoPacket(uint16 count, byte days_in_transit, Money feeder_share, SourceType source_type, SourceID source_id) : +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) : feeder_share(feeder_share), count(count), days_in_transit(days_in_transit), - source_id(source_id) + source_id(source_id), + source(source), + source_xy(source_xy), + loaded_at_xy(loaded_at_xy) { this->source_type = source_type; } @@ -224,12 +227,7 @@ bool CargoList::MoveTo(Tother_inst *dest, uint max_move, CargoList::MoveT Money fs = cp->feeder_share * max_move / static_cast(cp->count); cp->feeder_share -= fs; - CargoPacket *cp_new = new CargoPacket(max_move, cp->days_in_transit, fs, cp->source_type, cp->source_id); - - cp_new->source = cp->source; - cp_new->source_xy = cp->source_xy; - cp_new->loaded_at_xy = (mta == MTA_CARGO_LOAD) ? data : cp->loaded_at_xy; - + CargoPacket *cp_new = new CargoPacket(max_move, cp->days_in_transit, cp->source, cp->source_xy, (mta == MTA_CARGO_LOAD) ? data : cp->loaded_at_xy, fs, cp->source_type, cp->source_id); this->RemoveFromCache(cp_new); // this reflects the changes in cp. if (mta == MTA_TRANSFER) { -- cgit v1.2.3-70-g09d2