Lots of optimizations

This commit is contained in:
FlightControl_Master
2018-04-12 13:59:55 +02:00
parent dcc42b8e62
commit fea2f55fbb
16 changed files with 261 additions and 189 deletions

View File

@@ -349,9 +349,21 @@ function UNIT:GetPlayerName()
if DCSUnit then
local PlayerName = DCSUnit:getPlayerName()
-- TODO - Workaround for DCS-BUG-3
if PlayerName == nil or PlayerName == "" then
PlayerName = "Player" .. DCSUnit:getID()
local PlayerCategory = DCSUnit:getDesc().category
if PlayerCategory == Unit.Category.GROUND_UNIT or PlayerCategory == Unit.Category.SHIP then
PlayerName = "Player" .. DCSUnit:getID()
end
end
-- -- Good code
-- if PlayerName == nil then
-- PlayerName = nil
-- else
-- if PlayerName == "" then
-- PlayerName = "Player" .. DCSUnit:getID()
-- end
-- end
return PlayerName
end
@@ -638,12 +650,9 @@ function UNIT:GetThreatLevel()
if Descriptor then
local Attributes = Descriptor.attributes
self:T( Attributes )
if self:IsGround() then
self:T( "Ground" )
local ThreatLevels = {
"Unarmed",
"Infantry",
@@ -680,8 +689,6 @@ function UNIT:GetThreatLevel()
if self:IsAir() then
self:T( "Air" )
local ThreatLevels = {
"Unarmed",
"Tanker",
@@ -714,8 +721,6 @@ function UNIT:GetThreatLevel()
if self:IsShip() then
self:T( "Ship" )
--["Aircraft Carriers"] = {"Heavy armed ships",},
--["Cruisers"] = {"Heavy armed ships",},
--["Destroyers"] = {"Heavy armed ships",},
@@ -753,7 +758,6 @@ function UNIT:GetThreatLevel()
end
end
self:T2( ThreatLevel )
return ThreatLevel, ThreatText
end