diff options
Diffstat (limited to 'src/base_station_base.h')
-rw-r--r-- | src/base_station_base.h | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/base_station_base.h b/src/base_station_base.h index a1c935fce..0467866e5 100644 --- a/src/base_station_base.h +++ b/src/base_station_base.h @@ -56,6 +56,7 @@ struct BaseStation : StationPool::PoolItem<&_station_pool> { char *name; ///< Custom name StringID string_id; ///< Default name (town area) of station + mutable std::string cached_name; ///< NOSAVE: Cache of the resolved name of the station, if not using a custom name Town *town; ///< The town this station is associated with Owner owner; ///< The owner of this station @@ -108,6 +109,13 @@ struct BaseStation : StationPool::PoolItem<&_station_pool> { */ virtual void UpdateVirtCoord() = 0; + inline const char *GetCachedName() const + { + if (this->name != nullptr) return this->name; + if (this->cached_name.empty()) this->FillCachedName(); + return this->cached_name.c_str(); + } + virtual void MoveSign(TileIndex new_xy) { this->xy = new_xy; @@ -161,6 +169,9 @@ struct BaseStation : StationPool::PoolItem<&_station_pool> { } static void PostDestructor(size_t index); + +private: + void FillCachedName() const; }; /** |