#PLAYERTASKCONTROLLER

* Fix a problem that sometimes the object event is called prior to the SET_CLIENT event for players joining, leading to false negatives on specifically filtered SET_CLIENT objects
This commit is contained in:
Applevangelist 2023-09-14 12:35:43 +02:00
parent 4e44d979a1
commit 97809cdb65
2 changed files with 10 additions and 6 deletions

View File

@ -860,8 +860,10 @@ do -- SET_BASE
self:F3( Object ) self:F3( Object )
local outcome = false local outcome = false
local name = Object:GetName() local name = Object:GetName()
--self:I("SET_BASE: Objectname = "..name)
self:ForEach( self:ForEach(
function(object) function(object)
--self:I("SET_BASE: In set objectname = "..object:GetName())
if object:GetName() == name then if object:GetName() == name then
outcome = true outcome = true
end end
@ -4330,7 +4332,6 @@ do -- SET_CLIENT
function SET_CLIENT:FilterStart() function SET_CLIENT:FilterStart()
if _DATABASE then if _DATABASE then
self:_FilterStart()
self:HandleEvent( EVENTS.Birth, self._EventOnBirth ) self:HandleEvent( EVENTS.Birth, self._EventOnBirth )
self:HandleEvent( EVENTS.Dead, self._EventOnDeadOrCrash ) self:HandleEvent( EVENTS.Dead, self._EventOnDeadOrCrash )
self:HandleEvent( EVENTS.Crash, self._EventOnDeadOrCrash ) self:HandleEvent( EVENTS.Crash, self._EventOnDeadOrCrash )
@ -4339,6 +4340,7 @@ do -- SET_CLIENT
local timing = self.ZoneTimerInterval or 30 local timing = self.ZoneTimerInterval or 30
self.ZoneTimer:Start(timing,timing) self.ZoneTimer:Start(timing,timing)
end end
self:_FilterStart()
end end
return self return self
@ -4574,9 +4576,9 @@ do -- SET_CLIENT
if self.Filter.Callsigns then if self.Filter.Callsigns then
local MClientCallsigns = false local MClientCallsigns = false
local callsign = MClient:GetCallsign() local callsign = MClient:GetCallsign()
--self:T(callsign) --self:I(callsign)
for _,_Callsign in pairs(self.Filter.Callsigns) do for _,_Callsign in pairs(self.Filter.Callsigns) do
if callsign and string.find(callsign,_Callsign) then if callsign and string.find(callsign,_Callsign,1,true) then
MClientCallsigns = true MClientCallsigns = true
end end
end end

View File

@ -98,7 +98,7 @@ PLAYERTASK = {
--- PLAYERTASK class version. --- PLAYERTASK class version.
-- @field #string version -- @field #string version
PLAYERTASK.version="0.1.19" PLAYERTASK.version="0.1.20"
--- Generic task condition. --- Generic task condition.
-- @type PLAYERTASK.Condition -- @type PLAYERTASK.Condition
@ -2195,7 +2195,8 @@ function PLAYERTASKCONTROLLER:_EventHandler(EventData)
end end
elseif EventData.id == EVENTS.PlayerEnterAircraft and EventData.IniCoalition == self.Coalition then elseif EventData.id == EVENTS.PlayerEnterAircraft and EventData.IniCoalition == self.Coalition then
if EventData.IniPlayerName and EventData.IniGroup then if EventData.IniPlayerName and EventData.IniGroup then
if self.IsClientSet and self.ClientSet:IsNotInSet(CLIENT:FindByName(EventData.IniUnitName)) then --if self.IsClientSet and self.ClientSet:IsNotInSet(CLIENT:FindByName(EventData.IniUnitName)) then
if self.IsClientSet and (not self.ClientSet:IsIncludeObject(CLIENT:FindByName(EventData.IniUnitName))) then
self:T(self.lid.."Client not in SET: "..EventData.IniPlayerName) self:T(self.lid.."Client not in SET: "..EventData.IniPlayerName)
return self return self
end end
@ -4064,6 +4065,7 @@ function PLAYERTASKCONTROLLER:onafterStart(From, Event, To)
self:HandleEvent(EVENTS.Crash, self._EventHandler) self:HandleEvent(EVENTS.Crash, self._EventHandler)
self:HandleEvent(EVENTS.PilotDead, self._EventHandler) self:HandleEvent(EVENTS.PilotDead, self._EventHandler)
self:HandleEvent(EVENTS.PlayerEnterAircraft, self._EventHandler) self:HandleEvent(EVENTS.PlayerEnterAircraft, self._EventHandler)
self:SetEventPriority(5)
return self return self
end end