diff options
author | terkhen <terkhen@openttd.org> | 2010-11-16 12:05:41 +0000 |
---|---|---|
committer | terkhen <terkhen@openttd.org> | 2010-11-16 12:05:41 +0000 |
commit | d7aa9a6bd111abb562e5ff3852e57845dda75d80 (patch) | |
tree | 196d846a51a2c7ef3ef32e8a612720f2c2b8436f | |
parent | 0f2a9877b8fd2032872e9b23d5e6a8b1b1f13200 (diff) | |
download | openttd-d7aa9a6bd111abb562e5ff3852e57845dda75d80.tar.xz |
(svn r21205) -Fix [FS#4207]: Under some conditions, group count would be wrong after moving train engines in the depot window.
-rw-r--r-- | src/train_cmd.cpp | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp index a073c7e33..bb3e1d797 100644 --- a/src/train_cmd.cpp +++ b/src/train_cmd.cpp @@ -1251,7 +1251,7 @@ CommandCost CmdMoveRailVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, u * a) the 'next' part is a wagon that becomes a free wagon chain. * b) the 'next' part is an engine that becomes a front engine. * c) there is no 'next' part, nothing else happens - * 3) front engine gets moved to later in the current train, it is not an engine anymore. + * 3) front engine gets moved to later in the current train, it is not a front engine anymore. * a) the 'next' part is a wagon that becomes a free wagon chain. * b) the 'next' part is an engine that becomes a front engine. * 4) free wagon gets moved @@ -1270,14 +1270,15 @@ 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. - * Or we are moving to later in the train and our - * new head isn't a front engine anymore. - */ - if (dst_head != NULL ? dst_head != src : !src_head->IsFrontEngine()) { + /* We are going to be moved to a different train, and + * we were the front engine of the original train. */ + if (dst_head != NULL && dst_head != src && (src_head == NULL || !src_head->IsFrontEngine())) { + DecreaseGroupNumVehicle(src->group_id); + } + + /* The front engine is going to be moved later in the + * current train, and it will not be a train anymore. */ + if (dst_head == NULL && !src_head->IsFrontEngine()) { DecreaseGroupNumVehicle(src->group_id); } @@ -1288,6 +1289,12 @@ CommandCost CmdMoveRailVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, u src->unitnumber = 0; } + /* We were a front engine and we are becoming one for a different train. + * Increase the group counter accordingly. */ + if (original_src_head == src && dst_head == src) { + IncreaseGroupNumVehicle(src->group_id); + } + /* 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) { |