mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2026-08-11 03:43:38 +00:00
Update
- SET: cleaned up FilterPrefixes - AUFTRAG: fixed bug in _GetDCSAttackTask - CONTROLLABLE: Removed unused parameter AttackQtyLimit from TaskAttackGroup, changed weapon type enum for some tasks.
This commit is contained in:
@@ -54,7 +54,7 @@
|
||||
|
||||
do -- SET_BASE
|
||||
|
||||
---
|
||||
--- SET_BASE class.
|
||||
-- @type SET_BASE
|
||||
-- @field #table Filter Table of filters.
|
||||
-- @field #table Set Table of objects.
|
||||
@@ -62,6 +62,7 @@ do -- SET_BASE
|
||||
-- @field #table List Unused table.
|
||||
-- @field Core.Scheduler#SCHEDULER CallScheduler
|
||||
-- @field #SET_BASE.Filters Filter Filters
|
||||
-- @field #booleaen filterNoRegex If true, FilterPrefix ignores special characters and evaluates plain string.
|
||||
-- @extends Core.Base#BASE
|
||||
|
||||
--- The @{Core.Set#SET_BASE} class defines the core functions that define a collection of objects.
|
||||
@@ -100,6 +101,7 @@ do -- SET_BASE
|
||||
["neutral"] = coalition.side.NEUTRAL,
|
||||
},
|
||||
},
|
||||
filterNoRegex=false,
|
||||
}
|
||||
|
||||
--- Filters
|
||||
@@ -244,6 +246,26 @@ do -- SET_BASE
|
||||
return ObjectFound
|
||||
end
|
||||
|
||||
|
||||
--- Compares string for FilterPrefix function.
|
||||
-- @param #SET_BASE self
|
||||
-- @param #string Name The Name of the object.
|
||||
-- @param #string Pattern The pattern that is contained in the Name.
|
||||
-- @param #boolean NoRegex If `true`, special characters in the Name are interpreted as plain text and not regular expressions. Default is `self.filterNoregex`.
|
||||
-- @param #boolean ReplaceDash If `true`, dashes are not used as regex.
|
||||
-- @return #boolean Returns `true`, if the pattern is contained in the name and false otherwise.
|
||||
function SET_BASE:_SearchPattern(Name, Pattern, NoRegex, ReplaceDash)
|
||||
NoRegex=NoRegex or self.filterNoRegex
|
||||
if ReplaceDash==true then
|
||||
-- Not sure why "-" is replaced by "%-" ?! - So we can still match group names with a dash in them
|
||||
-- reason is that the string is interpreted as a pattern and "-" is a special character then. For interpreting it as a string, fourth parameter needs to be set to true.
|
||||
Pattern=Pattern:gsub("-", "%%-")
|
||||
end
|
||||
local contain=string.find(Name, Pattern, 1, NoRegex)
|
||||
return contain
|
||||
end
|
||||
|
||||
|
||||
--- Gets the Set.
|
||||
-- @param #SET_BASE self
|
||||
-- @return #SET_BASE self
|
||||
@@ -2118,19 +2140,16 @@ do
|
||||
if self.Filter.GroupPrefixes and MGroupInclude then
|
||||
local MGroupPrefix = false
|
||||
for GroupPrefixId, GroupPrefix in pairs(self.Filter.GroupPrefixes) do
|
||||
--self:I({ "Prefix:", MGroup:GetName(), GroupPrefix })
|
||||
if string.find(MGroup:GetName(), string.gsub(GroupPrefix,"-","%%-"),1) then
|
||||
if self:_SearchPattern(MGroup:GetName(), GroupPrefix, false, true) then
|
||||
MGroupPrefix = true
|
||||
end
|
||||
end
|
||||
MGroupInclude = MGroupInclude and MGroupPrefix
|
||||
--self:I("Is Included: "..tostring(MGroupInclude))
|
||||
end
|
||||
|
||||
if self.Filter.Zones and MGroupInclude then
|
||||
local MGroupZone = false
|
||||
for ZoneName, Zone in pairs(self.Filter.Zones) do
|
||||
--self:T("Zone:", ZoneName)
|
||||
if MGroup:IsInZone(Zone) then
|
||||
MGroupZone = true
|
||||
end
|
||||
@@ -2144,7 +2163,6 @@ do
|
||||
MGroupInclude = MGroupInclude and MGroupFunc
|
||||
end
|
||||
|
||||
--self:I(MGroupInclude)
|
||||
return MGroupInclude
|
||||
end
|
||||
|
||||
@@ -3375,9 +3393,8 @@ do -- SET_UNIT
|
||||
|
||||
if self.Filter.UnitPrefixes and MUnitInclude then
|
||||
local MUnitPrefix = false
|
||||
for UnitPrefixId, UnitPrefix in pairs(self.Filter.UnitPrefixes) do
|
||||
--self:T3({ "Prefix:", string.find(MUnit:GetName(), UnitPrefix, 1), UnitPrefix })
|
||||
if string.find(MUnit:GetName(), UnitPrefix, 1) then
|
||||
for UnitPrefixId, UnitPrefix in pairs(self.Filter.UnitPrefixes) do
|
||||
if self:_SearchPattern(MUnit:GetName(), UnitPrefix, false, true) then
|
||||
MUnitPrefix = true
|
||||
end
|
||||
end
|
||||
@@ -4148,8 +4165,7 @@ do -- SET_STATIC
|
||||
if self.Filter.StaticPrefixes then
|
||||
local MStaticPrefix = false
|
||||
for StaticPrefixId, StaticPrefix in pairs(self.Filter.StaticPrefixes) do
|
||||
--self:T(3({ "Prefix:", string.find(MStatic:GetName(), StaticPrefix, 1), StaticPrefix })
|
||||
if string.find(MStatic:GetName(), StaticPrefix, 1) then
|
||||
if self:_SearchPattern(MStatic:GetName(), StaticPrefix, false, true) then
|
||||
MStaticPrefix = true
|
||||
end
|
||||
end
|
||||
@@ -4932,12 +4948,10 @@ do -- SET_CLIENT
|
||||
if self.Filter.ClientPrefixes and MClientInclude then
|
||||
local MClientPrefix = false
|
||||
for ClientPrefixId, ClientPrefix in pairs(self.Filter.ClientPrefixes) do
|
||||
--self:T3({ "Prefix:", string.find(MClient.UnitName, ClientPrefix, 1), ClientPrefix })
|
||||
if string.find(MClient.UnitName, ClientPrefix, 1) then
|
||||
if self:_SearchPattern(MClient.UnitName, ClientPrefix) then
|
||||
MClientPrefix = true
|
||||
end
|
||||
end
|
||||
--self:T({ "Evaluated Prefix", MClientPrefix })
|
||||
MClientInclude = MClientInclude and MClientPrefix
|
||||
end
|
||||
|
||||
@@ -4958,7 +4972,7 @@ do -- SET_CLIENT
|
||||
local playername = MClient:GetPlayerName() or "Unknown"
|
||||
--self:T(playername)
|
||||
for _,_Playername in pairs(self.Filter.Playernames) do
|
||||
if playername and string.find(playername,_Playername) then
|
||||
if playername and self:_SearchPattern(playername,_Playername) then
|
||||
MClientPlayername = true
|
||||
end
|
||||
end
|
||||
@@ -4971,7 +4985,7 @@ do -- SET_CLIENT
|
||||
local callsign = MClient:GetCallsign()
|
||||
--self:I(callsign)
|
||||
for _,_Callsign in pairs(self.Filter.Callsigns) do
|
||||
if callsign and string.find(callsign,_Callsign,1,true) then
|
||||
if callsign and self:_SearchPattern(callsign,_Callsign, true) then
|
||||
MClientCallsigns = true
|
||||
end
|
||||
end
|
||||
@@ -5392,12 +5406,10 @@ do -- SET_PLAYER
|
||||
if self.Filter.ClientPrefixes then
|
||||
local MClientPrefix = false
|
||||
for ClientPrefixId, ClientPrefix in pairs(self.Filter.ClientPrefixes) do
|
||||
--self:T(3({ "Prefix:", string.find(MClient.UnitName, ClientPrefix, 1), ClientPrefix })
|
||||
if string.find(MClient.UnitName, ClientPrefix, 1) then
|
||||
if self:_SearchPattern(MClient.UnitName,ClientPrefix) then
|
||||
MClientPrefix = true
|
||||
end
|
||||
end
|
||||
--self:T(({ "Evaluated Prefix", MClientPrefix })
|
||||
MClientInclude = MClientInclude and MClientPrefix
|
||||
end
|
||||
end
|
||||
@@ -6101,12 +6113,10 @@ do -- SET_ZONE
|
||||
if self.Filter.Prefixes then
|
||||
local MZonePrefix = false
|
||||
for ZonePrefixId, ZonePrefix in pairs(self.Filter.Prefixes) do
|
||||
--self:T(2({ "Prefix:", string.find(MZoneName, ZonePrefix, 1), ZonePrefix })
|
||||
if string.find(MZoneName, ZonePrefix, 1) then
|
||||
if self:_SearchPattern(MZoneName, ZonePrefix, false, true) then
|
||||
MZonePrefix = true
|
||||
end
|
||||
end
|
||||
--self:T(({ "Evaluated Prefix", MZonePrefix })
|
||||
MZoneInclude = MZoneInclude and MZonePrefix
|
||||
end
|
||||
end
|
||||
@@ -6612,12 +6622,10 @@ do -- SET_ZONE_GOAL
|
||||
if self.Filter.Prefixes then
|
||||
local MZonePrefix = false
|
||||
for ZonePrefixId, ZonePrefix in pairs(self.Filter.Prefixes) do
|
||||
--self:T(3({ "Prefix:", string.find(MZoneName, ZonePrefix, 1), ZonePrefix })
|
||||
if string.find(MZoneName, ZonePrefix, 1) then
|
||||
if self:_SearchPattern(MZoneName, ZonePrefix, false, true) then
|
||||
MZonePrefix = true
|
||||
end
|
||||
end
|
||||
--self:T(({ "Evaluated Prefix", MZonePrefix })
|
||||
MZoneInclude = MZoneInclude and MZonePrefix
|
||||
end
|
||||
end
|
||||
@@ -6974,18 +6982,14 @@ do -- SET_OPSZONE
|
||||
-- Loop over prefixes.
|
||||
for ZonePrefixId, ZonePrefix in pairs(self.Filter.Prefixes) do
|
||||
|
||||
-- Prifix
|
||||
--self:T(3({ "Prefix:", string.find(MZoneName, ZonePrefix, 1), ZonePrefix })
|
||||
|
||||
if string.find(MZoneName, ZonePrefix, 1) then
|
||||
-- Prefix
|
||||
if self:_SearchPattern(MZoneName, ZonePrefix, false, true) then
|
||||
MZonePrefix = true
|
||||
break --Break the loop as we found the prefix.
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
--self:T(({ "Evaluated Prefix", MZonePrefix })
|
||||
|
||||
MZoneInclude = MZoneInclude and MZonePrefix
|
||||
end
|
||||
|
||||
@@ -7773,7 +7777,7 @@ function SET_OPSGROUP:_EventOnBirth(Event)
|
||||
local MGroupPrefix = false
|
||||
|
||||
for GroupPrefixId, GroupPrefix in pairs(self.Filter.GroupPrefixes) do
|
||||
if string.find(MGroup:GetName(), GroupPrefix:gsub ("-", "%%-"), 1) then --Not sure why "-" is replaced by "%-" ?! - So we can still match group names with a dash in them
|
||||
if self:_SearchPattern(MGroup:GetName(), GroupPrefix, false, true) then
|
||||
MGroupPrefix = true
|
||||
end
|
||||
end
|
||||
@@ -8107,12 +8111,10 @@ do -- SET_SCENERY
|
||||
if self.Filter.Prefixes then
|
||||
local MSceneryPrefix = false
|
||||
for ZonePrefixId, ZonePrefix in pairs(self.Filter.Prefixes) do
|
||||
--self:T(({ "Prefix:", string.find(MSceneryName, ZonePrefix, 1), ZonePrefix })
|
||||
if string.find(MSceneryName, ZonePrefix, 1) then
|
||||
if self:_SearchPattern(MSceneryName, ZonePrefix, false, true) then
|
||||
MSceneryPrefix = true
|
||||
end
|
||||
end
|
||||
--self:T(({ "Evaluated Prefix", MSceneryPrefix })
|
||||
MSceneryInclude = MSceneryInclude and MSceneryPrefix
|
||||
end
|
||||
|
||||
@@ -8380,8 +8382,7 @@ do -- SET_DYNAMICCARGO
|
||||
if self.Filter.StaticPrefixes then
|
||||
local DCargoPrefix = false
|
||||
for StaticPrefixId, StaticPrefix in pairs(self.Filter.StaticPrefixes) do
|
||||
--self:T2({ "Prefix:", string.find(DCargo:GetName(), StaticPrefix, 1), StaticPrefix })
|
||||
if string.find(DCargo:GetName(), StaticPrefix, 1) then
|
||||
if self:_SearchPattern(DCargo:GetName(), StaticPrefix, false, true) then
|
||||
DCargoPrefix = true
|
||||
end
|
||||
end
|
||||
@@ -8549,7 +8550,7 @@ do -- SET_DYNAMICCARGO
|
||||
function SET_DYNAMICCARGO:FilterCurrentOwner(PlayerName)
|
||||
self:FilterFunction(
|
||||
function(cargo)
|
||||
if cargo and cargo.Owner and string.find(cargo.Owner,PlayerName,1,true) then
|
||||
if cargo and cargo.Owner and self:_SearchPattern(cargo.Owner, PlayerName, true) then
|
||||
return true
|
||||
else
|
||||
return false
|
||||
|
||||
Reference in New Issue
Block a user