diff options
Diffstat (limited to 'src/waypoint.cpp')
-rw-r--r-- | src/waypoint.cpp | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/src/waypoint.cpp b/src/waypoint.cpp index cc7415367..f455dde5f 100644 --- a/src/waypoint.cpp +++ b/src/waypoint.cpp @@ -386,26 +386,24 @@ CommandCost CmdRenameWaypoint(TileIndex tile, uint32 flags, uint32 p1, uint32 p2 Waypoint *wp = GetWaypoint(p1); if (!CheckOwnership(wp->owner)) return CMD_ERROR; - if (!StrEmpty(_cmd_text)) { + bool reset = StrEmpty(_cmd_text); + + if (!reset) { if (strlen(_cmd_text) >= MAX_LENGTH_WAYPOINT_NAME_BYTES) return CMD_ERROR; if (!IsUniqueWaypointName(_cmd_text)) return_cmd_error(STR_NAME_MUST_BE_UNIQUE); + } - if (flags & DC_EXEC) { - free(wp->name); - wp->name = strdup(_cmd_text); - wp->town_cn = 0; + if (flags & DC_EXEC) { + free(wp->name); - UpdateWaypointSign(wp); - MarkWholeScreenDirty(); + if (reset) { + MakeDefaultWaypointName(wp); // sets wp->name = NULL + } else { + wp->name = strdup(_cmd_text); } - } else { - if (flags & DC_EXEC) { - free(wp->name); - MakeDefaultWaypointName(wp); - UpdateWaypointSign(wp); - MarkWholeScreenDirty(); - } + UpdateWaypointSign(wp); + MarkWholeScreenDirty(); } return CommandCost(); } |