diff --git a/Moose Development/Moose/Ops/CSAR.lua b/Moose Development/Moose/Ops/CSAR.lua index 7b716ed5c..fd1eda22b 100644 --- a/Moose Development/Moose/Ops/CSAR.lua +++ b/Moose Development/Moose/Ops/CSAR.lua @@ -31,7 +31,7 @@ -- @image OPS_CSAR.jpg --- --- Last Update April 2024 +-- Last Update July 2024 ------------------------------------------------------------------------- --- **CSAR** class, extends Core.Base#BASE, Core.Fsm#FSM @@ -296,7 +296,7 @@ CSAR.AircraftType["OH58D"] = 2 --- CSAR class version. -- @field #string version -CSAR.version="1.0.24" +CSAR.version="1.0.25" ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -- ToDo list @@ -2111,12 +2111,12 @@ function CSAR:_AddMedevacMenuItem() local coalition = self.coalition local allheligroupset = self.allheligroupset -- Core.Set#SET_GROUP local _allHeliGroups = allheligroupset:GetSetObjects() - -- rebuild units table local _UnitList = {} for _key, _group in pairs (_allHeliGroups) do - local _unit = _group:GetUnit(1) -- Asume that there is only one unit in the flight for players - if _unit then + local _unit = _group:GetFirstUnitAlive() -- Asume that there is only one unit in the flight for players + if _unit then + --self:T("Unitname ".._unit:GetName().." IsAlive "..tostring(_unit:IsAlive()).." IsPlayer "..tostring(_unit:IsPlayer())) if _unit:IsAlive() and _unit:IsPlayer() then local unitName = _unit:GetName() _UnitList[unitName] = unitName diff --git a/Moose Development/Moose/Ops/CTLD.lua b/Moose Development/Moose/Ops/CTLD.lua index 037446ea4..16a87ca11 100644 --- a/Moose Development/Moose/Ops/CTLD.lua +++ b/Moose Development/Moose/Ops/CTLD.lua @@ -24,7 +24,7 @@ -- @module Ops.CTLD -- @image OPS_CTLD.jpg --- Last Update April 2024 +-- Last Update July 2024 do @@ -1255,7 +1255,7 @@ CTLD.UnitTypeCapabilities = { --- CTLD class version. -- @field #string version -CTLD.version="1.0.54" +CTLD.version="1.0.55" --- Instantiate a new CTLD. -- @param #CTLD self @@ -3670,7 +3670,7 @@ function CTLD:_RefreshF10Menus() -- rebuild units table local _UnitList = {} for _key, _group in pairs (PlayerTable) do - local _unit = _group:GetUnit(1) -- Wrapper.Unit#UNIT Asume that there is only one unit in the flight for players + local _unit = _group:GetFirstUnitAlive() -- Wrapper.Unit#UNIT Asume that there is only one unit in the flight for players if _unit then if _unit:IsAlive() and _unit:IsPlayer() then if _unit:IsHelicopter() or (self:IsHercules(_unit) and self.enableHercules) then --ensure no stupid unit entries here diff --git a/Moose Development/Moose/Wrapper/Group.lua b/Moose Development/Moose/Wrapper/Group.lua index 714fc2faf..633eb5a32 100644 --- a/Moose Development/Moose/Wrapper/Group.lua +++ b/Moose Development/Moose/Wrapper/Group.lua @@ -2745,7 +2745,7 @@ do -- Players local PlayerNames = {} local Units = self:GetUnits() - for UnitID, UnitData in pairs( Units ) do + for UnitID, UnitData in pairs( Units or {}) do local Unit = UnitData -- Wrapper.Unit#UNIT local PlayerName = Unit:GetPlayerName() if PlayerName and PlayerName ~= "" then diff --git a/Moose Development/Moose/Wrapper/Unit.lua b/Moose Development/Moose/Wrapper/Unit.lua index 497d9fb1a..c7f3f02be 100644 --- a/Moose Development/Moose/Wrapper/Unit.lua +++ b/Moose Development/Moose/Wrapper/Unit.lua @@ -447,7 +447,14 @@ function UNIT:IsPlayer() -- Units of template group. local template = group:GetTemplate() - if (template == nil) or (template.units == nil ) then return false end + if (template == nil) or (template.units == nil ) then + local DCSObject = self:GetDCSObject() + if DCSObject then + if DCSObject:getPlayerName() ~= nil then return true else return false end + else + return false + end + end local units=template.units