1
0
mirror of https://github.com/OpenTTD/OpenTTD.git synced 2025-09-02 03:19:10 +00:00

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

@@ -29,7 +29,7 @@
static bool IsUniqueDepotName(const char *name)
{
for (const Depot *d : Depot::Iterate()) {
if (d->name != nullptr && strcmp(d->name, name) == 0) return false;
if (!d->name.empty() && d->name == name) return false;
}
return true;
@@ -60,13 +60,11 @@ CommandCost CmdRenameDepot(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
}
if (flags & DC_EXEC) {
free(d->name);
if (reset) {
d->name = nullptr;
d->name.clear();
MakeDefaultName(d);
} else {
d->name = stredup(text);
d->name = text;
}
/* Update the orders and depot */