Pay all cargo payment incomes when cargo finally delivered

This commit is contained in:
Jonathan G Rennison
2018-01-26 18:28:57 +00:00
parent ea3948aa2d
commit 9000d74f3c
8 changed files with 191 additions and 12 deletions

View File

@@ -563,6 +563,9 @@ void ChangeOwnershipOfCompanyItems(Owner old_owner, Owner new_owner)
/* Change colour of existing windows */
if (new_owner != INVALID_OWNER) ChangeWindowOwner(old_owner, new_owner);
/* Change owner of deferred cargo payments */
ChangeOwnershipOfCargoPacketDeferredPayments(old_owner, new_owner);
cur_company.Restore();
MarkWholeScreenDirty();
@@ -1209,7 +1212,7 @@ CargoPayment::~CargoPayment()
* @param cp The cargo packet to pay for.
* @param count The number of packets to pay for.
*/
void CargoPayment::PayFinalDelivery(const CargoPacket *cp, uint count)
void CargoPayment::PayFinalDelivery(CargoPacket *cp, uint count)
{
if (this->owner == NULL) {
this->owner = Company::Get(this->front->owner);
@@ -1218,11 +1221,14 @@ void CargoPayment::PayFinalDelivery(const CargoPacket *cp, uint count)
/* Handle end of route payment */
Money profit = DeliverGoods(count, this->ct, this->current_station, cp->SourceStationXY(), cp->DaysInTransit(), this->owner, cp->SourceSubsidyType(), cp->SourceSubsidyID());
profit -= cp->FeederShare(count);
/* For Infrastructure patch. Handling transfers between other companies */
this->route_profit += profit - cp->FeederShare(count);
this->route_profit += profit;
cp->PayDeferredPayments();
/* The vehicle's profit is whatever route profit there is minus feeder shares. */
this->visual_profit += profit - cp->FeederShare(count);
this->visual_profit += profit;
}
/**
@@ -1231,7 +1237,7 @@ void CargoPayment::PayFinalDelivery(const CargoPacket *cp, uint count)
* @param count The number of packets to pay for.
* @return The amount of money paid for the transfer.
*/
Money CargoPayment::PayTransfer(const CargoPacket *cp, uint count)
Money CargoPayment::PayTransfer(CargoPacket *cp, uint count)
{
Money profit = GetTransportedGoodsIncome(
count,
@@ -1243,7 +1249,7 @@ Money CargoPayment::PayTransfer(const CargoPacket *cp, uint count)
profit = profit * _settings_game.economy.feeder_payment_share / 100;
/* For Infrastructure patch. Handling transfers between other companies */
this->route_profit += profit;
cp->RegisterDeferredCargoPayment(this->front->owner, this->front->type, profit);
this->visual_transfer += profit; // accumulate transfer profits for whole vehicle
return profit; // account for the (virtual) profit already made for the cargo packet