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:
@@ -80,21 +80,21 @@ void BuildDepotVehicleList(VehicleType type, TileIndex tile, VehicleList *engine
|
||||
case VEH_TRAIN: {
|
||||
const Train *t = Train::From(v);
|
||||
if (t->IsArticulatedPart() || t->IsRearDualheaded()) continue;
|
||||
if (t->track != TRACK_BIT_DEPOT) continue;
|
||||
if (!t->IsInDepot()) continue;
|
||||
if (wagons != nullptr && t->First()->IsFreeWagon()) {
|
||||
if (individual_wagons || t->IsFreeWagon()) wagons->push_back(t);
|
||||
continue;
|
||||
}
|
||||
if (!t->IsPrimaryVehicle()) continue;
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
if (!v->IsPrimaryVehicle()) continue;
|
||||
if (!v->IsInDepot()) continue;
|
||||
break;
|
||||
}
|
||||
|
||||
if (!v->IsPrimaryVehicle()) continue;
|
||||
|
||||
engines->push_back(v);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user