(svn r21205) -Fix [FS#4207]: Under some conditions, group count would be wrong after moving train engines in the depot window.

This commit is contained in:
terkhen 2010-11-16 12:05:41 +00:00
parent 0f2a9877b8
commit d7aa9a6bd1

View File

@ -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. * 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. * b) the 'next' part is an engine that becomes a front engine.
* c) there is no 'next' part, nothing else happens * 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. * 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. * b) the 'next' part is an engine that becomes a front engine.
* 4) free wagon gets moved * 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_DETAILS, src->index);
DeleteWindowById(WC_VEHICLE_TIMETABLE, src->index); DeleteWindowById(WC_VEHICLE_TIMETABLE, src->index);
/* We are going to be move to another train. So we /* We are going to be moved to a different train, and
* are no part of this group anymore. In case we * we were the front engine of the original train. */
* are not moving group... well, then we do not need if (dst_head != NULL && dst_head != src && (src_head == NULL || !src_head->IsFrontEngine())) {
* to move. DecreaseGroupNumVehicle(src->group_id);
* Or we are moving to later in the train and our }
* new head isn't a front engine anymore.
*/ /* The front engine is going to be moved later in the
if (dst_head != NULL ? dst_head != src : !src_head->IsFrontEngine()) { * current train, and it will not be a train anymore. */
if (dst_head == NULL && !src_head->IsFrontEngine()) {
DecreaseGroupNumVehicle(src->group_id); DecreaseGroupNumVehicle(src->group_id);
} }
@ -1288,6 +1289,12 @@ CommandCost CmdMoveRailVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, u
src->unitnumber = 0; 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 weren't a front engine but are becoming one. So
* we should be put in the default group. */ * we should be put in the default group. */
if (original_src_head != src && dst_head == src) { if (original_src_head != src && dst_head == src) {