summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/cargopacket.cpp2
-rw-r--r--src/cargopacket.h35
-rw-r--r--src/station_base.h2
-rw-r--r--src/vehicle_base.h2
4 files changed, 29 insertions, 12 deletions
diff --git a/src/cargopacket.cpp b/src/cargopacket.cpp
index 5f964c5e3..ec42fe6b3 100644
--- a/src/cargopacket.cpp
+++ b/src/cargopacket.cpp
@@ -90,7 +90,7 @@ void CargoList::AddToCache(const CargoPacket *cp)
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. */
diff --git a/src/cargopacket.h b/src/cargopacket.h
index e29bb2045..be725b133 100644
--- a/src/cargopacket.h
+++ b/src/cargopacket.h
@@ -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 */
diff --git a/src/station_base.h b/src/station_base.h
index 5c047f03f..b912a4357 100644
--- a/src/station_base.h
+++ b/src/station_base.h
@@ -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
};
diff --git a/src/vehicle_base.h b/src/vehicle_base.h
index f733297eb..10ab41047 100644
--- a/src/vehicle_base.h
+++ b/src/vehicle_base.h
@@ -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