diff options
author | Michael Lutz <michi@icosahedron.de> | 2020-05-17 23:31:59 +0200 |
---|---|---|
committer | Michael Lutz <michi@icosahedron.de> | 2020-05-21 20:02:34 +0200 |
commit | 63ccb36ef3ecd53a503c0e9fea87f0784802af0f (patch) | |
tree | d3e1134029fd437d1ad2d948f83592b930e9456f /src/station_cmd.cpp | |
parent | 9b6f5e3bb850b6cff02cc761767fcdf49c681645 (diff) | |
download | openttd-63ccb36ef3ecd53a503c0e9fea87f0784802af0f.tar.xz |
Codechange: Use std::string for most of the user-settable custom names.
Diffstat (limited to 'src/station_cmd.cpp')
-rw-r--r-- | src/station_cmd.cpp | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp index 6cfd94bb2..7bce21353 100644 --- a/src/station_cmd.cpp +++ b/src/station_cmd.cpp @@ -3917,7 +3917,7 @@ static uint UpdateStationWaiting(Station *st, CargoID type, uint amount, SourceT static bool IsUniqueStationName(const char *name) { for (const Station *st : Station::Iterate()) { - if (st->name != nullptr && strcmp(st->name, name) == 0) return false; + if (!st->name.empty() && st->name == name) return false; } return true; @@ -3949,8 +3949,11 @@ 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); + if (reset) { + st->name.clear(); + } else { + st->name = text; + } st->UpdateVirtCoord(); InvalidateWindowData(WC_STATION_LIST, st->owner, 1); |