Fix #11307: Incorrect GroupStatistics after selling leading wagon
When this results in a countable consist
This commit is contained in:
@@ -2334,7 +2334,8 @@ CommandCost CmdSellRailWagon(DoCommandFlag flags, Vehicle *t, uint16 data, uint3
|
|||||||
/* 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()) {
|
||||||
|
if (v->IsEngine()) {
|
||||||
/* We are selling the front engine. In this case we want to
|
/* We are selling the front engine. In this case we want to
|
||||||
* 'give' the order, unit number and such to the new head. */
|
* 'give' the order, unit number and such to the new head. */
|
||||||
new_head->orders = first->orders;
|
new_head->orders = first->orders;
|
||||||
@@ -2345,7 +2346,8 @@ CommandCost CmdSellRailWagon(DoCommandFlag flags, Vehicle *t, uint16 data, uint3
|
|||||||
new_head->CopyVehicleConfigAndStatistics(first);
|
new_head->CopyVehicleConfigAndStatistics(first);
|
||||||
new_head->speed_restriction = first->speed_restriction;
|
new_head->speed_restriction = first->speed_restriction;
|
||||||
SB(Train::From(new_head)->flags, VRF_SPEED_ADAPTATION_EXEMPT, 1, GB(Train::From(first)->flags, VRF_SPEED_ADAPTATION_EXEMPT, 1));
|
SB(Train::From(new_head)->flags, VRF_SPEED_ADAPTATION_EXEMPT, 1, GB(Train::From(first)->flags, VRF_SPEED_ADAPTATION_EXEMPT, 1));
|
||||||
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() && data & (MAKE_ORDER_BACKUP_FLAG >> 20)) {
|
} else if (v->IsPrimaryVehicle() && data & (MAKE_ORDER_BACKUP_FLAG >> 20)) {
|
||||||
OrderBackup::Backup(v, user);
|
OrderBackup::Backup(v, user);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user