summaryrefslogtreecommitdiff
path: root/src/waypoint.cpp
diff options
context:
space:
mode:
authorsmatz <smatz@openttd.org>2008-09-15 19:02:50 +0000
committersmatz <smatz@openttd.org>2008-09-15 19:02:50 +0000
commit1266b1a73f4197e3bf4d2cc0e09e9e667d7c640e (patch)
tree9ea3e279046e9a622321db881df0c37605fde380 /src/waypoint.cpp
parent42f33890aa4612a821c20783778bb086ee2028b6 (diff)
downloadopenttd-1266b1a73f4197e3bf4d2cc0e09e9e667d7c640e.tar.xz
(svn r14334) -Feature: ability to reset name to default/automatic value (for vehicles, engines, towns, groups, stations, waypoints, managers and companies)
Diffstat (limited to 'src/waypoint.cpp')
-rw-r--r--src/waypoint.cpp26
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();
}