diff --git a/src/economy.cpp b/src/economy.cpp index 03ed9a9053..50bdc26a62 100644 --- a/src/economy.cpp +++ b/src/economy.cpp @@ -466,9 +466,6 @@ void ChangeOwnershipOfCompanyItems(Owner old_owner, Owner new_owner) auto &unitidgen = new_company->freeunits[v->type]; v->unitnumber = unitidgen.UseID(unitidgen.NextID()); } - - /* Invalidate the vehicle's cargo payment "owner cache". */ - if (v->cargo_payment != nullptr) v->cargo_payment->owner = nullptr; } } @@ -1218,12 +1215,8 @@ CargoPayment::~CargoPayment() */ void CargoPayment::PayFinalDelivery(CargoType cargo, const CargoPacket *cp, uint count, TileIndex current_tile) { - if (this->owner == nullptr) { - this->owner = Company::Get(this->front->owner); - } - /* Handle end of route payment */ - Money profit = DeliverGoods(count, cargo, this->current_station, cp->GetDistance(current_tile), cp->GetPeriodsInTransit(), this->owner, cp->GetSource()); + Money profit = DeliverGoods(count, cargo, this->current_station, cp->GetDistance(current_tile), cp->GetPeriodsInTransit(), Company::Get(this->front->owner), cp->GetSource()); this->route_profit += profit; /* The vehicle's profit is whatever route profit there is minus feeder shares. */ diff --git a/src/economy_base.h b/src/economy_base.h index ca5e2ae7fe..4f9c9dc945 100644 --- a/src/economy_base.h +++ b/src/economy_base.h @@ -11,7 +11,6 @@ #define ECONOMY_BASE_H #include "cargopacket.h" -#include "company_type.h" /** Type of pool to store cargo payments in; little over 1 million. */ using CargoPaymentPool = Pool; @@ -24,7 +23,6 @@ extern CargoPaymentPool _cargo_payment_pool; struct CargoPayment : CargoPaymentPool::PoolItem<&_cargo_payment_pool> { /* CargoPaymentID index member of CargoPaymentPool is 4 bytes. */ StationID current_station = StationID::Invalid(); ///< NOSAVE: The current station - Company *owner = nullptr; ///< NOSAVE: The owner of the vehicle Vehicle *front = nullptr; ///< The front vehicle to do the payment of Money route_profit = 0; ///< The amount of money to add/remove from the bank account