diff options
author | Jonathan G Rennison <j.g.rennison@gmail.com> | 2020-01-06 20:40:31 +0000 |
---|---|---|
committer | Charles Pigott <charlespigott@googlemail.com> | 2020-01-12 19:37:43 +0000 |
commit | c3223903ed4f39abe8589355882b30b973da434e (patch) | |
tree | 9876dda172d7a076d7724efc52e21302bb7696a7 /src/industry.h | |
parent | f1734e7815653829d42ebd4def8c0d7d5aeae986 (diff) | |
download | openttd-c3223903ed4f39abe8589355882b30b973da434e.tar.xz |
Codechange: Cache resolved town, station and industry name strings
Diffstat (limited to 'src/industry.h')
-rw-r--r-- | src/industry.h | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/industry.h b/src/industry.h index f462cf482..e82033dd1 100644 --- a/src/industry.h +++ b/src/industry.h @@ -62,6 +62,7 @@ struct Industry : IndustryPool::PoolItem<&_industry_pool> { PartOfSubsidy part_of_subsidy; ///< NOSAVE: is this industry a source/destination of a subsidy? StationList stations_near; ///< NOSAVE: List of nearby stations. + mutable std::string cached_name; ///< NOSAVE: Cache of the resolved name of the industry Owner founder; ///< Founder of the industry Date construction_date; ///< Date of the construction of the industry @@ -157,10 +158,21 @@ struct Industry : IndustryPool::PoolItem<&_industry_pool> { memset(&counts, 0, sizeof(counts)); } + inline const char *GetCachedName() const + { + if (this->cached_name.empty()) this->FillCachedName(); + return this->cached_name.c_str(); + } + +private: + void FillCachedName() const; + protected: static uint16 counts[NUM_INDUSTRYTYPES]; ///< Number of industries per type ingame }; +void ClearAllIndustryCachedNames(); + void PlantRandomFarmField(const Industry *i); void ReleaseDisastersTargetingIndustry(IndustryID); |