summaryrefslogtreecommitdiff
path: root/src/cargopacket.h
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2013-04-13 13:42:08 +0000
committerfrosch <frosch@openttd.org>2013-04-13 13:42:08 +0000
commit5eddbb338b7838c01087921c77c0738fc12cbfb2 (patch)
treee1d1b917bc00b6e7e43aad49188c98b635887b12 /src/cargopacket.h
parent8d1d521456c57b69243853b369ecc60de0421e33 (diff)
downloadopenttd-5eddbb338b7838c01087921c77c0738fc12cbfb2.tar.xz
(svn r25185) -Fix [FS#5508]: Remove ambivalent functions CargoList::Empty() and Count(), and replace them with VehicleCargoList::StoredCount(), TotalCount(), StationCargoList::AvailableCount() and TotalCount(). (fonsinchen)
Diffstat (limited to 'src/cargopacket.h')
-rw-r--r--src/cargopacket.h54
1 files changed, 32 insertions, 22 deletions
diff --git a/src/cargopacket.h b/src/cargopacket.h
index bffc845ea..15b233fd0 100644
--- a/src/cargopacket.h
+++ b/src/cargopacket.h
@@ -249,30 +249,12 @@ public:
}
/**
- * Checks whether this list is empty.
- * @return True if and only if the list is empty.
- */
- inline bool Empty() const
- {
- return this->count == 0;
- }
-
- /**
- * Returns the number of cargo entities in this list.
- * @return The before mentioned number.
- */
- inline uint Count() const
- {
- return this->count;
- }
-
- /**
* Returns source of the first cargo packet in this list.
* @return The before mentioned source.
*/
inline StationID Source() const
{
- return this->Empty() ? INVALID_STATION : this->packets.front()->source;
+ return this->count == 0 ? INVALID_STATION : this->packets.front()->source;
}
/**
@@ -354,12 +336,30 @@ public:
* reserved).
* @return Cargo on board the vehicle.
*/
- inline uint OnboardCount() const
+ inline uint StoredCount() const
{
return this->count - this->action_counts[MTA_LOAD];
}
/**
+ * Returns sum of cargo, including reserved cargo.
+ * @return Sum of cargo.
+ */
+ inline uint TotalCount() const
+ {
+ return this->count;
+ }
+
+ /**
+ * Returns sum of reserved cargo.
+ * @return Sum of reserved cargo.
+ */
+ inline uint ReservedCount() const
+ {
+ return this->action_counts[MTA_LOAD];
+ }
+
+ /**
* Returns sum of cargo to be moved out of the vehicle at the current station.
* @return Cargo to be moved.
*/
@@ -446,6 +446,16 @@ public:
friend class CargoReturn;
/**
+ * Returns sum of cargo still available for loading at the sation.
+ * (i.e. not counting cargo which is already reserved for loading)
+ * @return Cargo on board the vehicle.
+ */
+ inline uint AvailableCount() const
+ {
+ return this->count;
+ }
+
+ /**
* Returns sum of cargo reserved for loading onto vehicles.
* @return Cargo reserved for loading.
*/
@@ -455,8 +465,8 @@ public:
}
/**
- * Returns total count of cargo, including reserved cargo that's not
- * actually in the list.
+ * Returns total count of cargo at the station, including
+ * cargo which is already reserved for loading.
* @return Total cargo count.
*/
inline uint TotalCount() const