File diff r18781:e1de9a06f7cd → r18782:6453522c2154
src/cargopacket.h
Show inline comments
 
@@ -60,91 +60,91 @@ public:
 
	CargoPacket(uint16 count, byte days_in_transit, StationID source, TileIndex source_xy, TileIndex loaded_at_xy, Money feeder_share = 0, SourceType source_type = ST_INDUSTRY, SourceID source_id = INVALID_SOURCE);
 

	
 
	/** Destroy the packet. */
 
	~CargoPacket() { }
 

	
 
	CargoPacket *Split(uint new_size);
 
	void Merge(CargoPacket *cp);
 

	
 
	/**
 
	 * Gets the number of 'items' in this packet.
 
	 * @return Item count.
 
	 */
 
	FORCEINLINE uint16 Count() const
 
	inline uint16 Count() const
 
	{
 
		return this->count;
 
	}
 

	
 
	/**
 
	 * Gets the amount of money already paid to earlier vehicles in
 
	 * the feeder chain.
 
	 * @return Feeder share.
 
	 */
 
	FORCEINLINE Money FeederShare() const
 
	inline Money FeederShare() const
 
	{
 
		return this->feeder_share;
 
	}
 

	
 
	/**
 
	 * Gets the number of days this cargo has been in transit.
 
	 * This number isn't really in days, but in 2.5 days (CARGO_AGING_TICKS = 185 ticks) and
 
	 * it is capped at 255.
 
	 * @return Length this cargo has been in transit.
 
	 */
 
	FORCEINLINE byte DaysInTransit() const
 
	inline byte DaysInTransit() const
 
	{
 
		return this->days_in_transit;
 
	}
 

	
 
	/**
 
	 * Gets the type of the cargo's source. industry, town or head quarter.
 
	 * @return Source type.
 
	 */
 
	FORCEINLINE SourceType SourceSubsidyType() const
 
	inline SourceType SourceSubsidyType() const
 
	{
 
		return this->source_type;
 
	}
 

	
 
	/**
 
	 * Gets the ID of the cargo's source. An IndustryID, TownID or CompanyID.
 
	 * @return Source ID.
 
	 */
 
	FORCEINLINE SourceID SourceSubsidyID() const
 
	inline SourceID SourceSubsidyID() const
 
	{
 
		return this->source_id;
 
	}
 

	
 
	/**
 
	 * Gets the ID of the station where the cargo was loaded for the first time.
 
	 * @return StationID.
 
	 */
 
	FORCEINLINE SourceID SourceStation() const
 
	inline SourceID SourceStation() const
 
	{
 
		return this->source;
 
	}
 

	
 
	/**
 
	 * Gets the coordinates of the cargo's source station.
 
	 * @return Source station's coordinates.
 
	 */
 
	FORCEINLINE TileIndex SourceStationXY() const
 
	inline TileIndex SourceStationXY() const
 
	{
 
		return this->source_xy;
 
	}
 

	
 
	/**
 
	 * Gets the coordinates of the cargo's last loading station.
 
	 * @return Last loading station's coordinates.
 
	 */
 
	FORCEINLINE TileIndex LoadedAtXY() const
 
	inline TileIndex LoadedAtXY() const
 
	{
 
		return this->loaded_at_xy;
 
	}
 

	
 

	
 
	static void InvalidateAllFrom(SourceType src_type, SourceID src);
 
	static void InvalidateAllFrom(StationID sid);
 
	static void AfterLoad();
 
};
 

	
 
/**
 
 * Iterate over all _valid_ cargo packets from the given start.
 
@@ -194,61 +194,61 @@ protected:
 
public:
 
	/** Create the cargo list. */
 
	CargoList() {}
 

	
 
	~CargoList();
 

	
 
	void OnCleanPool();
 

	
 
	/**
 
	 * Returns a pointer to the cargo packet list (so you can iterate over it etc).
 
	 * @return Pointer to the packet list.
 
	 */
 
	FORCEINLINE const List *Packets() const
 
	inline const List *Packets() const
 
	{
 
		return &this->packets;
 
	}
 

	
 
	/**
 
	 * Checks whether this list is empty.
 
	 * @return True if and only if the list is empty.
 
	 */
 
	FORCEINLINE bool Empty() const
 
	inline bool Empty() const
 
	{
 
		return this->count == 0;
 
	}
 

	
 
	/**
 
	 * Returns the number of cargo entities in this list.
 
	 * @return The before mentioned number.
 
	 */
 
	FORCEINLINE uint Count() const
 
	inline uint Count() const
 
	{
 
		return this->count;
 
	}
 

	
 
	/**
 
	 * Returns source of the first cargo packet in this list.
 
	 * @return The before mentioned source.
 
	 */
 
	FORCEINLINE StationID Source() const
 
	inline StationID Source() const
 
	{
 
		return this->Empty() ? INVALID_STATION : this->packets.front()->source;
 
	}
 

	
 
	/**
 
	 * Returns average number of days in transit for a cargo entity.
 
	 * @return The before mentioned number.
 
	 */
 
	FORCEINLINE uint DaysInTransit() const
 
	inline uint DaysInTransit() const
 
	{
 
		return this->count == 0 ? 0 : this->cargo_days_in_transit / this->count;
 
	}
 

	
 

	
 
	void Append(CargoPacket *cp);
 
	void Truncate(uint max_remaining);
 

	
 
	template <class Tother_inst>
 
	bool MoveTo(Tother_inst *dest, uint count, MoveToAction mta, CargoPayment *payment, uint data = 0);
 

	
 
	void InvalidateCache();
 
@@ -268,25 +268,25 @@ protected:
 
	void RemoveFromCache(const CargoPacket *cp);
 

	
 
public:
 
	/** The super class ought to know what it's doing. */
 
	friend class CargoList<VehicleCargoList>;
 
	/** The vehicles have a cargo list (and we want that saved). */
 
	friend const struct SaveLoad *GetVehicleDescription(VehicleType vt);
 

	
 
	/**
 
	 * Returns total sum of the feeder share for all packets.
 
	 * @return The before mentioned number.
 
	 */
 
	FORCEINLINE Money FeederShare() const
 
	inline Money FeederShare() const
 
	{
 
		return this->feeder_share;
 
	}
 

	
 
	void AgeCargo();
 

	
 
	void InvalidateCache();
 

	
 
	/**
 
	 * Are two the two CargoPackets mergeable in the context of
 
	 * a list of CargoPackets for a Vehicle?
 
	 * @param cp1 First CargoPacket.