Merge branch 'FF/Ops' into FF/OpsRat

This commit is contained in:
Frank 2024-04-18 10:36:42 +02:00
commit a8cbf81851
6 changed files with 62 additions and 31 deletions

View File

@ -1153,7 +1153,7 @@ function BASE:_Serialize(Arguments)
text = string.gsub(text,"(\n+)","") text = string.gsub(text,"(\n+)","")
text = string.gsub(text,"%(%(","%(") text = string.gsub(text,"%(%(","%(")
text = string.gsub(text,"%)%)","%)") text = string.gsub(text,"%)%)","%)")
text = string.gsub(text,"(%s+)","") text = string.gsub(text,"(%s+)"," ")
return text return text
end end

View File

@ -20,7 +20,7 @@
-- --
-- @module Core.ClientMenu -- @module Core.ClientMenu
-- @image Core_Menu.JPG -- @image Core_Menu.JPG
-- last change: Oct 2023 -- last change: Apr 2024
-- TODO -- TODO
---------------------------------------------------------------------------------------------------------------- ----------------------------------------------------------------------------------------------------------------
@ -51,6 +51,7 @@
-- @field #boolean Generic -- @field #boolean Generic
-- @field #boolean debug -- @field #boolean debug
-- @field #CLIENTMENUMANAGER Controller -- @field #CLIENTMENUMANAGER Controller
-- @field #active boolean
-- @extends Core.Base#BASE -- @extends Core.Base#BASE
--- ---
@ -58,7 +59,7 @@
CLIENTMENU = { CLIENTMENU = {
ClassName = "CLIENTMENUE", ClassName = "CLIENTMENUE",
lid = "", lid = "",
version = "0.1.1", version = "0.1.2",
name = nil, name = nil,
path = nil, path = nil,
group = nil, group = nil,
@ -70,6 +71,7 @@ CLIENTMENU = {
debug = false, debug = false,
Controller = nil, Controller = nil,
groupname = nil, groupname = nil,
active = false,
} }
--- ---
@ -114,7 +116,7 @@ function CLIENTMENU:NewEntry(Client,Text,Parent,Function,...)
if self.Functionargs and self.debug then if self.Functionargs and self.debug then
self:T({"Functionargs",self.Functionargs}) self:T({"Functionargs",self.Functionargs})
end end
if not self.Generic then if not self.Generic and self.active == false then
if Function ~= nil then if Function ~= nil then
local ErrorHandler = function( errmsg ) local ErrorHandler = function( errmsg )
env.info( "MOOSE Error in CLIENTMENU COMMAND function: " .. errmsg ) env.info( "MOOSE Error in CLIENTMENU COMMAND function: " .. errmsg )
@ -133,8 +135,10 @@ function CLIENTMENU:NewEntry(Client,Text,Parent,Function,...)
end end
end end
self.path = missionCommands.addCommandForGroup(self.GroupID,Text,self.parentpath, self.CallHandler) self.path = missionCommands.addCommandForGroup(self.GroupID,Text,self.parentpath, self.CallHandler)
self.active = true
else else
self.path = missionCommands.addSubMenuForGroup(self.GroupID,Text,self.parentpath) self.path = missionCommands.addSubMenuForGroup(self.GroupID,Text,self.parentpath)
self.active = true
end end
else else
if self.parentpath then if self.parentpath then
@ -200,6 +204,7 @@ function CLIENTMENU:RemoveF10()
if not status then if not status then
self:I(string.format("**** Error Removing Menu Entry %s for %s!",tostring(self.name),self.groupname)) self:I(string.format("**** Error Removing Menu Entry %s for %s!",tostring(self.name),self.groupname))
end end
self.active = false
end end
return self return self
end end
@ -412,7 +417,7 @@ end
CLIENTMENUMANAGER = { CLIENTMENUMANAGER = {
ClassName = "CLIENTMENUMANAGER", ClassName = "CLIENTMENUMANAGER",
lid = "", lid = "",
version = "0.1.4", version = "0.1.5a",
name = nil, name = nil,
clientset = nil, clientset = nil,
menutree = {}, menutree = {},
@ -676,6 +681,7 @@ end
function CLIENTMENUMANAGER:Propagate(Client) function CLIENTMENUMANAGER:Propagate(Client)
self:T(self.lid.."Propagate") self:T(self.lid.."Propagate")
--self:I(UTILS.PrintTableToLog(Client,1)) --self:I(UTILS.PrintTableToLog(Client,1))
local knownunits = {} -- track so we can ID multi seated
local Set = self.clientset.Set local Set = self.clientset.Set
if Client then if Client then
Set = {Client} Set = {Client}
@ -684,28 +690,36 @@ function CLIENTMENUMANAGER:Propagate(Client)
for _,_client in pairs(Set) do for _,_client in pairs(Set) do
local client = _client -- Wrapper.Client#CLIENT local client = _client -- Wrapper.Client#CLIENT
if client and client:IsAlive() then if client and client:IsAlive() then
local playerunit = client:GetName()
local playergroup = client:GetGroup()
local playername = client:GetPlayerName() or "none" local playername = client:GetPlayerName() or "none"
if not self.playertree[playername] then if not knownunits[playerunit] then
self.playertree[playername] = {} knownunits[playerunit] = true
end else
for level,branch in pairs (self.menutree) do self:I("Player in multi seat unit: "..playername)
self:T("Building branch:" .. level) break -- multi seat already build
for _,leaf in pairs(branch) do end
self:T("Building leaf:" .. leaf) if not self.playertree[playername] then
local entry = self:FindEntryByUUID(leaf) self.playertree[playername] = {}
if entry then end
self:T("Found generic entry:" .. entry.UUID) for level,branch in pairs (self.menutree) do
local parent = nil self:T("Building branch:" .. level)
if entry.Parent and entry.Parent.UUID then for _,leaf in pairs(branch) do
parent = self.playertree[playername][entry.Parent.UUID] or self:FindEntryByUUID(entry.Parent.UUID) self:T("Building leaf:" .. leaf)
end local entry = self:FindEntryByUUID(leaf)
self.playertree[playername][entry.UUID] = CLIENTMENU:NewEntry(client,entry.name,parent,entry.Function,unpack(entry.Functionargs)) if entry then
self.playertree[playername][entry.UUID].Once = entry.Once self:T("Found generic entry:" .. entry.UUID)
else local parent = nil
self:T("NO generic entry for:" .. leaf) if entry.Parent and entry.Parent.UUID then
end parent = self.playertree[playername][entry.Parent.UUID] or self:FindEntryByUUID(entry.Parent.UUID)
end end
self.playertree[playername][entry.UUID] = CLIENTMENU:NewEntry(client,entry.name,parent,entry.Function,unpack(entry.Functionargs))
self.playertree[playername][entry.UUID].Once = entry.Once
else
self:T("NO generic entry for:" .. leaf)
end
end end
end
end end
end end
return self return self
@ -719,6 +733,7 @@ end
function CLIENTMENUMANAGER:AddEntry(Entry,Client) function CLIENTMENUMANAGER:AddEntry(Entry,Client)
self:T(self.lid.."AddEntry") self:T(self.lid.."AddEntry")
local Set = self.clientset.Set local Set = self.clientset.Set
local knownunits = {}
if Client then if Client then
Set = {Client} Set = {Client}
end end
@ -726,6 +741,13 @@ function CLIENTMENUMANAGER:AddEntry(Entry,Client)
local client = _client -- Wrapper.Client#CLIENT local client = _client -- Wrapper.Client#CLIENT
if client and client:IsAlive() then if client and client:IsAlive() then
local playername = client:GetPlayerName() local playername = client:GetPlayerName()
local unitname = client:GetName()
if not knownunits[unitname] then
knownunits[unitname] = true
else
self:I("Player in multi seat unit: "..playername)
break
end
if Entry then if Entry then
self:T("Adding generic entry:" .. Entry.UUID) self:T("Adding generic entry:" .. Entry.UUID)
local parent = nil local parent = nil

View File

@ -4388,8 +4388,8 @@ do -- SET_CLIENT
return self return self
end end
--- Builds a set of CLIENTs that contain the given string in their unit/pilot name. --- Builds a set of CLIENTs that contain the given string in their **unit/pilot** name and **NOT** the group name!
-- **Attention!** Bad naming convention as this **does not** filter only **prefixes** but all clients that **contain** the string. -- **Attention!** Bad naming convention as this **does not** filter only **prefixes** but all clients that **contain** the string. Pattern matching applies.
-- @param #SET_CLIENT self -- @param #SET_CLIENT self
-- @param #string Prefixes The string pattern(s) that needs to be contained in the unit/pilot name. Can also be passed as a `#table` of strings. -- @param #string Prefixes The string pattern(s) that needs to be contained in the unit/pilot name. Can also be passed as a `#table` of strings.
-- @return #SET_CLIENT self -- @return #SET_CLIENT self

View File

@ -24,7 +24,7 @@
-- @module Ops.CTLD -- @module Ops.CTLD
-- @image OPS_CTLD.jpg -- @image OPS_CTLD.jpg
-- Last Update March 2024 -- Last Update April 2024
do do
@ -1253,7 +1253,7 @@ CTLD.UnitTypeCapabilities = {
--- CTLD class version. --- CTLD class version.
-- @field #string version -- @field #string version
CTLD.version="1.0.50" CTLD.version="1.0.51"
--- Instantiate a new CTLD. --- Instantiate a new CTLD.
-- @param #CTLD self -- @param #CTLD self
@ -2240,7 +2240,9 @@ end
local extractdistance = self.CrateDistance * self.ExtractFactor local extractdistance = self.CrateDistance * self.ExtractFactor
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 <= extractdistance and distance ~= -1 then local TNow = timer.getTime()
local vtime = v.ExtractTime or TNow-310
if distance <= extractdistance and distance ~= -1 and (TNow - vtime > 300) then
nearestGroup = v nearestGroup = v
nearestGroupIndex = k nearestGroupIndex = k
nearestDistance = distance nearestDistance = distance
@ -2291,9 +2293,11 @@ end
end end
if troopsize + numberonboard > trooplimit then if troopsize + numberonboard > trooplimit then
self:_SendMessage("Sorry, we\'re crammed already!", 10, false, Group) self:_SendMessage("Sorry, we\'re crammed already!", 10, false, Group)
nearestGroup.ExtractTime = 0
--return self --return self
else else
self.CargoCounter = self.CargoCounter + 1 self.CargoCounter = self.CargoCounter + 1
nearestGroup.ExtractTime = timer.GetTime()
local loadcargotype = CTLD_CARGO:New(self.CargoCounter, Cargotype.Name, Cargotype.Templates, Cargotype.CargoType, true, true, Cargotype.CratesNeeded,nil,nil,Cargotype.PerCrateMass) local loadcargotype = CTLD_CARGO:New(self.CargoCounter, Cargotype.Name, Cargotype.Templates, Cargotype.CargoType, true, true, Cargotype.CratesNeeded,nil,nil,Cargotype.PerCrateMass)
self:T({cargotype=loadcargotype}) self:T({cargotype=loadcargotype})
local running = math.floor(nearestDistance / 4)+10 -- time run to helo plus boarding local running = math.floor(nearestDistance / 4)+10 -- time run to helo plus boarding

View File

@ -505,6 +505,9 @@ end
function COHORT:SetCallsign(Callsign, Index) function COHORT:SetCallsign(Callsign, Index)
self.callsignName=Callsign self.callsignName=Callsign
self.callsignIndex=Index self.callsignIndex=Index
self.callsign={}
self.callsign.NumberSquad=Callsign
self.callsign.NumberGroup=Index
return self return self
end end

View File

@ -760,11 +760,13 @@ AIRBASE.Sinai = {
-- @field #number OpenMedOrBig 176: Combines OpenMed and OpenBig spots. -- @field #number OpenMedOrBig 176: Combines OpenMed and OpenBig spots.
-- @field #number HelicopterUsable 216: Combines HelicopterOnly, OpenMed and OpenBig. -- @field #number HelicopterUsable 216: Combines HelicopterOnly, OpenMed and OpenBig.
-- @field #number FighterAircraft 244: Combines Shelter. OpenMed and OpenBig spots. So effectively all spots usable by fixed wing aircraft. -- @field #number FighterAircraft 244: Combines Shelter. OpenMed and OpenBig spots. So effectively all spots usable by fixed wing aircraft.
-- @field #number SmallSizeFigher 100: Tight spots for smaller type fixed wing aircraft, like the F-16. Example of these spots: 04, 05, 06 on Muwaffaq_Salti. A Viper sized plane can spawn here, but an A-10 or Strike Eagle can't
AIRBASE.TerminalType = { AIRBASE.TerminalType = {
Runway=16, Runway=16,
HelicopterOnly=40, HelicopterOnly=40,
Shelter=68, Shelter=68,
OpenMed=72, OpenMed=72,
SmallSizeFighter=100,
OpenBig=104, OpenBig=104,
OpenMedOrBig=176, OpenMedOrBig=176,
HelicopterUsable=216, HelicopterUsable=216,
@ -1841,7 +1843,7 @@ function AIRBASE._CheckTerminalType(Term_Type, termtype)
match=true match=true
end end
elseif termtype==AIRBASE.TerminalType.FighterAircraft then elseif termtype==AIRBASE.TerminalType.FighterAircraft then
if Term_Type==AIRBASE.TerminalType.OpenMed or Term_Type==AIRBASE.TerminalType.OpenBig or Term_Type==AIRBASE.TerminalType.Shelter then if Term_Type==AIRBASE.TerminalType.OpenMed or Term_Type==AIRBASE.TerminalType.OpenBig or Term_Type==AIRBASE.TerminalType.Shelter or Term_Type==AIRBASE.TerminalType.SmallSizeFighter then
match=true match=true
end end
end end