mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-07-17 09:25:24 +01:00
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:
parent
4651ad94fe
commit
9957675a66
@ -725,7 +725,6 @@ CommandCost CmdAutoreplaceVehicle(DoCommandFlag flags, VehicleID veh_id)
|
|||||||
CommandCost ret = CheckOwnership(v->owner);
|
CommandCost ret = CheckOwnership(v->owner);
|
||||||
if (ret.Failed()) return ret;
|
if (ret.Failed()) return ret;
|
||||||
|
|
||||||
if (!v->IsChainInDepot()) return CMD_ERROR;
|
|
||||||
if (v->vehstatus & VS_CRASHED) return CMD_ERROR;
|
if (v->vehstatus & VS_CRASHED) return CMD_ERROR;
|
||||||
|
|
||||||
bool free_wagon = false;
|
bool free_wagon = false;
|
||||||
@ -737,6 +736,7 @@ CommandCost CmdAutoreplaceVehicle(DoCommandFlag flags, VehicleID veh_id)
|
|||||||
} else {
|
} else {
|
||||||
if (!v->IsPrimaryVehicle()) return CMD_ERROR;
|
if (!v->IsPrimaryVehicle()) return CMD_ERROR;
|
||||||
}
|
}
|
||||||
|
if (!v->IsChainInDepot()) return CMD_ERROR;
|
||||||
|
|
||||||
const Company *c = Company::Get(_current_company);
|
const Company *c = Company::Get(_current_company);
|
||||||
bool wagon_removal = c->settings.renew_keep_length;
|
bool wagon_removal = c->settings.renew_keep_length;
|
||||||
|
Loading…
Reference in New Issue
Block a user