mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
AIRBASE
- AIRBASE: Workaround for DCS bug that helipads have category of airdrome - SET_AIRBASE: Added FilterZones function
This commit is contained in:
parent
3c710613a8
commit
c00eff8b23
@ -5403,6 +5403,7 @@ do -- SET_AIRBASE
|
||||
Airbases = {},
|
||||
Filter = {
|
||||
Coalitions = nil,
|
||||
Zones = nil,
|
||||
},
|
||||
FilterMeta = {
|
||||
Coalitions = {
|
||||
@ -5555,6 +5556,31 @@ do -- SET_AIRBASE
|
||||
return self
|
||||
end
|
||||
|
||||
--- Builds a set of airbase objects in zones.
|
||||
-- @param #SET_AIRBASE self
|
||||
-- @param #table Zones Table of Core.Zone#ZONE Zone objects, or a Core.Set#SET_ZONE
|
||||
-- @return #SET_AIRBASE self
|
||||
function SET_AIRBASE:FilterZones( Zones )
|
||||
if not self.Filter.Zones then
|
||||
self.Filter.Zones = {}
|
||||
end
|
||||
local zones = {}
|
||||
if Zones.ClassName and Zones.ClassName == "SET_ZONE" then
|
||||
zones = Zones.Set
|
||||
elseif type( Zones ) ~= "table" or (type( Zones ) == "table" and Zones.ClassName ) then
|
||||
self:E("***** FilterZones needs either a table of ZONE Objects or a SET_ZONE as parameter!")
|
||||
return self
|
||||
else
|
||||
zones = Zones
|
||||
end
|
||||
for _,Zone in pairs( zones ) do
|
||||
local zonename = Zone:GetName()
|
||||
--self:T((zonename)
|
||||
self.Filter.Zones[zonename] = Zone
|
||||
end
|
||||
return self
|
||||
end
|
||||
|
||||
--- Starts the filtering.
|
||||
-- @param #SET_AIRBASE self
|
||||
-- @return #SET_AIRBASE self
|
||||
@ -5692,6 +5718,20 @@ do -- SET_AIRBASE
|
||||
--self:T(( { "Evaluated Category", MAirbaseCategory } )
|
||||
MAirbaseInclude = MAirbaseInclude and MAirbaseCategory
|
||||
end
|
||||
|
||||
if self.Filter.Zones and MAirbaseInclude then
|
||||
local MAirbaseZone = false
|
||||
for ZoneName, Zone in pairs( self.Filter.Zones ) do
|
||||
--self:T(( "Zone:", ZoneName )
|
||||
local coord = MAirbase:GetCoordinate()
|
||||
if coord and Zone:IsCoordinateInZone(coord) then
|
||||
MAirbaseZone = true
|
||||
end
|
||||
--self:T(( { "Evaluated Zone", MSceneryZone } )
|
||||
end
|
||||
MAirbaseInclude = MAirbaseInclude and MAirbaseZone
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
if self.Filter.Functions and MAirbaseInclude then
|
||||
|
||||
@ -630,9 +630,13 @@ do -- Object
|
||||
--- @function [parent=#Object] destroy
|
||||
-- @param #Object self
|
||||
|
||||
--- @function [parent=#Object] getCategory
|
||||
--- Returns an enumerator of the category for the specific object.
|
||||
-- The enumerator returned is dependent on the category of the object and how the function is called.
|
||||
-- As of DCS 2.9.2 when this function is called on an Object, Unit, Weapon, or Airbase a 2nd value will be returned which details the object sub-category value.
|
||||
-- @function [parent=#Object] getCategory
|
||||
-- @param #Object self
|
||||
-- @return #Object.Category
|
||||
-- @return #Object.Category The object category (1=UNIT, 2=WEAPON, 3=STATIC, 4=BASE, 5=SCENERY, 6=Cargo)
|
||||
-- @return #number The subcategory of the passed object, e.g. Unit.Category if a unit object was passed.
|
||||
|
||||
--- Returns type name of the Object.
|
||||
-- @function [parent=#Object] getTypeName
|
||||
|
||||
@ -514,7 +514,7 @@ function UTILS.PrintTableToLog(table, indent, noprint)
|
||||
env.info(string.rep(" ", indent) .. tostring(k) .. " = {")
|
||||
end
|
||||
text = text ..string.rep(" ", indent) .. tostring(k) .. " = {\n"
|
||||
text = text .. tostring(UTILS.PrintTableToLog(v, indent + 1)).."\n"
|
||||
text = text .. tostring(UTILS.PrintTableToLog(v, indent + 1), noprint).."\n"
|
||||
if not noprint then
|
||||
env.info(string.rep(" ", indent) .. "},")
|
||||
end
|
||||
|
||||
@ -1009,6 +1009,7 @@ if self.category==Airbase.Category.AIRDROME then
|
||||
self.isAirdrome=true
|
||||
elseif self.category==Airbase.Category.HELIPAD or self.descriptors.typeName=="FARP_SINGLE_01" then
|
||||
self.isHelipad=true
|
||||
self.category=Airbase.Category.HELIPAD
|
||||
elseif self.category==Airbase.Category.SHIP then
|
||||
self.isShip=true
|
||||
-- DCS bug: Oil rigs and gas platforms have category=2 (ship). Also they cannot be retrieved by coalition.getStaticObjects()
|
||||
@ -1025,20 +1026,33 @@ end
|
||||
-- Init Runways.
|
||||
self:_InitRunways()
|
||||
|
||||
-- Number of runways
|
||||
local Nrunways=#self.runways
|
||||
|
||||
-- Set the active runways based on wind direction.
|
||||
if self.isAirdrome then
|
||||
if Nrunways>0 then
|
||||
self:SetActiveRunway()
|
||||
end
|
||||
|
||||
-- Init parking spots.
|
||||
self:_InitParkingSpots()
|
||||
|
||||
-- Some heliports identify as airdromes in the airbase category. This is buggy in the descriptors category but also in the getCategory() and getCategoryEx() functions.
|
||||
if self.category==Airbase.Category.AIRDROME and (Nrunways==0 or self.NparkingTotal==self.NparkingTerminal[AIRBASE.TerminalType.HelicopterOnly]) then
|
||||
self:E(string.format("WARNING: %s identifies as airdrome (category=0) but has no runways or just helo parking ==> will change to helipad (category=1)", self.AirbaseName))
|
||||
self.category=Airbase.Category.HELIPAD
|
||||
self.isAirdrome=false
|
||||
self.isHelipad=true
|
||||
--self:GetCoordinate():MarkToAll("Helipad not airdrome")
|
||||
end
|
||||
|
||||
-- Get 2D position vector.
|
||||
local vec2=self:GetVec2()
|
||||
|
||||
-- Init coordinate.
|
||||
self:GetCoordinate()
|
||||
|
||||
|
||||
-- Storage.
|
||||
self.storage=_DATABASE:AddStorage(AirbaseName)
|
||||
|
||||
@ -1061,6 +1075,46 @@ end
|
||||
return self
|
||||
end
|
||||
|
||||
--- Get the category of this airbase. This is only a debug function because DCS 2.9 incorrectly returns heliports as airdromes.
|
||||
-- @param #AIRBASE self
|
||||
function AIRBASE:_GetCategory()
|
||||
|
||||
local name=self.AirbaseName
|
||||
|
||||
local static=StaticObject.getByName(name)
|
||||
local airbase=Airbase.getByName(name)
|
||||
local unit=Unit.getByName(name)
|
||||
|
||||
local text=string.format("\n=====================================================")
|
||||
text=text..string.format("\nAirbase %s:", name)
|
||||
if static then
|
||||
local oc, uc=static:getCategory()
|
||||
local ex=static:getCategoryEx()
|
||||
text=text..string.format("\nSTATIC: oc=%d, uc=%d, ex=%d", oc, uc, ex)
|
||||
--text=text..UTILS.PrintTableToLog(static:getDesc(), nil, true)
|
||||
text=text..string.format("\n--------------------------------------------------")
|
||||
end
|
||||
if unit then
|
||||
local oc, uc=unit:getCategory()
|
||||
local ex=unit:getCategoryEx()
|
||||
text=text..string.format("\nUNIT: oc=%d, uc=%d, ex=%d", oc, uc, ex)
|
||||
--text=text..UTILS.PrintTableToLog(unit:getDesc(), nil, true)
|
||||
text=text..string.format("\n--------------------------------------------------")
|
||||
end
|
||||
if airbase then
|
||||
local oc, uc=airbase:getCategory()
|
||||
local ex=airbase:getCategoryEx()
|
||||
text=text..string.format("\nAIRBASE: oc=%d, uc=%d, ex=%d", oc, uc, ex)
|
||||
text=text..string.format("\n--------------------------------------------------")
|
||||
text=text..UTILS.PrintTableToLog(airbase:getDesc(), nil, true)
|
||||
end
|
||||
|
||||
text=text..string.format("\n=====================================================")
|
||||
|
||||
|
||||
env.info(text)
|
||||
end
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
-- Reference methods
|
||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
@ -1593,6 +1647,9 @@ function AIRBASE:_InitParkingSpots()
|
||||
table.insert(self.parking, park)
|
||||
end
|
||||
|
||||
-- Runways are not included in total number of parking spots
|
||||
self.NparkingTotal=self.NparkingTotal-self.NparkingTerminal[AIRBASE.TerminalType.Runway]
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
@ -2079,11 +2136,6 @@ function AIRBASE:_InitRunways(IncludeInverse)
|
||||
-- Runway table.
|
||||
local Runways={}
|
||||
|
||||
if self:GetAirbaseCategory()~=Airbase.Category.AIRDROME then
|
||||
self.runways={}
|
||||
return {}
|
||||
end
|
||||
|
||||
--- Function to create a runway data table.
|
||||
local function _createRunway(name, course, width, length, center)
|
||||
|
||||
@ -2169,7 +2221,7 @@ function AIRBASE:_InitRunways(IncludeInverse)
|
||||
-- Debug info.
|
||||
self:T2(runways)
|
||||
|
||||
if runways then
|
||||
if runways and #runways>0 then
|
||||
|
||||
-- Loop over runways.
|
||||
for _,rwy in pairs(runways) do
|
||||
@ -2203,6 +2255,12 @@ function AIRBASE:_InitRunways(IncludeInverse)
|
||||
|
||||
end
|
||||
|
||||
else
|
||||
|
||||
-- No runways
|
||||
self.runways={}
|
||||
return {}
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user