mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2026-08-11 03:43:38 +00:00
Merge branch 'FF/Develop' into FF/Fox2
This commit is contained in:
@@ -251,24 +251,24 @@ end
|
||||
--- Adds a Airbase based on the Airbase Name in the DATABASE.
|
||||
-- @param #DATABASE self
|
||||
-- @param #string AirbaseName The name of the airbase.
|
||||
-- @return Wrapper.Airbase#AIRBASE The AIRBASE object.
|
||||
-- @return Wrapper.Airbase#AIRBASE Airbase object.
|
||||
function DATABASE:AddAirbase( AirbaseName )
|
||||
|
||||
if not self.AIRBASES[AirbaseName] then
|
||||
|
||||
|
||||
local airbase = AIRBASE:Register( AirbaseName ) --Wrapper.Airbase#AIRBASE
|
||||
self.AIRBASES[AirbaseName]=airbase
|
||||
|
||||
|
||||
-- Category and name.
|
||||
airbase.AirbaseCategory=airbase:GetAirbaseCategory()
|
||||
airbase.AirbaseCategoryName=AIRBASE.CategoryName[airbase.AirbaseCategory]
|
||||
|
||||
|
||||
-- Get airbase ID. WARNING: For ships it gets the unit ID. This can be identical to an exising AIRDROME or FARM ID! Therefore, units get a negative sign.
|
||||
airbase.AirbaseID=airbase:GetID()
|
||||
|
||||
|
||||
self:I(string.format("Adding airbase %s (ID=%d): %s with %d parking spots", tostring(airbase.AirbaseName), airbase.AirbaseID, airbase.AirbaseCategoryName, tonumber(#airbase.parking)))
|
||||
end
|
||||
|
||||
|
||||
return self.AIRBASES[AirbaseName]
|
||||
end
|
||||
|
||||
@@ -910,6 +910,7 @@ end
|
||||
--- @param #DATABASE self
|
||||
function DATABASE:_RegisterAirbases()
|
||||
|
||||
--[[
|
||||
local CoalitionsData = { AirbasesRed = coalition.getAirbases( coalition.side.RED ), AirbasesBlue = coalition.getAirbases( coalition.side.BLUE ), AirbasesNeutral = coalition.getAirbases( coalition.side.NEUTRAL ) }
|
||||
for CoalitionId, CoalitionData in pairs( CoalitionsData ) do
|
||||
for DCSAirbaseId, DCSAirbase in pairs( CoalitionData ) do
|
||||
@@ -920,6 +921,18 @@ function DATABASE:_RegisterAirbases()
|
||||
local airbase=self:AddAirbase( DCSAirbaseName )
|
||||
end
|
||||
end
|
||||
]]
|
||||
|
||||
for DCSAirbaseId, DCSAirbase in pairs(world.getAirbases()) do
|
||||
local DCSAirbaseName = DCSAirbase:getName()
|
||||
|
||||
-- This gives the incorrect value to be inserted into the airdromeID for DCS 2.5.6!
|
||||
local airbaseID=DCSAirbase:getID()
|
||||
|
||||
local airbase=self:AddAirbase( DCSAirbaseName )
|
||||
|
||||
self:I(string.format("Register Airbase: %s, getID=%d, GetID=%d (unique=%d)", DCSAirbaseName, DCSAirbase:getID(), airbase:GetID(), airbase:GetID(true)))
|
||||
end
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
@@ -355,22 +355,18 @@ AIRBASE.TerminalType = {
|
||||
-- @return Wrapper.Airbase#AIRBASE
|
||||
function AIRBASE:Register( AirbaseName )
|
||||
|
||||
-- Inherit from POSITIONABLE.
|
||||
local self = BASE:Inherit( self, POSITIONABLE:New( AirbaseName ) ) --#AIRBASE
|
||||
|
||||
-- Set airbase name.
|
||||
local self = BASE:Inherit( self, POSITIONABLE:New( AirbaseName ) ) --#AIRBASE
|
||||
self.AirbaseName = AirbaseName
|
||||
|
||||
-- Set airbase zone.
|
||||
self.AirbaseID = self:GetID(true)
|
||||
self.AirbaseZone = ZONE_RADIUS:New( AirbaseName, self:GetVec2(), 2500 )
|
||||
|
||||
|
||||
-- Get Parking data.
|
||||
self.parking=self:GetParkingSpotsTable()
|
||||
|
||||
|
||||
-- Register zone.
|
||||
_DATABASE.ZONENAMES[AirbaseName] = AirbaseName
|
||||
_DATABASE:AddZone( AirbaseName, self.AirbaseZone )
|
||||
|
||||
_DATABASE:AddZone( AirbaseName, self.AirbaseZone )
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
@@ -406,7 +402,7 @@ function AIRBASE:FindByID(id)
|
||||
for name,_airbase in pairs(_DATABASE.AIRBASES) do
|
||||
local airbase=_airbase --#AIRBASE
|
||||
|
||||
local aid=airbase:GetID()
|
||||
local aid=tonumber(airbase:GetID(true))
|
||||
|
||||
if aid==id then
|
||||
return airbase
|
||||
@@ -474,6 +470,54 @@ function AIRBASE.GetAllAirbases(coalition, category)
|
||||
return airbases
|
||||
end
|
||||
|
||||
--- Get ID of the airbase.
|
||||
-- @param #AIRBASE self
|
||||
-- @param #boolean unique (Optional) If true, ships will get a negative sign as the unit ID might be the same as an airbase ID. Default off!
|
||||
-- @return #number The airbase ID.
|
||||
function AIRBASE:GetID(unique)
|
||||
|
||||
if self.AirbaseID then
|
||||
|
||||
return unique and self.AirbaseID or math.abs(self.AirbaseID)
|
||||
|
||||
else
|
||||
|
||||
for DCSAirbaseId, DCSAirbase in pairs(world.getAirbases()) do
|
||||
|
||||
-- Get the airbase name.
|
||||
local AirbaseName = DCSAirbase:getName()
|
||||
|
||||
-- This gives the incorrect value to be inserted into the airdromeID for DCS 2.5.6!
|
||||
local airbaseID=tonumber(DCSAirbase:getID())
|
||||
|
||||
-- No way AFIK to get the DCS version. So we check if the event exists. That should tell us if we are on DCS 2.5.6 or prior to that.
|
||||
if world.event.S_EVENT_KILL and world.event.S_EVENT_KILL>0 and self:GetAirbaseCategory()==Airbase.Category.AIRDROME then
|
||||
|
||||
-- We have to take the key value of this loop!
|
||||
airbaseID=DCSAirbaseId
|
||||
|
||||
-- Now another quirk: for Caucasus, we need to add 11 to the key value to get the correct ID. See https://forums.eagle.ru/showpost.php?p=4210774&postcount=11
|
||||
if UTILS.GetDCSMap()==DCSMAP.Caucasus then
|
||||
airbaseID=airbaseID+11
|
||||
end
|
||||
end
|
||||
|
||||
if AirbaseName==self.AirbaseName then
|
||||
if self:GetAirbaseCategory()==Airbase.Category.SHIP then
|
||||
-- Ships get a negative sign as their unit number might be the same as the ID of another airbase.
|
||||
return unique and -airbaseID or airbaseID
|
||||
else
|
||||
return airbaseID
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
return nil
|
||||
end
|
||||
|
||||
|
||||
--- Returns a table of parking data for a given airbase. If the optional parameter *available* is true only available parking will be returned, otherwise all parking at the base is returned. Term types have the following enumerated values:
|
||||
--
|
||||
@@ -712,7 +756,7 @@ function AIRBASE:MarkParkingSpots(termtype, mark)
|
||||
self:E(string.format("Parking spots at %s for termial type %s:", airbasename, tostring(termtype)))
|
||||
|
||||
self.parkingmarks=self.parkingmarks or {}
|
||||
|
||||
|
||||
for _,_spot in pairs(parkingdata) do
|
||||
|
||||
-- Mark text.
|
||||
@@ -733,7 +777,7 @@ function AIRBASE:MarkParkingSpots(termtype, mark)
|
||||
airbasename, _spot.TerminalID, _spot.TerminalType,tostring(_spot.Free),tostring(_spot.TOAC),_spot.TerminalID0,_spot.DistToRwy)
|
||||
self:I(_text)
|
||||
end
|
||||
|
||||
|
||||
return self.parkingmarks
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user