diff options
author | michi_cc <michi_cc@openttd.org> | 2012-04-17 19:44:16 +0000 |
---|---|---|
committer | michi_cc <michi_cc@openttd.org> | 2012-04-17 19:44:16 +0000 |
commit | 37e321044a1c32873980fc6d75c45011639ca2f3 (patch) | |
tree | aefe8b92c5cc387d178e23fad1dafd7cbc2aa872 /src/group_cmd.cpp | |
parent | 0daf3509227d476d7c869ce5c74906d7e3214565 (diff) | |
download | openttd-37e321044a1c32873980fc6d75c45011639ca2f3.tar.xz |
(svn r24139) -Add: Creating a new vehicle group by drag and drop. (Based on patch by Juanjo)
Diffstat (limited to 'src/group_cmd.cpp')
-rw-r--r-- | src/group_cmd.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/group_cmd.cpp b/src/group_cmd.cpp index a3587abbf..ca671e680 100644 --- a/src/group_cmd.cpp +++ b/src/group_cmd.cpp @@ -429,7 +429,7 @@ CommandCost CmdAddVehicleGroup(TileIndex tile, DoCommandFlag flags, uint32 p1, u Vehicle *v = Vehicle::GetIfValid(GB(p2, 0, 20)); GroupID new_g = p1; - if (v == NULL || (!Group::IsValidID(new_g) && !IsDefaultGroupID(new_g))) return CMD_ERROR; + if (v == NULL || (!Group::IsValidID(new_g) && !IsDefaultGroupID(new_g) && new_g != NEW_GROUP)) return CMD_ERROR; if (Group::IsValidID(new_g)) { Group *g = Group::Get(new_g); @@ -438,6 +438,14 @@ CommandCost CmdAddVehicleGroup(TileIndex tile, DoCommandFlag flags, uint32 p1, u if (v->owner != _current_company || !v->IsPrimaryVehicle()) return CMD_ERROR; + if (new_g == NEW_GROUP) { + /* Create new group. */ + CommandCost ret = CmdCreateGroup(0, flags, v->type, 0, NULL); + if (ret.Failed()) return ret; + + new_g = _new_group_id; + } + if (flags & DC_EXEC) { AddVehicleToGroup(v, new_g); |