This commit is contained in:
Applevangelist
2026-03-26 09:11:03 +01:00
parent 58eeabe3fa
commit 9fb9b6378e
3 changed files with 137 additions and 122 deletions
+2 -2
View File
@@ -1380,12 +1380,12 @@ function DATABASE:_RegisterDynamicGroup(Groupname)
local DCSUnitName = DCSUnit:getName() local DCSUnitName = DCSUnit:getName()
-- Add unit. -- Add unit.
self:I(string.format("Register Unit: %s", tostring(DCSUnitName))) self:T(string.format("Register Unit: %s", tostring(DCSUnitName)))
self:AddUnit( tostring(DCSUnitName), true ) self:AddUnit( tostring(DCSUnitName), true )
end end
else else
self:E({"Group does not exist: ", DCSGroup}) self:T({"Group does not exist: ", DCSGroup})
end end
return self return self
end end
@@ -2102,6 +2102,8 @@ function RAT:_InitAircraft(DCSgroup)
local DCSdesc=DCSunit:getDesc() local DCSdesc=DCSunit:getDesc()
local DCScategory=DCSgroup:getCategory() local DCScategory=DCSgroup:getCategory()
local DCStype=DCSunit:getTypeName() local DCStype=DCSunit:getTypeName()
self:I({typename=DCStype})
UTILS.PrintTableToLog(DCSdesc.box,1,noprint,3,seen)
-- set category -- set category
if DCScategory==Group.Category.AIRPLANE then if DCScategory==Group.Category.AIRPLANE then
@@ -2137,6 +2139,11 @@ function RAT:_InitAircraft(DCSgroup)
-- Store all descriptors. -- Store all descriptors.
--self.aircraft.descriptors=DCSdesc --self.aircraft.descriptors=DCSdesc
-- Tomcat sizing as default
self.aircraft.length=12
self.aircraft.height=4
self.aircraft.width=10.3
-- aircraft dimensions -- aircraft dimensions
if DCSdesc.box then if DCSdesc.box then
self.aircraft.length=DCSdesc.box.max.x self.aircraft.length=DCSdesc.box.max.x
@@ -2158,6 +2165,10 @@ function RAT:_InitAircraft(DCSgroup)
self.aircraft.length=11.48 self.aircraft.length=11.48
self.aircraft.height=4.11 self.aircraft.height=4.11
self.aircraft.width=13.41 self.aircraft.width=13.41
elseif DCStype == "F-14A-135-GR" then
self.aircraft.length=12
self.aircraft.height=4
self.aircraft.width=10.3
end end
self.aircraft.box=math.max(self.aircraft.length,self.aircraft.width) self.aircraft.box=math.max(self.aircraft.length,self.aircraft.width)
+65 -61
View File
@@ -2124,8 +2124,8 @@ function MSRS:_HoundTextToSpeech(Message,Frequencies,Modulations,Volume,Label,Co
--end --end
local provider = self.provider local provider = self.provider
provider=provider:gsub("gcloud", "google") --provider=provider:gsub("gcloud", "google")
provider=provider:gsub("win", "sapi") --provider=provider:gsub("win", "sapi")
local TransmissionP = { local TransmissionP = {
freqs = freqs, freqs = freqs,
@@ -2584,10 +2584,11 @@ end
-- @param Core.Point#COORDINATE coordinate (Optional) Coordinate to be used -- @param Core.Point#COORDINATE coordinate (Optional) Coordinate to be used
-- @param #number speed (Optional) Speed to be used -- @param #number speed (Optional) Speed to be used
-- @param #string speaker (Optional) PIPER voice can have various speakers, set this here if you use PIPER/HOUND with a fitting voice. -- @param #string speaker (Optional) PIPER voice can have various speakers, set this here if you use PIPER/HOUND with a fitting voice.
-- @param #number priority (Optional) Priority of this transmission. Can be [1..100], default is 50. Higher is taken up earlier from the queue.
-- @return #MSRSQUEUE.Transmission Radio transmission table. -- @return #MSRSQUEUE.Transmission Radio transmission table.
function MSRSQUEUE:NewTransmission(text, duration, msrs, tstart, interval, subgroups, subtitle, subduration, frequency, modulation, gender, culture, voice, volume, label,coordinate,speed,speaker) function MSRSQUEUE:NewTransmission(text, duration, msrs, tstart, interval, subgroups, subtitle, subduration, frequency, modulation, gender, culture, voice, volume, label,coordinate,speed,speaker,priority)
self:T({Text=text, Dur=duration, start=tstart, int=interval, sub=subgroups, subt=subtitle, sudb=subduration, F=frequency, M=modulation, G=gender, C=culture, V=voice, Vol=volume, L=label, S=speed}) self:T({Text=text, Dur=duration, start=tstart, int=interval, sub=subgroups, subt=subtitle, sudb=subduration, F=frequency, M=modulation, G=gender, C=culture, V=voice, Vol=volume, L=label, S=speed, P=priority})
self:T({provider=msrs.provider}) self:I({provider=msrs.provider})
if self.TransmitOnlyWithPlayers then if self.TransmitOnlyWithPlayers then
if self.PlayerSet and self.PlayerSet:CountAlive() == 0 then if self.PlayerSet and self.PlayerSet:CountAlive() == 0 then
return self return self
@@ -2633,6 +2634,7 @@ function MSRSQUEUE:NewTransmission(text, duration, msrs, tstart, interval, subgr
elseif msrs.Speaker then elseif msrs.Speaker then
transmission.speaker = msrs.speaker transmission.speaker = msrs.speaker
end end
transmission.priority = priority or 50
-- Add transmission to queue. -- Add transmission to queue.
self:AddTransmission(transmission) self:AddTransmission(transmission)
@@ -2700,7 +2702,7 @@ function MSRSQUEUE:CalcTransmisstionDuration()
return T return T
end end
--- Check radio queue for transmissions to be broadcasted. -- Check radio queue for transmissions to be broadcasted.
-- @param #MSRSQUEUE self -- @param #MSRSQUEUE self
-- @param #number delay Delay in seconds before checking. -- @param #number delay Delay in seconds before checking.
function MSRSQUEUE:_CheckRadioQueue(delay) function MSRSQUEUE:_CheckRadioQueue(delay)
@@ -2709,27 +2711,26 @@ function MSRSQUEUE:_CheckRadioQueue(delay)
local N = #self.queue local N = #self.queue
-- Debug info. -- Debug info.
self:T2(self.lid..string.format("Check radio queue %s: delay=%.3f sec, N=%d, checking=%s", self.alias, delay or 0, N, tostring(self.checking))) self:T2(self.lid..string.format(
"Check radio queue %s: delay=%.3f sec, N=%d, checking=%s",
self.alias, delay or 0, N, tostring(self.checking)
))
if delay and delay > 0 then if delay and delay > 0 then
-- Delayed call. -- Delayed call.
self:ScheduleOnce(delay, MSRSQUEUE._CheckRadioQueue, self) self:ScheduleOnce(delay, MSRSQUEUE._CheckRadioQueue, self)
-- Checking on. -- Checking on.
self.checking = true self.checking = true
return
else end
-- Check if queue is empty. -- Check if queue is empty.
if N == 0 then if N == 0 then
-- Debug info. -- Debug info.
self:T(self.lid..string.format("Check radio queue %s empty ==> disable checking", self.alias)) self:T(self.lid..string.format("Check radio queue %s empty ==> disable checking", self.alias))
-- Queue is now empty. Nothing else to do. We start checking again if a transmission is added.
-- Queue is now empty. Nothing to else to do. We start checking again, if a transmission is added.
self.checking = false self.checking = false
return return
end end
@@ -2742,22 +2743,35 @@ function MSRSQUEUE:_CheckRadioQueue(delay)
-- Set dt. -- Set dt.
local dt = self.dt local dt = self.dt
local playing = false local playing = false
local next=nil --#MSRSQUEUE.Transmission local nextTx = nil -- #MSRSQUEUE.Transmission
local remove = nil local remove = nil
-- Helper: read priority with default 50; clamp to [1,100]
local function getPriority(tx)
local p = tx.priority
if p == nil then return 50 end
if p < 1 then return 1 end
if p > 100 then return 100 end
return p
end
-- Scan queue to determine status and pick the next transmission.
-- Rules:
-- * If something is currently playing and not yet finished -> keep playing, compute dt.
-- * Otherwise, among eligible (due and interval-ok, not playing) candidates pick max priority.
-- * If tie -> earlier in queue wins automatically by iteration order.
local bestPrio = nil
for i, _transmission in ipairs(self.queue) do for i, _transmission in ipairs(self.queue) do
local transmission = _transmission -- #MSRSQUEUE.Transmission local transmission = _transmission -- #MSRSQUEUE.Transmission
-- Check if transmission time has passed. -- Check if transmission time has passed.
if time >= transmission.Tplay then if time >= transmission.Tplay then
-- Check if transmission is currently playing. -- Check if transmission is currently playing.
if transmission.isplaying then if transmission.isplaying then
-- Check if transmission is finished. -- Check if transmission is finished.
if time >= transmission.Tstarted + transmission.duration then if time >= transmission.Tstarted + transmission.duration then
-- Transmission over. -- Transmission over.
transmission.isplaying = false transmission.isplaying = false
@@ -2766,61 +2780,56 @@ function MSRSQUEUE:_CheckRadioQueue(delay)
-- Store time last transmission finished. -- Store time last transmission finished.
self.Tlast = time self.Tlast = time
else
else -- still playing
-- Transmission is still playing. -- Transmission is still playing.
playing = true playing = true
dt = transmission.duration - (time - transmission.Tstarted) dt = transmission.duration - (time - transmission.Tstarted)
-- While something is playing, we keep scanning to see if it just finished at this exact loop,
-- but do not pick a new nextTx until the player finishes.
end end
else -- not playing yet else
-- Not playing yet: evaluate eligibility (interval logic), then consider for priority selection.
local Tlast = self.Tlast local Tlast = self.Tlast
local eligible = false
if transmission.interval == nil then if transmission.interval == nil then
-- No interval constraint.
-- Not playing ==> this will be next. eligible = true
if next==nil then
next=transmission
end
else else
-- Interval-constrained: only eligible if no last or enough time passed since last finish.
if (Tlast == nil) or (time - Tlast >= transmission.interval) then
eligible = true
end
end
if Tlast==nil or time-Tlast>=transmission.interval then if eligible and not playing then
next=transmission local prio = getPriority(transmission)
if bestPrio == nil or prio > bestPrio then
bestPrio = prio
nextTx = transmission
-- Earliest in queue preserves tie-breaking (we only replace on strictly higher prio).
end
end
-- Note: do NOT break early—need to scan all to find the true highest priority candidate.
end
else else
end
end
-- We got a transmission or one with an interval that is not due yet. No need for anything else.
if next or Tlast then
break
end
end
else
-- Transmission not due yet. -- Transmission not due yet.
end end
end end
-- Found a new transmission. -- Found a new transmission and nothing is currently playing.
if next~=nil and not playing then if nextTx ~= nil and not playing then
-- Debug info. -- Debug info.
self:T(self.lid..string.format("Broadcasting text=\"%s\" at T=%.3f", next.text, time)) self:T(self.lid..string.format('Broadcasting text="%s" at T=%.3f (prio=%d)', nextTx.text, time, (nextTx.priority or 50)))
-- Call SRS. -- Call SRS.
self:Broadcast(next) self:Broadcast(nextTx)
next.isplaying=true nextTx.isplaying = true
next.Tstarted=time nextTx.Tstarted = time
dt=next.duration dt = nextTx.duration
end end
-- Remove completed call from queue. -- Remove completed call from queue.
@@ -2833,18 +2842,13 @@ function MSRSQUEUE:_CheckRadioQueue(delay)
if #self.queue == 0 then if #self.queue == 0 then
-- Debug info. -- Debug info.
self:T(self.lid..string.format("Check radio queue %s empty ==> disable checking", self.alias)) self:T(self.lid..string.format("Check radio queue %s empty ==> disable checking", self.alias))
self.checking = false self.checking = false
return return
end end
end end
-- Check queue. -- Continue checking.
self:_CheckRadioQueue(dt) self:_CheckRadioQueue(dt)
end
end end
MSRS.LoadConfigFile() MSRS.LoadConfigFile()