summaryrefslogtreecommitdiff
path: root/src/group_cmd.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/group_cmd.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/group_cmd.cpp')
-rw-r--r--src/group_cmd.cpp10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/group_cmd.cpp b/src/group_cmd.cpp
index c830d2f13..bc6018ac1 100644
--- a/src/group_cmd.cpp
+++ b/src/group_cmd.cpp
@@ -171,18 +171,22 @@ static bool IsUniqueGroupName(const char *name)
CommandCost CmdRenameGroup(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{
if (!IsValidGroupID(p1)) return CMD_ERROR;
- if (StrEmpty(_cmd_text) || strlen(_cmd_text) >= MAX_LENGTH_GROUP_NAME_BYTES) return CMD_ERROR;
Group *g = GetGroup(p1);
if (g->owner != _current_player) return CMD_ERROR;
- if (!IsUniqueGroupName(_cmd_text)) return_cmd_error(STR_NAME_MUST_BE_UNIQUE);
+ bool reset = StrEmpty(_cmd_text);
+
+ if (!reset) {
+ if (strlen(_cmd_text) >= MAX_LENGTH_GROUP_NAME_BYTES) return CMD_ERROR;
+ if (!IsUniqueGroupName(_cmd_text)) return_cmd_error(STR_NAME_MUST_BE_UNIQUE);
+ }
if (flags & DC_EXEC) {
/* Delete the old name */
free(g->name);
/* Assign the new one */
- g->name = strdup(_cmd_text);
+ g->name = reset ? NULL : strdup(_cmd_text);
InvalidateWindowData(GetWindowClassForVehicleType(g->vehicle_type), (g->vehicle_type << 11) | VLW_GROUP_LIST | _current_player);
}