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

@@ -862,6 +862,8 @@ void Vehicle::PreDestructor()
/* Leave the drive through roadstop, when you have not already left it. */
RoadStop::GetByTile(v->tile, GetRoadStopType(v->tile))->Leave(v);
}
if (v->disaster_vehicle != INVALID_VEHICLE) ReleaseDisasterVehicle(v->disaster_vehicle);
}
if (this->Previous() == nullptr) {
@@ -884,8 +886,6 @@ void Vehicle::PreDestructor()
DeleteDepotHighlightOfVehicle(this);
StopGlobalFollowVehicle(this);
ReleaseDisastersTargetingVehicle(this->index);
}
Vehicle::~Vehicle()