mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-12 18:40:29 +00:00
Fix #11307: Incorrect GroupStatistics after selling leading wagon
When this results in a countable consist
This commit is contained in:
parent
14bcfff6f5
commit
3afb732c37
@ -1421,16 +1421,18 @@ CommandCost CmdSellRailWagon(DoCommandFlag flags, Vehicle *t, bool sell_chain, b
|
|||||||
/* First normalise the sub types of the chain. */
|
/* First normalise the sub types of the chain. */
|
||||||
NormaliseSubtypes(new_head);
|
NormaliseSubtypes(new_head);
|
||||||
|
|
||||||
if (v == first && v->IsEngine() && !sell_chain && new_head != nullptr && new_head->IsFrontEngine()) {
|
if (v == first && !sell_chain && new_head != nullptr && new_head->IsFrontEngine()) {
|
||||||
/* We are selling the front engine. In this case we want to
|
if (v->IsEngine()) {
|
||||||
* 'give' the order, unit number and such to the new head. */
|
/* We are selling the front engine. In this case we want to
|
||||||
new_head->orders = first->orders;
|
* 'give' the order, unit number and such to the new head. */
|
||||||
new_head->AddToShared(first);
|
new_head->orders = first->orders;
|
||||||
DeleteVehicleOrders(first);
|
new_head->AddToShared(first);
|
||||||
|
DeleteVehicleOrders(first);
|
||||||
|
|
||||||
/* Copy other important data from the front engine */
|
/* Copy other important data from the front engine */
|
||||||
new_head->CopyVehicleConfigAndStatistics(first);
|
new_head->CopyVehicleConfigAndStatistics(first);
|
||||||
GroupStatistics::CountVehicle(new_head, 1); // after copying over the profit
|
}
|
||||||
|
GroupStatistics::CountVehicle(new_head, 1); // after copying over the profit, if required
|
||||||
} else if (v->IsPrimaryVehicle() && backup_order) {
|
} else if (v->IsPrimaryVehicle() && backup_order) {
|
||||||
OrderBackup::Backup(v, user);
|
OrderBackup::Backup(v, user);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user