(svn r23233) -Codechange: Refactor maximum and actually transported cargo amount of towns into a reusable struct.
This commit is contained in:
@@ -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 */
|
||||
|
Reference in New Issue
Block a user