Codechange: Use std::string for most of the user-settable custom names.

This commit is contained in:
Michael Lutz
2020-05-17 23:31:59 +02:00
parent 9b6f5e3bb8
commit 63ccb36ef3
41 changed files with 160 additions and 177 deletions

View File

@@ -54,7 +54,7 @@ struct BaseStation : StationPool::PoolItem<&_station_pool> {
TrackedViewportSign sign; ///< NOSAVE: Dimensions of sign
byte delete_ctr; ///< Delete counter. If greater than 0 then it is decremented until it reaches 0; the waypoint is then is deleted.
char *name; ///< Custom name
std::string 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
@@ -111,7 +111,7 @@ struct BaseStation : StationPool::PoolItem<&_station_pool> {
inline const char *GetCachedName() const
{
if (this->name != nullptr) return this->name;
if (!this->name.empty()) return this->name.c_str();
if (this->cached_name.empty()) this->FillCachedName();
return this->cached_name.c_str();
}