From c73d8a6339e2e9b83b27f64f52f3b5ea2510d702 Mon Sep 17 00:00:00 2001 From: Applevangelist Date: Tue, 16 Jul 2024 13:38:42 +0200 Subject: [PATCH] Further fixes --- Moose Development/Moose/Core/Database.lua | 2 +- Moose Development/Moose/Core/Set.lua | 36 ++++++++++++++-------- Moose Development/Moose/Sound/Radio.lua | 14 ++++++--- Moose Development/Moose/Wrapper/Client.lua | 4 +-- 4 files changed, 36 insertions(+), 20 deletions(-) diff --git a/Moose Development/Moose/Core/Database.lua b/Moose Development/Moose/Core/Database.lua index 6cdf05da7..ed1271037 100644 --- a/Moose Development/Moose/Core/Database.lua +++ b/Moose Development/Moose/Core/Database.lua @@ -834,7 +834,7 @@ function DATABASE:FindGroup( GroupName ) local GroupFound = self.GROUPS[GroupName] - if GroupFound == nil and GroupName ~= nil then + if GroupFound == nil and GroupName ~= nil and self.Templates.Groups[GroupName] == nil then -- see if the group exists in the API, maybe a dynamic slot self:_RegisterDynamicGroup(GroupName) return self.GROUPS[GroupName] diff --git a/Moose Development/Moose/Core/Set.lua b/Moose Development/Moose/Core/Set.lua index 9023297f6..2ba9c7996 100644 --- a/Moose Development/Moose/Core/Set.lua +++ b/Moose Development/Moose/Core/Set.lua @@ -4743,18 +4743,23 @@ do -- SET_CLIENT self:T( { "Evaluated Coalition", MClientCoalition } ) MClientInclude = MClientInclude and MClientCoalition end - + if self.Filter.Categories and MClientInclude then local MClientCategory = false for CategoryID, CategoryName in pairs( self.Filter.Categories ) do local ClientCategoryID = _DATABASE:GetCategoryFromClientTemplate( MClientName ) - local UnitCategory - if ClientCategoryID==nil and MClient:IsAlive()~=nil then + local UnitCategory = 0 + if ClientCategoryID==nil and MClient:IsExist() then ClientCategoryID,UnitCategory=MClient:GetCategory() - end - self:T3( { "Category:", UnitCategory, self.FilterMeta.Categories[CategoryName], CategoryName } ) - if self.FilterMeta.Categories[CategoryName] and UnitCategory and self.FilterMeta.Categories[CategoryName] == UnitCategory then - MClientCategory = true + self:T3( { "Category:", UnitCategory, self.FilterMeta.Categories[CategoryName], CategoryName } ) + if self.FilterMeta.Categories[CategoryName] and UnitCategory and self.FilterMeta.Categories[CategoryName] == UnitCategory then + MClientCategory = true + end + else + self:T3( { "Category:", ClientCategoryID, self.FilterMeta.Categories[CategoryName], CategoryName } ) + if self.FilterMeta.Categories[CategoryName] and ClientCategoryID and self.FilterMeta.Categories[CategoryName] == ClientCategoryID then + MClientCategory = true + end end end self:T( { "Evaluated Category", MClientCategory } ) @@ -5217,13 +5222,18 @@ do -- SET_PLAYER local MClientCategory = false for CategoryID, CategoryName in pairs( self.Filter.Categories ) do local ClientCategoryID = _DATABASE:GetCategoryFromClientTemplate( MClientName ) - local UnitCategory - if ClientCategoryID==nil and MClient:IsAlive()~=nil then + local UnitCategory = 0 + if ClientCategoryID==nil and MClient:IsExist() then ClientCategoryID,UnitCategory=MClient:GetCategory() - end - self:T3( { "Category:", UnitCategory, self.FilterMeta.Categories[CategoryName], CategoryName } ) - if self.FilterMeta.Categories[CategoryName] and UnitCategory and self.FilterMeta.Categories[CategoryName] == UnitCategory then - MClientCategory = true + self:T3( { "Category:", UnitCategory, self.FilterMeta.Categories[CategoryName], CategoryName } ) + if self.FilterMeta.Categories[CategoryName] and UnitCategory and self.FilterMeta.Categories[CategoryName] == UnitCategory then + MClientCategory = true + end + else + self:T3( { "Category:", ClientCategoryID, self.FilterMeta.Categories[CategoryName], CategoryName } ) + if self.FilterMeta.Categories[CategoryName] and ClientCategoryID and self.FilterMeta.Categories[CategoryName] == ClientCategoryID then + MClientCategory = true + end end end self:T( { "Evaluated Category", MClientCategory } ) diff --git a/Moose Development/Moose/Sound/Radio.lua b/Moose Development/Moose/Sound/Radio.lua index 68acf2a5a..961ccdc6a 100644 --- a/Moose Development/Moose/Sound/Radio.lua +++ b/Moose Development/Moose/Sound/Radio.lua @@ -97,6 +97,7 @@ RADIO = { Power = 100, Loop = false, alias = nil, + moduhasbeenset = false, } --- Create a new RADIO Object. This doesn't broadcast a transmission, though, use @{#RADIO.Broadcast} to actually broadcast. @@ -167,12 +168,13 @@ function RADIO:SetFrequency(Frequency) self:F2(Frequency) if type(Frequency) == "number" then - + -- If frequency is in range --if (Frequency >= 30 and Frequency <= 87.995) or (Frequency >= 108 and Frequency <= 173.995) or (Frequency >= 225 and Frequency <= 399.975) then -- Convert frequency from MHz to Hz - self.Frequency = Frequency * 1000000 + self.Frequency = Frequency + self.HertzFrequency = Frequency * 1000000 -- If the RADIO is attached to a UNIT or a GROUP, we need to send the DCS Command "SetFrequency" to change the UNIT or GROUP frequency if self.Positionable.ClassName == "UNIT" or self.Positionable.ClassName == "GROUP" then @@ -180,7 +182,7 @@ function RADIO:SetFrequency(Frequency) local commandSetFrequency={ id = "SetFrequency", params = { - frequency = self.Frequency, + frequency = self.HertzFrequency, modulation = self.Modulation, } } @@ -197,7 +199,7 @@ function RADIO:SetFrequency(Frequency) return self end ---- Set AM or FM modulation of the radio transmitter. +--- Set AM or FM modulation of the radio transmitter. Set this before you set a frequency! -- @param #RADIO self -- @param #number Modulation Modulation is either radio.modulation.AM or radio.modulation.FM. -- @return #RADIO self @@ -206,6 +208,10 @@ function RADIO:SetModulation(Modulation) if type(Modulation) == "number" then if Modulation == radio.modulation.AM or Modulation == radio.modulation.FM then --TODO Maybe make this future proof if ED decides to add an other modulation ? self.Modulation = Modulation + if self.moduhasbeenset == false and Modulation == radio.modulation.FM then -- override default + self:SetFrequency(self.Frequency) + end + self.moduhasbeenset = true return self end end diff --git a/Moose Development/Moose/Wrapper/Client.lua b/Moose Development/Moose/Wrapper/Client.lua index f91b7a47c..3fb20deba 100644 --- a/Moose Development/Moose/Wrapper/Client.lua +++ b/Moose Development/Moose/Wrapper/Client.lua @@ -306,7 +306,7 @@ function CLIENT:IsMultiSeated() return false end ---- Checks for a client alive event and calls a function on a continuous basis. +--- Checks for a client alive event and calls a function on a continuous basis. Does **NOT** work for dynamic spawn client slots! -- @param #CLIENT self -- @param #function CallBackFunction Create a function that will be called when a player joins the slot. -- @param ... (Optional) Arguments for callback function as comma separated list. @@ -325,7 +325,7 @@ end -- @param #CLIENT self function CLIENT:_AliveCheckScheduler( SchedulerName ) - self:F3( { SchedulerName, self.ClientName, self.ClientAlive2, self.ClientBriefingShown, self.ClientCallBack } ) + self:T2( { SchedulerName, self.ClientName, self.ClientAlive2, self.ClientBriefingShown, self.ClientCallBack } ) if self:IsAlive() then