Fix Vehicle::CopyVehicleConfigAndStatistics not releasing unit number

See: https://github.com/OpenTTD/OpenTTD/issues/12388
This commit is contained in:
Jonathan G Rennison
2024-03-27 19:25:03 +00:00
parent afaf452534
commit 315dd62bd9
3 changed files with 15 additions and 2 deletions

View File

@@ -3710,6 +3710,17 @@ void Vehicle::ResetRefitCaps()
for (Vehicle *v = this; v != nullptr; v = v->Next()) v->refit_cap = v->cargo_cap;
}
/**
* Release the vehicle's unit number.
*/
void Vehicle::ReleaseUnitNumber()
{
if (this->unitnumber != 0) {
Company::Get(this->owner)->freeunits[this->type].ReleaseID(this->unitnumber);
this->unitnumber = 0;
}
}
static bool ShouldVehicleContinueWaiting(Vehicle *v)
{
if (v->GetNumOrders() < 1) return false;