diff options
author | michi_cc <michi_cc@openttd.org> | 2011-11-15 20:47:53 +0000 |
---|---|---|
committer | michi_cc <michi_cc@openttd.org> | 2011-11-15 20:47:53 +0000 |
commit | 6548ec6e9ecf0f6d608d0b738213f62b1ce6e584 (patch) | |
tree | d8e94705bf49526712eda2cc81588d9b5fac8ee3 /src/town_type.h | |
parent | 88aaeb4092e563f9e894608fc27d507d4693f188 (diff) | |
download | openttd-6548ec6e9ecf0f6d608d0b738213f62b1ce6e584.tar.xz |
(svn r23233) -Codechange: Refactor maximum and actually transported cargo amount of towns into a reusable struct.
Diffstat (limited to 'src/town_type.h')
-rw-r--r-- | src/town_type.h | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/town_type.h b/src/town_type.h index 14d840cb0..39deb6167 100644 --- a/src/town_type.h +++ b/src/town_type.h @@ -107,4 +107,22 @@ typedef SimpleTinyEnumT<TownFounding, byte> TownFoundingByte; static const uint MAX_LENGTH_TOWN_NAME_CHARS = 32; ///< The maximum length of a town name in characters including '\0' +/** Store the maximum and actually transported cargo amount for the current and the last month. */ +template <typename Tstorage> +struct TransportedCargoStat { + Tstorage old_max; ///< Maximum amount last month + Tstorage new_max; ///< Maximum amount this month + Tstorage old_act; ///< Actually transported last month + Tstorage new_act; ///< Actually transported this month + + TransportedCargoStat() : old_max(0), new_max(0), old_act(0), new_act(0) {} + + /** Update stats for a new month. */ + void NewMonth() + { + this->old_max = this->new_max; this->new_max = 0; + this->old_act = this->new_act; this->new_act = 0; + } +}; + #endif /* TOWN_TYPE_H */ |