diff options
author | rubidium <rubidium@openttd.org> | 2009-12-12 23:49:30 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2009-12-12 23:49:30 +0000 |
commit | 5477aec8fb7f7c10d3083051eb1cfc0ced9a09c4 (patch) | |
tree | 69cdd30377ddb8b9cdddcb822ba4ae892e422f68 | |
parent | d3e754fa6f4f213a79b29130fe54cdbd7950b546 (diff) | |
download | openttd-5477aec8fb7f7c10d3083051eb1cfc0ced9a09c4.tar.xz |
(svn r18474) -Fix (r18470): in some odd corner cases the group (vehicle) counts could be off
-rw-r--r-- | src/train_cmd.cpp | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp index 294f4a6c4..ceb039e01 100644 --- a/src/train_cmd.cpp +++ b/src/train_cmd.cpp @@ -1372,7 +1372,7 @@ CommandCost CmdMoveRailVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, u if (move_chain && src_head == dst_head) return CommandCost(); /* When moving a multiheaded part to be place after itself, bail out. */ - if (!move_chain && dst->IsRearDualheaded() && src == dst->other_multiheaded_part) return CommandCost(); + if (!move_chain && dst != NULL && dst->IsRearDualheaded() && src == dst->other_multiheaded_part) return CommandCost(); /* Check if all vehicles in the source train are stopped inside a depot. */ if (!src_head->IsStoppedInDepot()) return_cmd_error(STR_ERROR_TRAINS_CAN_ONLY_BE_ALTERED_INSIDE_A_DEPOT); @@ -1444,6 +1444,12 @@ CommandCost CmdMoveRailVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, u DeleteWindowById(WC_VEHICLE_DETAILS, src->index); DeleteWindowById(WC_VEHICLE_TIMETABLE, src->index); + /* We are going to be move to another train. So we + * are no part of this group anymore. In case we + * are not moving group... well, then we do not need + * to move. */ + if (dst_head != NULL && dst_head != src) DecreaseGroupNumVehicle(src->group_id); + /* Delete orders, group stuff and the unit number as we're not the * front of any vehicle anymore. */ DeleteVehicleOrders(src); @@ -1451,6 +1457,12 @@ CommandCost CmdMoveRailVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, u src->unitnumber = 0; } + /* We weren't a front engine but are becoming one. So + * we should be put in the default group. */ + if (original_src_head != src && dst_head == src) { + SetTrainGroupID(src, DEFAULT_GROUP); + } + /* Handle 'new engine' part of cases #1b, #2b, #3b, #4b and #5 in NormaliseTrainHead. */ NormaliseTrainHead(src_head); NormaliseTrainHead(dst_head); |