diff options
author | Niels Martin Hansen <nielsm@indvikleren.dk> | 2018-07-26 19:29:54 +0200 |
---|---|---|
committer | Niels Martin Hansen <nielsm@indvikleren.dk> | 2018-11-03 21:43:54 +0100 |
commit | e66cec8f86357918c58b20bd3cc67330f277a5e1 (patch) | |
tree | 1d34c8882bdc3fa2150ebcd06ea5e9ce247cd68a /src/industry.h | |
parent | 8859381d301a60169e167431c97cb084b7730ead (diff) | |
download | openttd-e66cec8f86357918c58b20bd3cc67330f277a5e1.tar.xz |
Add: NewGRF support for 16-in-16-out industries
Diffstat (limited to 'src/industry.h')
-rw-r--r-- | src/industry.h | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/src/industry.h b/src/industry.h index 42cf3aff2..af0208b3c 100644 --- a/src/industry.h +++ b/src/industry.h @@ -12,6 +12,7 @@ #ifndef INDUSTRY_H #define INDUSTRY_H +#include <algorithm> #include "newgrf_storage.h" #include "subsidy_type.h" #include "industry_map.h" @@ -64,7 +65,7 @@ struct Industry : IndustryPool::PoolItem<&_industry_pool> { OwnerByte founder; ///< Founder of the industry Date construction_date; ///< Date of the construction of the industry uint8 construction_type; ///< Way the industry was constructed (@see IndustryConstructionType) - Date last_cargo_accepted_at; ///< Last day cargo was accepted by this industry + Date last_cargo_accepted_at[INDUSTRY_NUM_INPUTS]; ///< Last day each cargo type was accepted by this industry byte selected_layout; ///< Which tile layout was used when creating the industry uint16 random; ///< Random value used for randomisation of all kinds of things @@ -86,6 +87,22 @@ struct Industry : IndustryPool::PoolItem<&_industry_pool> { return IsTileType(tile, MP_INDUSTRY) && GetIndustryIndex(tile) == this->index; } + inline int GetCargoProducedIndex(CargoID cargo) const + { + if (cargo == CT_INVALID) return -1; + const CargoID *pos = std::find(this->produced_cargo, endof(this->produced_cargo), cargo); + if (pos == endof(this->produced_cargo)) return -1; + return pos - this->produced_cargo; + } + + inline int GetCargoAcceptedIndex(CargoID cargo) const + { + if (cargo == CT_INVALID) return -1; + const CargoID *pos = std::find(this->accepts_cargo, endof(this->accepts_cargo), cargo); + if (pos == endof(this->accepts_cargo)) return -1; + return pos - this->accepts_cargo; + } + /** * Get the industry of the given tile * @param tile the tile to get the industry from |