Fixed endless loop when out of resources upon receiving a GCI request.

This commit is contained in:
FlightControl_Master 2017-08-02 20:54:26 +02:00
parent 2501db53b8
commit 2cf1801f1d

View File

@ -2423,7 +2423,9 @@ do -- AI_A2A_DISPATCHER
local ClosestDistance = 0
local ClosestDefenderSquadronName = nil
while( DefendersCount > 0 ) do
local BreakLoop = false
while( DefendersCount > 0 and not BreakLoop ) do
for SquadronName, DefenderSquadron in pairs( self.DefenderSquadrons or {} ) do
for InterceptID, Intercept in pairs( DefenderSquadron.Gci or {} ) do
@ -2434,7 +2436,7 @@ do -- AI_A2A_DISPATCHER
local TargetCoord = DetectedItem.InterceptCoord
if TargetCoord then
local Distance = SpawnCoord:Get2DDistance( TargetCoord )
self:F( { Distance = Distance, TargetCoord = TargetCoord } )
self:F( { Distance = Distance, TargetCoord = TargetCoord } )
if ClosestDistance == 0 or Distance < ClosestDistance then
@ -2543,15 +2545,20 @@ do -- AI_A2A_DISPATCHER
AIGroup:Destroy()
end
end
end
end
end -- if DefenderGCI then
end -- while ( DefendersNeeded > 0 ) do
end
else
-- No more resources, try something else.
-- Subject for a later enhancement to try to depart from another squadron and disable this one.
BreakLoop = true
break
end
else
-- There isn't any closest airbase anymore, break the loop.
break
end
end
end -- if DefenderSquadron then
end