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

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