(svn r14149) -Fix: When selling the front engine of a train consist with another engine at the second position, not all 'important' data was copied to the new head.
authorfrosch
Sat, 23 Aug 2008 23:31:27 +0000
changeset 9992 5e68b6f327fb
parent 9991 28905686e09b
child 9993 56936d41c036
(svn r14149) -Fix: When selling the front engine of a train consist with another engine at the second position, not all 'important' data was copied to the new head.
src/train_cmd.cpp
--- a/src/train_cmd.cpp	Sat Aug 23 23:15:04 2008 +0000
+++ b/src/train_cmd.cpp	Sat Aug 23 23:31:27 2008 +0000
@@ -1421,20 +1421,20 @@
 				 * promote it as a new train, retaining the unitnumber, orders */
 				if (new_f != NULL && IsTrainEngine(new_f)) {
 					switch_engine = true;
-					/* Copy important data from the front engine */
-					new_f->unitnumber      = first->unitnumber;
-					new_f->current_order   = first->current_order;
-					new_f->cur_order_index = first->cur_order_index;
-					new_f->orders          = first->orders;
-					new_f->num_orders      = first->num_orders;
 
 					/* Make sure the group counts stay correct. */
 					new_f->group_id        = first->group_id;
 					first->group_id        = DEFAULT_GROUP;
 
+					/* Copy orders (by sharing) */
+					new_f->orders          = first->orders;
+					new_f->num_orders      = first->num_orders;
 					new_f->AddToShared(first);
 					DeleteVehicleOrders(first);
 
+					/* Copy other important data from the front engine */
+					new_f->CopyVehicleConfigAndStatistics(first);
+
 					/* If we deleted a window then open a new one for the 'new' train */
 					if (IsLocalPlayer() && w != NULL) ShowVehicleViewWindow(new_f);
 				}