diff options
author | smatz <smatz@openttd.org> | 2008-09-15 19:02:50 +0000 |
---|---|---|
committer | smatz <smatz@openttd.org> | 2008-09-15 19:02:50 +0000 |
commit | 1266b1a73f4197e3bf4d2cc0e09e9e667d7c640e (patch) | |
tree | 9ea3e279046e9a622321db881df0c37605fde380 /src/station_cmd.cpp | |
parent | 42f33890aa4612a821c20783778bb086ee2028b6 (diff) | |
download | openttd-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/station_cmd.cpp')
-rw-r--r-- | src/station_cmd.cpp | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp index 056e0d620..1160f433d 100644 --- a/src/station_cmd.cpp +++ b/src/station_cmd.cpp @@ -2814,17 +2814,20 @@ static bool IsUniqueStationName(const char *name) CommandCost CmdRenameStation(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) { if (!IsValidStationID(p1)) return CMD_ERROR; - if (StrEmpty(_cmd_text) || strlen(_cmd_text) >= MAX_LENGTH_STATION_NAME_BYTES) return CMD_ERROR; Station *st = GetStation(p1); - if (!CheckOwnership(st->owner)) return CMD_ERROR; - if (!IsUniqueStationName(_cmd_text)) return_cmd_error(STR_NAME_MUST_BE_UNIQUE); + bool reset = StrEmpty(_cmd_text); + + if (!reset) { + if (strlen(_cmd_text) >= MAX_LENGTH_STATION_NAME_BYTES) return CMD_ERROR; + if (!IsUniqueStationName(_cmd_text)) return_cmd_error(STR_NAME_MUST_BE_UNIQUE); + } if (flags & DC_EXEC) { free(st->name); - st->name = strdup(_cmd_text); + st->name = reset ? NULL : strdup(_cmd_text); UpdateStationVirtCoord(st); InvalidateWindowData(WC_STATION_LIST, st->owner, 1); |