Fix: depot-related commands did not validate depot tiles properly (#9948)
The bug comes in two slices: 1) the functions never actually checked if "tile" was a depot tile. This allowed executing the function on tile 0, where are the things like shadows of aircrafts are. 2) BuildDepotVehicleList() first checked if a vehicle is in a depot before checking if it was a primary vehicle. This is invalid for aircraft. Fixing the first hides the second, and fixing the second makes the first non-exploitable. But, fixing both felt like the best thing to do.
This commit is contained in:
@@ -634,6 +634,7 @@ CommandCost CmdMassStartStopVehicle(DoCommandFlag flags, TileIndex tile, bool do
|
||||
if (vehicle_list_window) {
|
||||
if (!GenerateVehicleSortList(&list, vli)) return CMD_ERROR;
|
||||
} else {
|
||||
if (!IsDepotTile(tile) || !IsTileOwner(tile, _current_company)) return CMD_ERROR;
|
||||
/* Get the list of vehicles in the depot */
|
||||
BuildDepotVehicleList(vli.vtype, tile, &list, nullptr);
|
||||
}
|
||||
@@ -666,6 +667,7 @@ CommandCost CmdDepotSellAllVehicles(DoCommandFlag flags, TileIndex tile, Vehicle
|
||||
CommandCost cost(EXPENSES_NEW_VEHICLES);
|
||||
|
||||
if (!IsCompanyBuildableVehicleType(vehicle_type)) return CMD_ERROR;
|
||||
if (!IsDepotTile(tile) || !IsTileOwner(tile, _current_company)) return CMD_ERROR;
|
||||
|
||||
/* Get the list of vehicles in the depot */
|
||||
BuildDepotVehicleList(vehicle_type, tile, &list, &list);
|
||||
|
Reference in New Issue
Block a user