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:
@@ -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()
|
||||
|
Reference in New Issue
Block a user