Fix: autoreplace command did not validate the vehicle argument properly (#9946)

It first checked if the vehicle was in the depot, which for some types
is only a valid action for the primary vehicle. Afterwards, it checked
if the vehicle was a primary vehicle.
This commit is contained in:
Patric Stout 2022-07-09 11:25:17 +02:00 committed by GitHub
parent 4651ad94fe
commit 9957675a66
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 1 deletions

View File

@ -725,7 +725,6 @@ CommandCost CmdAutoreplaceVehicle(DoCommandFlag flags, VehicleID veh_id)
CommandCost ret = CheckOwnership(v->owner);
if (ret.Failed()) return ret;
if (!v->IsChainInDepot()) return CMD_ERROR;
if (v->vehstatus & VS_CRASHED) return CMD_ERROR;
bool free_wagon = false;
@ -737,6 +736,7 @@ CommandCost CmdAutoreplaceVehicle(DoCommandFlag flags, VehicleID veh_id)
} else {
if (!v->IsPrimaryVehicle()) return CMD_ERROR;
}
if (!v->IsChainInDepot()) return CMD_ERROR;
const Company *c = Company::Get(_current_company);
bool wagon_removal = c->settings.renew_keep_length;