mirror of https://github.com/OpenTTD/OpenTTD.git
(svn r17808) -Codechange: remove write 'access' from all of CargoPacket's variables
This commit is contained in:
parent
f11cebfe9b
commit
e613107e02
|
@ -37,11 +37,14 @@ extern const struct SaveLoad *GetCargoPacketDesc();
|
||||||
*/
|
*/
|
||||||
struct CargoPacket : CargoPacketPool::PoolItem<&_cargopacket_pool> {
|
struct CargoPacket : CargoPacketPool::PoolItem<&_cargopacket_pool> {
|
||||||
private:
|
private:
|
||||||
/* Variables used by the CargoList cache. Only let them be modified via
|
Money feeder_share; ///< Value of feeder pickup to be paid for on delivery of cargo
|
||||||
* the proper accessor functions and/or CargoList itself. */
|
uint16 count; ///< The amount of cargo in this packet
|
||||||
Money feeder_share; ///< Value of feeder pickup to be paid for on delivery of cargo
|
byte days_in_transit; ///< Amount of days this packet has been in transit
|
||||||
uint16 count; ///< The amount of cargo in this packet
|
SourceTypeByte source_type; ///< Type of \c source_id
|
||||||
byte days_in_transit; ///< Amount of days this packet has been in transit
|
SourceID source_id; ///< Index of source, INVALID_SOURCE if unknown/invalid
|
||||||
|
StationID source; ///< The station where the cargo came from first
|
||||||
|
TileIndex source_xy; ///< The origin of the cargo (first station in feeder chain)
|
||||||
|
TileIndex loaded_at_xy; ///< Location where this cargo has been loaded into the vehicle
|
||||||
|
|
||||||
/** The CargoList caches, thus needs to know about it. */
|
/** The CargoList caches, thus needs to know about it. */
|
||||||
template <class Tinst> friend class CargoList;
|
template <class Tinst> friend class CargoList;
|
||||||
|
@ -53,12 +56,6 @@ public:
|
||||||
/** Maximum number of items in a single cargo packet. */
|
/** Maximum number of items in a single cargo packet. */
|
||||||
static const uint16 MAX_COUNT = UINT16_MAX;
|
static const uint16 MAX_COUNT = UINT16_MAX;
|
||||||
|
|
||||||
SourceTypeByte source_type; ///< Type of \c source_id
|
|
||||||
SourceID source_id; ///< Index of source, INVALID_SOURCE if unknown/invalid
|
|
||||||
StationID source; ///< The station where the cargo came from first
|
|
||||||
TileIndex source_xy; ///< The origin of the cargo (first station in feeder chain)
|
|
||||||
TileIndex loaded_at_xy; ///< Location where this cargo has been loaded into the vehicle
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new cargo packet
|
* Creates a new cargo packet
|
||||||
* @param source the source of the packet
|
* @param source the source of the packet
|
||||||
|
@ -117,6 +114,51 @@ public:
|
||||||
return this->days_in_transit;
|
return this->days_in_transit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the type of the cargo's source. industry, town or head quarter
|
||||||
|
* @return the source type
|
||||||
|
*/
|
||||||
|
FORCEINLINE SourceType SourceSubsidyType() const
|
||||||
|
{
|
||||||
|
return this->source_type;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the ID of the cargo's source. An IndustryID, TownID or CompanyID
|
||||||
|
* @return the source ID
|
||||||
|
*/
|
||||||
|
FORCEINLINE SourceID SourceSubsidyID() const
|
||||||
|
{
|
||||||
|
return this->source_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the ID of the station where the cargo was loaded for the first time
|
||||||
|
* @return the StationID
|
||||||
|
*/
|
||||||
|
FORCEINLINE SourceID SourceStation() const
|
||||||
|
{
|
||||||
|
return this->source;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the coordinates of the cargo's source station
|
||||||
|
* @return the source station's coordinates
|
||||||
|
*/
|
||||||
|
FORCEINLINE TileIndex SourceStationXY() const
|
||||||
|
{
|
||||||
|
return this->source_xy;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the coordinates of the cargo's last loading station
|
||||||
|
* @return the last loading station's coordinates
|
||||||
|
*/
|
||||||
|
FORCEINLINE TileIndex LoadedAtXY() const
|
||||||
|
{
|
||||||
|
return this->loaded_at_xy;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static void InvalidateAllFrom(SourceType src_type, SourceID src);
|
static void InvalidateAllFrom(SourceType src_type, SourceID src);
|
||||||
static void InvalidateAllFrom(StationID sid);
|
static void InvalidateAllFrom(StationID sid);
|
||||||
|
|
|
@ -1035,7 +1035,7 @@ void CargoPayment::PayFinalDelivery(const CargoPacket *cp, uint count)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Handle end of route payment */
|
/* Handle end of route payment */
|
||||||
Money profit = DeliverGoods(count, this->ct, this->current_station, cp->source_xy, cp->DaysInTransit(), this->owner, cp->source_type, cp->source_id);
|
Money profit = DeliverGoods(count, this->ct, this->current_station, cp->SourceStation(), cp->DaysInTransit(), this->owner, cp->SourceSubsidyType(), cp->SourceSubsidyID());
|
||||||
this->route_profit += profit;
|
this->route_profit += profit;
|
||||||
|
|
||||||
/* The vehicle's profit is whatever route profit there is minus feeder shares. */
|
/* The vehicle's profit is whatever route profit there is minus feeder shares. */
|
||||||
|
@ -1053,7 +1053,7 @@ Money CargoPayment::PayTransfer(const CargoPacket *cp, uint count)
|
||||||
Money profit = GetTransportedGoodsIncome(
|
Money profit = GetTransportedGoodsIncome(
|
||||||
count,
|
count,
|
||||||
/* pay transfer vehicle for only the part of transfer it has done: ie. cargo_loaded_at_xy to here */
|
/* 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),
|
DistanceManhattan(cp->LoadedAtXY(), Station::Get(this->current_station)->xy),
|
||||||
cp->DaysInTransit(),
|
cp->DaysInTransit(),
|
||||||
this->ct);
|
this->ct);
|
||||||
|
|
||||||
|
|
|
@ -827,7 +827,7 @@ struct StationViewWindow : public Window {
|
||||||
const StationCargoList::List *packets = st->goods[i].cargo.Packets();
|
const StationCargoList::List *packets = st->goods[i].cargo.Packets();
|
||||||
for (StationCargoList::List::const_iterator it = packets->begin(); it != packets->end(); it++) {
|
for (StationCargoList::List::const_iterator it = packets->begin(); it != packets->end(); it++) {
|
||||||
const CargoPacket *cp = *it;
|
const CargoPacket *cp = *it;
|
||||||
if (cp->source != station_id) {
|
if (cp->SourceStation() != station_id) {
|
||||||
bool added = false;
|
bool added = false;
|
||||||
|
|
||||||
/* Enable the expand/hide button for this cargo type */
|
/* Enable the expand/hide button for this cargo type */
|
||||||
|
@ -839,14 +839,14 @@ struct StationViewWindow : public Window {
|
||||||
/* Check if we already have this source in the list */
|
/* Check if we already have this source in the list */
|
||||||
for (CargoDataList::iterator jt = cargolist.begin(); jt != cargolist.end(); jt++) {
|
for (CargoDataList::iterator jt = cargolist.begin(); jt != cargolist.end(); jt++) {
|
||||||
CargoData *cd = &(*jt);
|
CargoData *cd = &(*jt);
|
||||||
if (cd->cargo == i && cd->source == cp->source) {
|
if (cd->cargo == i && cd->source == cp->SourceStation()) {
|
||||||
cd->count += cp->Count();
|
cd->count += cp->Count();
|
||||||
added = true;
|
added = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!added) cargolist.push_back(CargoData(i, cp->source, cp->Count()));
|
if (!added) cargolist.push_back(CargoData(i, cp->SourceStation(), cp->Count()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue