Fixes to resolve exceptions in multi player situations

This commit is contained in:
FlightControl 2017-07-08 05:54:33 +02:00
parent 367c4d74af
commit 8e2aef17e7
3 changed files with 117 additions and 109 deletions

View File

@ -1724,6 +1724,7 @@ do -- AI_A2A_DISPATCHER
self:E( { DefenderSquadron } ) self:E( { DefenderSquadron } )
local SpawnCoord = DefenderSquadron.Airbase:GetCoordinate() -- Core.Point#COORDINATE local SpawnCoord = DefenderSquadron.Airbase:GetCoordinate() -- Core.Point#COORDINATE
local TargetCoord = Target.Set:GetFirst():GetCoordinate() local TargetCoord = Target.Set:GetFirst():GetCoordinate()
if TargetCoord then
local Distance = SpawnCoord:Get2DDistance( TargetCoord ) local Distance = SpawnCoord:Get2DDistance( TargetCoord )
if ClosestDistance == 0 or Distance < ClosestDistance then if ClosestDistance == 0 or Distance < ClosestDistance then
@ -1736,6 +1737,7 @@ do -- AI_A2A_DISPATCHER
end end
end end
end end
end
if ClosestDefenderSquadronName then if ClosestDefenderSquadronName then

View File

@ -1170,7 +1170,7 @@ do -- Players
-- @return #nil The group has no players -- @return #nil The group has no players
function GROUP:GetPlayerNames() function GROUP:GetPlayerNames()
local PlayerNames = nil local PlayerNames = {}
local Units = self:GetUnits() local Units = self:GetUnits()
for UnitID, UnitData in pairs( Units ) do for UnitID, UnitData in pairs( Units ) do

View File

@ -598,12 +598,17 @@ end
-- @param #UNIT self -- @param #UNIT self
function UNIT:GetThreatLevel() function UNIT:GetThreatLevel()
local Attributes = self:GetDesc().attributes
self:T( Attributes )
local ThreatLevel = 0 local ThreatLevel = 0
local ThreatText = "" local ThreatText = ""
local Descriptor = self:GetDesc()
if Descriptor then
local Attributes = Descriptor.attributes
self:T( Attributes )
if self:IsGround() then if self:IsGround() then
self:T( "Ground" ) self:T( "Ground" )
@ -715,6 +720,7 @@ function UNIT:GetThreatLevel()
ThreatText = ThreatLevels[ThreatLevel+1] ThreatText = ThreatLevels[ThreatLevel+1]
end end
end
self:T2( ThreatLevel ) self:T2( ThreatLevel )
return ThreatLevel, ThreatText return ThreatLevel, ThreatText