Codechange: Don't scan vehicle pool to find targeting disaster vehicle when deleting any vehicle. (#12064)

* Codechange: Don't scan vehicle pool to find targeting disaster vehicle when deleting any vehicle.

When deleting a vehicle, the vehicle pool is scanned to find a targetting disaster vehicle. With lots of vehicles this can take some time, especially when deleting multiple consecutive vehicles.

Disasters vehicles can actually only target road vehicles. Store the DisasterVehicle index in the road vehicle, so that no pool scan is necessary.

* Change: Small UFOs no longer target a vehicle which is already a target.
This commit is contained in:
Peter Nelson
2024-02-11 23:04:29 +00:00
committed by GitHub
parent fa6f270f23
commit df691eb31e
5 changed files with 44 additions and 17 deletions

View File

@@ -116,6 +116,8 @@ struct RoadVehicle final : public GroundVehicle<RoadVehicle, VEH_ROAD> {
RoadType roadtype; //!< Roadtype of this vehicle.
RoadTypes compatible_roadtypes; //!< Roadtypes this consist is powered on.
VehicleID disaster_vehicle = INVALID_VEHICLE; ///< NOSAVE: Disaster vehicle targetting this vehicle.
/** We don't want GCC to zero our struct! It already is zeroed and has an index! */
RoadVehicle() : GroundVehicleBase() {}
/** We want to 'destruct' the right class. */