summaryrefslogtreecommitdiff
path: root/src/waypoint_cmd.cpp
diff options
context:
space:
mode:
authorMichael Lutz <michi@icosahedron.de>2020-05-17 23:31:59 +0200
committerMichael Lutz <michi@icosahedron.de>2020-05-21 20:02:34 +0200
commit63ccb36ef3ecd53a503c0e9fea87f0784802af0f (patch)
treed3e1134029fd437d1ad2d948f83592b930e9456f /src/waypoint_cmd.cpp
parent9b6f5e3bb850b6cff02cc761767fcdf49c681645 (diff)
downloadopenttd-63ccb36ef3ecd53a503c0e9fea87f0784802af0f.tar.xz
Codechange: Use std::string for most of the user-settable custom names.
Diffstat (limited to 'src/waypoint_cmd.cpp')
-rw-r--r--src/waypoint_cmd.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/waypoint_cmd.cpp b/src/waypoint_cmd.cpp
index 51d791fc2..01cdbc16e 100644
--- a/src/waypoint_cmd.cpp
+++ b/src/waypoint_cmd.cpp
@@ -398,7 +398,7 @@ CommandCost RemoveBuoy(TileIndex tile, DoCommandFlag flags)
static bool IsUniqueWaypointName(const char *name)
{
for (const Waypoint *wp : Waypoint::Iterate()) {
- if (wp->name != nullptr && strcmp(wp->name, name) == 0) return false;
+ if (!wp->name.empty() && wp->name == name) return false;
}
return true;
@@ -431,8 +431,11 @@ CommandCost CmdRenameWaypoint(TileIndex tile, DoCommandFlag flags, uint32 p1, ui
}
if (flags & DC_EXEC) {
- free(wp->name);
- wp->name = reset ? nullptr : stredup(text);
+ if (reset) {
+ wp->name.clear();
+ } else {
+ wp->name = text;
+ }
wp->UpdateVirtCoord();
}