mirror of https://github.com/OpenTTD/OpenTTD
Codechange: Remove owner from CargoPayment. (#14411)
Owner can instead be looked up from the CargoPayment's vehicle. This reduces the size of each CargoPayment slightly.pull/14392/head
parent
febba930b0
commit
16b0371c1b
|
@ -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. */
|
||||
|
|
|
@ -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<CargoPayment, CargoPaymentID, 512>;
|
||||
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue