* ensure tactical frequencies are handed back

#PlayerTask
* Add'l check for stale tasks to rebuild menu
This commit is contained in:
Applevangelist 2023-07-29 16:44:25 +02:00
parent cbd371b40f
commit 4ed2b0610d
2 changed files with 42 additions and 5 deletions

View File

@ -1517,6 +1517,23 @@ function AWACS:_SubScribeTactRadio(Group,Frequency)
return self return self
end end
--- [Internal] _CheckSubscribers
-- @param #AWACS self
-- @return #AWACS self
function AWACS:_CheckSubscribers()
self:T(self.lid.."_InitLocalization")
for _name,_freq in pairs(self.TacticalSubscribers or {}) do
local grp = GROUP:FindByName(_name)
if (not grp) or (not grp:IsAlive()) then
self.TacticalFrequencies[_freq] = _freq
self.TacticalSubscribers[_name] = nil
end
end
return self
end
--- [Internal] Init localization --- [Internal] Init localization
-- @param #AWACS self -- @param #AWACS self
-- @return #AWACS self -- @return #AWACS self
@ -6180,6 +6197,8 @@ function AWACS:onafterStatus(From, Event, To)
self:_CheckMerges() self:_CheckMerges()
self:_CheckSubscribers()
local outcome, targets = self:_TargetSelectionProcess(true) local outcome, targets = self:_TargetSelectionProcess(true)
self:_CheckTaskQueue() self:_CheckTaskQueue()

View File

@ -98,7 +98,7 @@ PLAYERTASK = {
--- PLAYERTASK class version. --- PLAYERTASK class version.
-- @field #string version -- @field #string version
PLAYERTASK.version="0.1.18" PLAYERTASK.version="0.1.19"
--- Generic task condition. --- Generic task condition.
-- @type PLAYERTASK.Condition -- @type PLAYERTASK.Condition
@ -2483,6 +2483,15 @@ function PLAYERTASKCONTROLLER:_CheckTaskQueue()
self:T("*****Removing player " .. _id) self:T("*****Removing player " .. _id)
self.TasksPerPlayer:PullByID(_id) self.TasksPerPlayer:PullByID(_id)
end end
local clients=task:GetClientObjects()
for _,client in pairs(clients) do
self:_RemoveMenuEntriesForTask(task,client)
--self:_SwitchMenuForClient(client,"Info")
end
for _,client in pairs(clients) do
-- self:_RemoveMenuEntriesForTask(Task,client)
self:_SwitchMenuForClient(client,"Info",5)
end
-- Follow-up tasks? -- Follow-up tasks?
local nexttasks = {} local nexttasks = {}
if task.FinalState == "Success" then if task.FinalState == "Success" then
@ -3594,28 +3603,28 @@ function PLAYERTASKCONTROLLER:_RemoveMenuEntriesForTask(Task,Client)
if Task then if Task then
if Task.UUIDS and self.JoinTaskMenuTemplate then if Task.UUIDS and self.JoinTaskMenuTemplate then
--self:I("***** JoinTaskMenuTemplate") --self:I("***** JoinTaskMenuTemplate")
UTILS.PrintTableToLog(Task.UUIDS) --UTILS.PrintTableToLog(Task.UUIDS)
local controller = self.JoinTaskMenuTemplate local controller = self.JoinTaskMenuTemplate
for _,_uuid in pairs(Task.UUIDS) do for _,_uuid in pairs(Task.UUIDS) do
local Entry = controller:FindEntryByUUID(_uuid) local Entry = controller:FindEntryByUUID(_uuid)
if Entry then if Entry then
controller:DeleteF10Entry(Entry,Client) controller:DeleteF10Entry(Entry,Client)
controller:DeleteGenericEntry(Entry) controller:DeleteGenericEntry(Entry)
UTILS.PrintTableToLog(controller.menutree) --UTILS.PrintTableToLog(controller.menutree)
end end
end end
end end
if Task.AUUIDS and self.ActiveTaskMenuTemplate then if Task.AUUIDS and self.ActiveTaskMenuTemplate then
--self:I("***** ActiveTaskMenuTemplate") --self:I("***** ActiveTaskMenuTemplate")
UTILS.PrintTableToLog(Task.AUUIDS) --UTILS.PrintTableToLog(Task.AUUIDS)
for _,_uuid in pairs(Task.AUUIDS) do for _,_uuid in pairs(Task.AUUIDS) do
local controller = self.ActiveTaskMenuTemplate local controller = self.ActiveTaskMenuTemplate
local Entry = controller:FindEntryByUUID(_uuid) local Entry = controller:FindEntryByUUID(_uuid)
if Entry then if Entry then
controller:DeleteF10Entry(Entry,Client) controller:DeleteF10Entry(Entry,Client)
controller:DeleteGenericEntry(Entry) controller:DeleteGenericEntry(Entry)
UTILS.PrintTableToLog(controller.menutree) --UTILS.PrintTableToLog(controller.menutree)
end end
end end
end end
@ -4210,6 +4219,15 @@ function PLAYERTASKCONTROLLER:onafterTaskFailed(From, Event, To, Task)
taskname = string.format(failtxttts, self.MenuName or self.Name, Task.PlayerTaskNr, tostring(Task.TTSType)) taskname = string.format(failtxttts, self.MenuName or self.Name, Task.PlayerTaskNr, tostring(Task.TTSType))
self.SRSQueue:NewTransmission(taskname,nil,self.SRS,nil,2) self.SRSQueue:NewTransmission(taskname,nil,self.SRS,nil,2)
end end
local clients=Task:GetClientObjects()
for _,client in pairs(clients) do
self:_RemoveMenuEntriesForTask(Task,client)
--self:_SwitchMenuForClient(client,"Info")
end
for _,client in pairs(clients) do
-- self:_RemoveMenuEntriesForTask(Task,client)
self:_SwitchMenuForClient(client,"Info",5)
end
return self return self
end end