Changeset - r27928:312b50d8ddd9
[Not reviewed]
master
0 1 0
Jonathan G Rennison - 9 months ago 2023-09-17 12:24:07
j.g.rennison@gmail.com
Fix #11307: Incorrect GroupStatistics after selling leading wagon

When this results in a countable consist
1 file changed with 12 insertions and 10 deletions:
0 comments (0 inline, 0 general)
src/train_cmd.cpp
Show inline comments
 
@@ -1421,16 +1421,18 @@ CommandCost CmdSellRailWagon(DoCommandFl
 
		/* First normalise the sub types of the chain. */
 
		NormaliseSubtypes(new_head);
 

	
 
		if (v == first && v->IsEngine() && !sell_chain && new_head != nullptr && new_head->IsFrontEngine()) {
 
			/* We are selling the front engine. In this case we want to
 
			 * 'give' the order, unit number and such to the new head. */
 
			new_head->orders = first->orders;
 
			new_head->AddToShared(first);
 
			DeleteVehicleOrders(first);
 

	
 
			/* Copy other important data from the front engine */
 
			new_head->CopyVehicleConfigAndStatistics(first);
 
			GroupStatistics::CountVehicle(new_head, 1); // after copying over the profit
 
		if (v == first && !sell_chain && new_head != nullptr && new_head->IsFrontEngine()) {
 
			if (v->IsEngine()) {
 
				/* We are selling the front engine. In this case we want to
 
				 * 'give' the order, unit number and such to the new head. */
 
				new_head->orders = first->orders;
 
				new_head->AddToShared(first);
 
				DeleteVehicleOrders(first);
 

	
 
				/* Copy other important data from the front engine */
 
				new_head->CopyVehicleConfigAndStatistics(first);
 
			}
 
			GroupStatistics::CountVehicle(new_head, 1); // after copying over the profit, if required
 
		} else if (v->IsPrimaryVehicle() && backup_order) {
 
			OrderBackup::Backup(v, user);
 
		}
0 comments (0 inline, 0 general)