Changeset - r13276:3604b09589ee
[Not reviewed]
master
0 4 0
rubidium - 15 years ago 2009-10-18 13:39:00
rubidium@openttd.org
(svn r17795) -Codechange: split cargolist into one for vehicles and one for stations.
4 files changed with 29 insertions and 12 deletions:
0 comments (0 inline, 0 general)
src/cargopacket.cpp
Show inline comments
 
@@ -90,7 +90,7 @@ void CargoList::AddToCache(const CargoPa
 
	this->cargo_days_in_transit += cp->days_in_transit * cp->count;
 
}
 

	
 
void CargoList::AgeCargo()
 
void VehicleCargoList::AgeCargo()
 
{
 
	for (List::const_iterator it = this->packets.begin(); it != this->packets.end(); it++) {
 
		/* If we're at the maximum, then we can't increase no more. */
src/cargopacket.h
Show inline comments
 
@@ -45,6 +45,8 @@ private:
 

	
 
	/** The CargoList caches, thus needs to know about it. */
 
	friend class CargoList;
 
	friend class VehicleCargoList;
 
	friend class StationCargoList;
 
	/** We want this to be saved, right? */
 
	friend const struct SaveLoad *GetCargoPacketDesc();
 
public:
 
@@ -143,9 +145,6 @@ public:
 
 */
 
#define FOR_ALL_CARGOPACKETS(var) FOR_ALL_CARGOPACKETS_FROM(var, 0)
 

	
 
extern const struct SaveLoad *GetGoodsDesc();
 
extern const SaveLoad *GetVehicleDescription(VehicleType vt);
 

	
 
/**
 
 * Simple collection class for a list of cargo packets
 
 */
 
@@ -162,7 +161,7 @@ public:
 
		MTA_UNLOAD,         ///< The cargo is moved as part of a forced unload
 
	};
 

	
 
private:
 
protected:
 
	Money feeder_share;         ///< Cache for the feeder share
 
	uint count;                 ///< Cache for the number of cargo entities
 
	uint cargo_days_in_transit; ///< Cache for the sum of number of days in transit of each entity; comparable to man-hours
 
@@ -184,11 +183,6 @@ private:
 
	void RemoveFromCache(const CargoPacket *cp);
 

	
 
public:
 
	/** The stations, via GoodsEntry, have a CargoList. */
 
	friend const struct SaveLoad *GetGoodsDesc();
 
	/** The vehicles have a cargo list too. */
 
	friend const SaveLoad *GetVehicleDescription(VehicleType vt);
 

	
 
	/** Create the cargo list */
 
	FORCEINLINE CargoList() { this->InvalidateCache(); }
 
	/** And destroy it ("frees" all cargo packets) */
 
@@ -297,4 +291,27 @@ public:
 
	void InvalidateCache();
 
};
 

	
 
/**
 
 * CargoList that is used for vehicles.
 
 */
 
class VehicleCargoList : public CargoList {
 
public:
 
	/** The vehicles have a cargo list (and we want that saved). */
 
	friend const struct SaveLoad *GetVehicleDescription(VehicleType vt);
 

	
 
	/**
 
	 * Ages the all cargo in this list
 
	 */
 
	void AgeCargo();
 
};
 

	
 
/**
 
 * CargoList that is used for stations.
 
 */
 
class StationCargoList : public CargoList {
 
public:
 
	/** The stations, via GoodsEntry, have a CargoList. */
 
	friend const struct SaveLoad *GetGoodsDesc();
 
};
 

	
 
#endif /* CARGOPACKET_H */
src/station_base.h
Show inline comments
 
@@ -44,7 +44,7 @@ struct GoodsEntry {
 
	byte rating;
 
	byte last_speed;
 
	byte last_age;
 
	CargoList cargo; ///< The cargo packets of cargo waiting in this station
 
	StationCargoList cargo; ///< The cargo packets of cargo waiting in this station
 
};
 

	
 

	
src/vehicle_base.h
Show inline comments
 
@@ -166,7 +166,7 @@ public:
 
	CargoID cargo_type;      ///< type of cargo this vehicle is carrying
 
	byte cargo_subtype;      ///< Used for livery refits (NewGRF variations)
 
	uint16 cargo_cap;        ///< total capacity
 
	CargoList cargo;         ///< The cargo this vehicle is carrying
 
	VehicleCargoList cargo;  ///< The cargo this vehicle is carrying
 

	
 
	byte day_counter;        ///< Increased by one for each day
 
	byte tick_counter;       ///< Increased by one for each tick
0 comments (0 inline, 0 general)