diff options
author | rubidium <rubidium@openttd.org> | 2009-10-06 17:23:15 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2009-10-06 17:23:15 +0000 |
commit | 5f59d0c5b4e85a3bb51936fa05b2c5493f571eca (patch) | |
tree | ca2af53f7c2c4af662725813b62d480a3748954d /src/economy.cpp | |
parent | a4835e3f0b8c0d4f330fc8e91bdd529af60cc7a3 (diff) | |
download | openttd-5f59d0c5b4e85a3bb51936fa05b2c5493f571eca.tar.xz |
(svn r17720) -Codechange: guard the CargoPacket variables that are cached in CargoLists so they cannot be written from outside the CargoList class (based on patch by fonsinchen)
Diffstat (limited to 'src/economy.cpp')
-rw-r--r-- | src/economy.cpp | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/src/economy.cpp b/src/economy.cpp index faa043b62..15951bafe 100644 --- a/src/economy.cpp +++ b/src/economy.cpp @@ -1028,36 +1028,37 @@ CargoPayment::~CargoPayment() * @param cp The cargo packet to pay for. * @param count The number of packets to pay for. */ -void CargoPayment::PayFinalDelivery(CargoPacket *cp, uint count) +void CargoPayment::PayFinalDelivery(const CargoPacket *cp, uint count) { if (this->owner == NULL) { this->owner = Company::Get(this->front->owner); } /* Handle end of route payment */ - Money profit = DeliverGoods(count, this->ct, this->current_station, cp->source_xy, cp->days_in_transit, this->owner, cp->source_type, cp->source_id); + Money profit = DeliverGoods(count, this->ct, this->current_station, cp->source_xy, cp->DaysInTransit(), this->owner, cp->source_type, cp->source_id); this->route_profit += profit; /* The vehicle's profit is whatever route profit there is minus feeder shares. */ - this->visual_profit += profit - cp->feeder_share; + this->visual_profit += profit - cp->FeederShare(); } /** * Handle payment for transfer of the given cargo packet. - * @param cp The cargo packet to pay for. + * @param cp The cargo packet to pay for; actual payment won't be made!. * @param count The number of packets to pay for. + * @return The amount of money paid for the transfer. */ -void CargoPayment::PayTransfer(CargoPacket *cp, uint count) +Money CargoPayment::PayTransfer(const CargoPacket *cp, uint count) { Money profit = GetTransportedGoodsIncome( count, /* pay transfer vehicle for only the part of transfer it has done: ie. cargo_loaded_at_xy to here */ DistanceManhattan(cp->loaded_at_xy, Station::Get(this->current_station)->xy), - cp->days_in_transit, + cp->DaysInTransit(), this->ct); this->visual_profit += profit; // accumulate transfer profits for whole vehicle - cp->feeder_share += profit; // account for the (virtual) profit already made for the cargo packet + return profit; // account for the (virtual) profit already made for the cargo packet } /** |