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

@@ -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();
}