summaryrefslogtreecommitdiff
path: root/src/station_cmd.cpp
diff options
context:
space:
mode:
authorJonathan G Rennison <j.g.rennison@gmail.com>2020-01-06 20:40:31 +0000
committerCharles Pigott <charlespigott@googlemail.com>2020-01-12 19:37:43 +0000
commitc3223903ed4f39abe8589355882b30b973da434e (patch)
tree9876dda172d7a076d7724efc52e21302bb7696a7 /src/station_cmd.cpp
parentf1734e7815653829d42ebd4def8c0d7d5aeae986 (diff)
downloadopenttd-c3223903ed4f39abe8589355882b30b973da434e.tar.xz
Codechange: Cache resolved town, station and industry name strings
Diffstat (limited to 'src/station_cmd.cpp')
-rw-r--r--src/station_cmd.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp
index 3b92f814b..adc2b0084 100644
--- a/src/station_cmd.cpp
+++ b/src/station_cmd.cpp
@@ -453,6 +453,22 @@ void UpdateAllStationVirtCoords()
}
}
+void BaseStation::FillCachedName() const
+{
+ char buf[MAX_LENGTH_STATION_NAME_CHARS * MAX_CHAR_LENGTH];
+ int64 args_array[] = { this->index };
+ StringParameters tmp_params(args_array);
+ char *end = GetStringWithArgs(buf, Waypoint::IsExpected(this) ? STR_WAYPOINT_NAME : STR_STATION_NAME, &tmp_params, lastof(buf));
+ this->cached_name.assign(buf, end);
+}
+
+void ClearAllStationCachedNames()
+{
+ for (BaseStation *st : BaseStation::Iterate()) {
+ st->cached_name.clear();
+ }
+}
+
/**
* Get a mask of the cargo types that the station accepts.
* @param st Station to query
@@ -3933,6 +3949,7 @@ CommandCost CmdRenameStation(TileIndex tile, DoCommandFlag flags, uint32 p1, uin
}
if (flags & DC_EXEC) {
+ st->cached_name.clear();
free(st->name);
st->name = reset ? nullptr : stredup(text);