Changeset - r13289:26a0ed664dc0
[Not reviewed]
master
0 3 0
rubidium - 15 years ago 2009-10-18 17:53:34
rubidium@openttd.org
(svn r17808) -Codechange: remove write 'access' from all of CargoPacket's variables
3 files changed with 58 insertions and 16 deletions:
0 comments (0 inline, 0 general)
src/cargopacket.h
Show inline comments
 
@@ -37,11 +37,14 @@ extern const struct SaveLoad *GetCargoPa
 
 */
 
struct CargoPacket : CargoPacketPool::PoolItem<&_cargopacket_pool> {
 
private:
 
	/* Variables used by the CargoList cache. Only let them be modified via
 
	 * the proper accessor functions and/or CargoList itself. */
 
	Money feeder_share;     ///< Value of feeder pickup to be paid for on delivery of cargo
 
	uint16 count;           ///< The amount of cargo in this packet
 
	byte days_in_transit;   ///< Amount of days this packet has been in transit
 
	Money feeder_share;         ///< Value of feeder pickup to be paid for on delivery of cargo
 
	uint16 count;               ///< The amount of cargo in this packet
 
	byte days_in_transit;       ///< Amount of days this packet has been in transit
 
	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
 

	
 
	/** The CargoList caches, thus needs to know about it. */
 
	template <class Tinst> friend class CargoList;
 
@@ -53,12 +56,6 @@ public:
 
	/** Maximum number of items in a single cargo packet. */
 
	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
 
	 * @param source      the source of the packet
 
@@ -117,6 +114,51 @@ public:
 
		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(StationID sid);
src/economy.cpp
Show inline comments
 
@@ -1035,7 +1035,7 @@ void CargoPayment::PayFinalDelivery(cons
 
	}
 

	
 
	/* 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;
 

	
 
	/* The vehicle's profit is whatever route profit there is minus feeder shares. */
 
@@ -1053,7 +1053,7 @@ Money CargoPayment::PayTransfer(const Ca
 
	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),
 
		DistanceManhattan(cp->LoadedAtXY(), Station::Get(this->current_station)->xy),
 
		cp->DaysInTransit(),
 
		this->ct);
 

	
src/station_gui.cpp
Show inline comments
 
@@ -827,7 +827,7 @@ struct StationViewWindow : public Window
 
				const StationCargoList::List *packets = st->goods[i].cargo.Packets();
 
				for (StationCargoList::List::const_iterator it = packets->begin(); it != packets->end(); it++) {
 
					const CargoPacket *cp = *it;
 
					if (cp->source != station_id) {
 
					if (cp->SourceStation() != station_id) {
 
						bool added = false;
 

	
 
						/* 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 */
 
						for (CargoDataList::iterator jt = cargolist.begin(); jt != cargolist.end(); jt++) {
 
							CargoData *cd = &(*jt);
 
							if (cd->cargo == i && cd->source == cp->source) {
 
							if (cd->cargo == i && cd->source == cp->SourceStation()) {
 
								cd->count += cp->Count();
 
								added = true;
 
								break;
 
							}
 
						}
 

	
 
						if (!added) cargolist.push_back(CargoData(i, cp->source, cp->Count()));
 
						if (!added) cargolist.push_back(CargoData(i, cp->SourceStation(), cp->Count()));
 
					}
 
				}
 
			}
0 comments (0 inline, 0 general)