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

View File

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

View File

@ -598,12 +598,17 @@ end
-- @param #UNIT self
function UNIT:GetThreatLevel()
local Attributes = self:GetDesc().attributes
self:T( Attributes )
local ThreatLevel = 0
local ThreatText = ""
local Descriptor = self:GetDesc()
if Descriptor then
local Attributes = Descriptor.attributes
self:T( Attributes )
if self:IsGround() then
self:T( "Ground" )
@ -680,15 +685,15 @@ function UNIT:GetThreatLevel()
self:T( "Ship" )
--["Aircraft Carriers"] = {"Heavy armed ships",},
--["Cruisers"] = {"Heavy armed ships",},
--["Destroyers"] = {"Heavy armed ships",},
--["Frigates"] = {"Heavy armed ships",},
--["Corvettes"] = {"Heavy armed ships",},
--["Heavy armed ships"] = {"Armed ships", "Armed Air Defence", "HeavyArmoredUnits",},
--["Light armed ships"] = {"Armed ships","NonArmoredUnits"},
--["Armed ships"] = {"Ships"},
--["Unarmed ships"] = {"Ships","HeavyArmoredUnits",},
--["Aircraft Carriers"] = {"Heavy armed ships",},
--["Cruisers"] = {"Heavy armed ships",},
--["Destroyers"] = {"Heavy armed ships",},
--["Frigates"] = {"Heavy armed ships",},
--["Corvettes"] = {"Heavy armed ships",},
--["Heavy armed ships"] = {"Armed ships", "Armed Air Defence", "HeavyArmoredUnits",},
--["Light armed ships"] = {"Armed ships","NonArmoredUnits"},
--["Armed ships"] = {"Ships"},
--["Unarmed ships"] = {"Ships","HeavyArmoredUnits",},
local ThreatLevels = {
"Unarmed ship",
@ -715,6 +720,7 @@ function UNIT:GetThreatLevel()
ThreatText = ThreatLevels[ThreatLevel+1]
end
end
self:T2( ThreatLevel )
return ThreatLevel, ThreatText