Mercurial > hg > openttd
changeset 18832:1d0a58216701 draft
(svn r23681) -Fix [FS#4914]: vehicle numbers got misaccounted when autoreplacing failed due to length checks
author | rubidium <rubidium@openttd.org> |
---|---|
date | Wed, 28 Dec 2011 17:34:44 +0000 |
parents | 1080223f1dc7 |
children | da4cf42b7840 |
files | src/train_cmd.cpp |
diffstat | 1 files changed, 7 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/src/train_cmd.cpp +++ b/src/train_cmd.cpp @@ -1200,11 +1200,9 @@ Train *original_src_head = src_head; Train *original_dst_head = (dst_head == src_head ? NULL : dst_head); - if (flags & DC_EXEC) { - /* Remove old heads from the statistics */ - if (original_src_head != NULL && original_src_head->IsFrontEngine()) GroupStatistics::CountVehicle(original_src_head, -1); - if (original_dst_head != NULL && original_dst_head->IsFrontEngine()) GroupStatistics::CountVehicle(original_dst_head, -1); - } + /* We want this information from before the rearrangement, but execute this after the validation. */ + bool original_src_head_front_engine = original_src_head != NULL && original_src_head->IsFrontEngine(); + bool original_dst_head_front_engine = original_dst_head != NULL && original_dst_head->IsFrontEngine(); /* (Re)arrange the trains in the wanted arrangement. */ ArrangeTrains(&dst_head, dst, &src_head, src, move_chain); @@ -1224,6 +1222,10 @@ /* do it? */ if (flags & DC_EXEC) { + /* Remove old heads from the statistics */ + if (original_src_head_front_engine) GroupStatistics::CountVehicle(original_src_head, -1); + if (original_dst_head_front_engine) GroupStatistics::CountVehicle(original_dst_head, -1); + /* First normalise the sub types of the chains. */ NormaliseSubtypes(src_head); NormaliseSubtypes(dst_head);