Some nil checks to the A2A dispatcher, keeping it from detecting nil units, added locale to Settings and use of it to TextAndSound

This commit is contained in:
Applevangelist 2022-04-04 12:57:04 +02:00
parent 4e7ff94b33
commit 89845883d0
3 changed files with 35 additions and 6 deletions

View File

@ -884,8 +884,9 @@ do -- AI_A2A_DISPATCHER
--- Enumerator for spawns at airbases --- Enumerator for spawns at airbases
-- @type AI_A2A_DISPATCHER.Takeoff -- @type AI_A2A_DISPATCHER.Takeoff
-- @extends Wrapper.Group#GROUP.Takeoff -- @extends Wrapper.Group#GROUP.Takeoff
--- @field #AI_A2A_DISPATCHER.Takeoff Takeoff ---
-- @field #AI_A2A_DISPATCHER.Takeoff Takeoff
AI_A2A_DISPATCHER.Takeoff = GROUP.Takeoff AI_A2A_DISPATCHER.Takeoff = GROUP.Takeoff
--- Defnes Landing location. --- Defnes Landing location.
@ -3048,7 +3049,20 @@ do -- AI_A2A_DISPATCHER
for FriendlyDistance, AIFriendly in UTILS.spairs( DefenderFriendlies or {} ) do for FriendlyDistance, AIFriendly in UTILS.spairs( DefenderFriendlies or {} ) do
-- We only allow to ENGAGE targets as long as the Units on both sides are balanced. -- We only allow to ENGAGE targets as long as the Units on both sides are balanced.
if AttackerCount > DefenderCount then if AttackerCount > DefenderCount then
local Friendly = AIFriendly:GetGroup() -- Wrapper.Group#GROUP --self:I("***** AI_A2A_DISPATCHER:CountDefendersToBeEngaged() *****\nThis is supposed to be a UNIT:")
if AIFriendly then
local classname = AIFriendly.ClassName or "No Class Name"
local unitname = AIFriendly.IdentifiableName or "No Unit Name"
--self:I("Class Name: " .. classname)
--self:I("Unit Name: " .. unitname)
--self:I({AIFriendly})
end
local Friendly = nil
if AIFriendly and AIFriendly:IsAlive() then
--self:I("AIFriendly alive, getting GROUP")
Friendly = AIFriendly:GetGroup() -- Wrapper.Group#GROUP
end
if Friendly and Friendly:IsAlive() then if Friendly and Friendly:IsAlive() then
-- Ok, so we have a friendly near the potential target. -- Ok, so we have a friendly near the potential target.
-- Now we need to check if the AIGroup has a Task. -- Now we need to check if the AIGroup has a Task.

View File

@ -253,6 +253,7 @@ do -- SETTINGS
self:SetMessageTime( MESSAGE.Type.Overview, 60 ) self:SetMessageTime( MESSAGE.Type.Overview, 60 )
self:SetMessageTime( MESSAGE.Type.Update, 15 ) self:SetMessageTime( MESSAGE.Type.Update, 15 )
self:SetEraModern() self:SetEraModern()
self:SetLocale("en")
return self return self
else else
local Settings = _DATABASE:GetPlayerSettings( PlayerName ) local Settings = _DATABASE:GetPlayerSettings( PlayerName )
@ -284,7 +285,21 @@ do -- SETTINGS
function SETTINGS:SetMetric() function SETTINGS:SetMetric()
self.Metric = true self.Metric = true
end end
--- Sets the SETTINGS default text locale.
-- @param #SETTINGS self
-- @param #string Locale
function SETTINGS:SetLocale(Locale)
self.Locale = Locale or "en"
end
--- Gets the SETTINGS text locale.
-- @param #SETTINGS self
-- @return #string
function SETTINGS:GetLocale()
return self.Locale or _SETTINGS:GetLocale()
end
--- Gets if the SETTINGS is metric. --- Gets if the SETTINGS is metric.
-- @param #SETTINGS self -- @param #SETTINGS self
-- @return #boolean true if metric. -- @return #boolean true if metric.

View File

@ -60,14 +60,14 @@ TEXTANDSOUND = {
--- Instantiate a new object --- Instantiate a new object
-- @param #TEXTANDSOUND self -- @param #TEXTANDSOUND self
-- @param #string ClassName Name of the class this instance is providing texts for. -- @param #string ClassName Name of the class this instance is providing texts for.
-- @param #string Defaultlocale Default locale of this instance, e.g. "en". -- @param #string Defaultlocale (Optional) Default locale of this instance, defaults to "en".
-- @return #TEXTANDSOUND self -- @return #TEXTANDSOUND self
function TEXTANDSOUND:New(ClassName,Defaultlocale) function TEXTANDSOUND:New(ClassName,Defaultlocale)
-- Inherit everything from BASE class. -- Inherit everything from BASE class.
local self=BASE:Inherit(self, BASE:New()) local self=BASE:Inherit(self, BASE:New())
-- Set some string id for output to DCS.log file. -- Set some string id for output to DCS.log file.
self.lid=string.format("%s (%s) | ", self.ClassName, self.version) self.lid=string.format("%s (%s) | ", self.ClassName, self.version)
self.locale = Defaultlocale or "en" self.locale = Defaultlocale or (_SETTINGS:GetLocale() or "en")
self.textclass = ClassName or "none" self.textclass = ClassName or "none"
self.entries = {} self.entries = {}
local initentry = {} -- #TEXTANDSOUND.Entry local initentry = {} -- #TEXTANDSOUND.Entry