summaryrefslogtreecommitdiff
path: root/src/cargo_type.h
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2012-01-20 20:18:19 +0000
committerrubidium <rubidium@openttd.org>2012-01-20 20:18:19 +0000
commit70c7fbd90eb0ace75d759725ba4d0085283f152c (patch)
treef807e537b9e78dff6442d4ec2a472217e84157d4 /src/cargo_type.h
parent15331fa03c5bd87c54ea51e57a9738e867f6bc2e (diff)
downloadopenttd-70c7fbd90eb0ace75d759725ba4d0085283f152c.tar.xz
(svn r23826) -Fix [FS#4972]: the detailed performance rating window showed the cargo count of the current quarter instead of the last quarter like the tooltip says
Diffstat (limited to 'src/cargo_type.h')
-rw-r--r--src/cargo_type.h27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/cargo_type.h b/src/cargo_type.h
index 5d3fa9ae5..7b7168a10 100644
--- a/src/cargo_type.h
+++ b/src/cargo_type.h
@@ -105,6 +105,33 @@ public:
{
return this->amount[cargo];
}
+
+ /**
+ * Get the sum of all cargo amounts.
+ * @return The sum.
+ */
+ template <typename T>
+ inline const T GetSum() const
+ {
+ T ret = 0;
+ for (size_t i = 0; i < lengthof(this->amount); i++) {
+ ret += this->amount[i];
+ }
+ return ret;
+ }
+
+ /**
+ * Get the amount of cargos that have an amount.
+ * @return The amount.
+ */
+ inline byte GetCount() const
+ {
+ byte count = 0;
+ for (size_t i = 0; i < lengthof(this->amount); i++) {
+ if (this->amount[i] != 0) count++;
+ }
+ return count;
+ }
};