mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Use the best aircraft rather than first found.
The priority list was guiding the purchase decision which largely meant that this was working correctly, but there were suboptimal cases where the list was being taken in FIFO order by purchased type. This fixes the search to be locally optimal, although this does still mean that a worse but closer aircraft will be chosen over a better but slightly farther away aircraft. We'd need to have a quality vs distance rating to do better. Fixes https://github.com/dcs-liberation/dcs_liberation/issues/755
This commit is contained in:
@@ -162,10 +162,10 @@ class AircraftAllocator:
|
||||
if not airfield.is_friendly(self.is_player):
|
||||
continue
|
||||
inventory = self.global_inventory.for_control_point(airfield)
|
||||
for aircraft, available in inventory.all_aircraft:
|
||||
for aircraft in types:
|
||||
if not airfield.can_operate(aircraft):
|
||||
continue
|
||||
if aircraft in types and available >= flight.num_aircraft:
|
||||
if inventory.available(aircraft) >= flight.num_aircraft:
|
||||
inventory.remove_aircraft(aircraft, flight.num_aircraft)
|
||||
return airfield, aircraft
|
||||
|
||||
|
||||
Reference in New Issue
Block a user