Merge pull request #1576 from FlightControl-Master/Applevangelist-CTLD

Update CTLD.lua
This commit is contained in:
Applevangelist 2021-07-21 18:47:52 +02:00 committed by GitHub
commit 2ab7f784c9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -528,7 +528,7 @@ CTLD.UnitTypes = {
--- CTLD class version. --- CTLD class version.
-- @field #string version -- @field #string version
CTLD.version="0.1.4r2" CTLD.version="0.1.4r3"
--- Instantiate a new CTLD. --- Instantiate a new CTLD.
-- @param #CTLD self -- @param #CTLD self
@ -961,7 +961,7 @@ end
local nearestDistance = 10000000 local nearestDistance = 10000000
for k,v in pairs(self.DroppedTroops) do for k,v in pairs(self.DroppedTroops) do
local distance = self:_GetDistance(v:GetCoordinate(),unitcoord) local distance = self:_GetDistance(v:GetCoordinate(),unitcoord)
if distance < nearestDistance then if distance < nearestDistance and distance ~= -1 then
nearestGroup = v nearestGroup = v
nearestGroupIndex = k nearestGroupIndex = k
nearestDistance = distance nearestDistance = distance
@ -2349,6 +2349,20 @@ end
return self return self
end end
--- (Internal) Run through DroppedTroops and capture alive units
-- @param #CTLD self
-- @return #CTLD self
function CTLD:CleanDroppedTroops()
local troops = self.DroppedTroops
local newtable = {}
for _index, _group in pairs (troops) do
if _group and _group:IsAlive() then
newtable[_index] = _group
end
end
self.DroppedTroops = newtable
return self
end
------------------------------------------------------------------- -------------------------------------------------------------------
-- FSM functions -- FSM functions
------------------------------------------------------------------- -------------------------------------------------------------------
@ -2388,6 +2402,7 @@ end
-- @return #CTLD self -- @return #CTLD self
function CTLD:onbeforeStatus(From, Event, To) function CTLD:onbeforeStatus(From, Event, To)
self:T({From, Event, To}) self:T({From, Event, To})
self:CleanDroppedTroops()
self:_RefreshF10Menus() self:_RefreshF10Menus()
self:_RefreshRadioBeacons() self:_RefreshRadioBeacons()
self:CheckAutoHoverload() self:CheckAutoHoverload()