mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2026-08-12 16:57:50 +00:00
Update Spawn.lua
SPAWN:SpawnAtAirbase() and SPAWN:ParkAircraft() now handle HELIPAD/FARP parking the same way as airbases: explicit parking is honored first, helicopter spawns try the smarter parking search before falling back to the simpler free-spot table.
This commit is contained in:
@@ -2178,15 +2178,43 @@ function SPAWN:SpawnAtAirbase( SpawnAirbase, Takeoff, TakeoffAltitude, TerminalT
|
|||||||
local scanscenery = false
|
local scanscenery = false
|
||||||
local verysafe = false
|
local verysafe = false
|
||||||
|
|
||||||
|
-- Use exact parking data when provided, otherwise let helicopters on ships/FARPs
|
||||||
|
-- use the smarter parking search before falling back to the procedural queue path.
|
||||||
|
local useexplicitspots = false
|
||||||
|
|
||||||
-- Number of free parking spots at the airbase.
|
-- Number of free parking spots at the airbase.
|
||||||
if autoparking then
|
if Parkingdata~=nil then
|
||||||
|
-- Parking data explicitly set by user as input parameter.
|
||||||
|
nfree = #Parkingdata
|
||||||
|
spots = Parkingdata
|
||||||
|
useexplicitspots = true
|
||||||
|
elseif autoparking and AirbaseCategory == Airbase.Category.HELIPAD and ishelo then
|
||||||
|
if termtype == nil then
|
||||||
|
-- Helo is spawned. Try exclusive helo spots first.
|
||||||
|
spots = SpawnAirbase:FindFreeParkingSpotForAircraft( group, AIRBASE.TerminalType.HelicopterOnly, scanradius, scanunits, scanstatics, scanscenery, verysafe, nunits, nil )
|
||||||
|
nfree = #spots
|
||||||
|
if nfree < nunits then
|
||||||
|
-- Not enough helo ports. Let's try also other terminal types.
|
||||||
|
spots = SpawnAirbase:FindFreeParkingSpotForAircraft( group, AIRBASE.TerminalType.HelicopterUsable, scanradius, scanunits, scanstatics, scanscenery, verysafe, nunits, nil )
|
||||||
|
nfree = #spots
|
||||||
|
end
|
||||||
|
else
|
||||||
|
-- Terminal type explicitly given.
|
||||||
|
spots = SpawnAirbase:FindFreeParkingSpotForAircraft( group, termtype, scanradius, scanunits, scanstatics, scanscenery, verysafe, nunits, nil )
|
||||||
|
nfree = #spots
|
||||||
|
end
|
||||||
|
|
||||||
|
if nfree >= nunits then
|
||||||
|
useexplicitspots = true
|
||||||
|
else
|
||||||
|
-- These places work procedural and have some kind of build in queue ==> Less effort.
|
||||||
|
nfree = SpawnAirbase:GetFreeParkingSpotsNumber( termtype, true )
|
||||||
|
spots = SpawnAirbase:GetFreeParkingSpotsTable( termtype, true )
|
||||||
|
end
|
||||||
|
elseif autoparking then
|
||||||
-- These places work procedural and have some kind of build in queue ==> Less effort.
|
-- These places work procedural and have some kind of build in queue ==> Less effort.
|
||||||
nfree = SpawnAirbase:GetFreeParkingSpotsNumber( termtype, true )
|
nfree = SpawnAirbase:GetFreeParkingSpotsNumber( termtype, true )
|
||||||
spots = SpawnAirbase:GetFreeParkingSpotsTable( termtype, true )
|
spots = SpawnAirbase:GetFreeParkingSpotsTable( termtype, true )
|
||||||
elseif Parkingdata~=nil then
|
|
||||||
-- Parking data explicitly set by user as input parameter. (This was commented out for some unknown reason. But I need it this way.)
|
|
||||||
nfree=#Parkingdata
|
|
||||||
spots=Parkingdata
|
|
||||||
else
|
else
|
||||||
if ishelo then
|
if ishelo then
|
||||||
if termtype == nil then
|
if termtype == nil then
|
||||||
@@ -2238,7 +2266,7 @@ function SPAWN:SpawnAtAirbase( SpawnAirbase, Takeoff, TakeoffAltitude, TerminalT
|
|||||||
local _notenough = false
|
local _notenough = false
|
||||||
|
|
||||||
-- Need to differentiate some cases again.
|
-- Need to differentiate some cases again.
|
||||||
if autoparking then
|
if autoparking and not useexplicitspots then
|
||||||
|
|
||||||
-- On free spot required in these cases.
|
-- On free spot required in these cases.
|
||||||
if nfree >= 1 then
|
if nfree >= 1 then
|
||||||
@@ -2582,21 +2610,51 @@ function SPAWN:ParkAircraft( SpawnAirbase, TerminalType, Parkingdata, SpawnIndex
|
|||||||
local scanscenery = false
|
local scanscenery = false
|
||||||
local verysafe = false
|
local verysafe = false
|
||||||
|
|
||||||
-- Number of free parking spots at the airbase.
|
-- Use exact parking data when provided, otherwise let helicopters on FARPs
|
||||||
if spawnonship or spawnonfarp or spawnonrunway then
|
-- use the smarter parking search before falling back to the procedural queue path.
|
||||||
-- These places work procedural and have some kind of build in queue ==> Less effort.
|
local useexplicitspots = false
|
||||||
--self:T2( string.format( "Group %s is spawned on farp/ship/runway %s.", self.SpawnTemplatePrefix, SpawnAirbase:GetName() ) )
|
|
||||||
nfree = SpawnAirbase:GetFreeParkingSpotsNumber( termtype, true )
|
-- Number of free parking spots at the airbase.
|
||||||
spots = SpawnAirbase:GetFreeParkingSpotsTable( termtype, true )
|
if Parkingdata~=nil then
|
||||||
--[[
|
-- Parking data explicitly set by user as input parameter.
|
||||||
elseif Parkingdata~=nil then
|
nfree = #Parkingdata
|
||||||
-- Parking data explicitly set by user as input parameter.
|
spots = Parkingdata
|
||||||
nfree=#Parkingdata
|
useexplicitspots = true
|
||||||
spots=Parkingdata
|
elseif spawnonfarp and ishelo then
|
||||||
]]
|
|
||||||
else
|
|
||||||
if ishelo then
|
|
||||||
if termtype == nil then
|
if termtype == nil then
|
||||||
|
-- Helo is spawned. Try exclusive helo spots first.
|
||||||
|
--self:T2( string.format( "Helo group %s is at %s using terminal type %d.", self.SpawnTemplatePrefix, SpawnAirbase:GetName(), AIRBASE.TerminalType.HelicopterOnly ) )
|
||||||
|
spots = SpawnAirbase:FindFreeParkingSpotForAircraft( TemplateGroup, AIRBASE.TerminalType.HelicopterOnly, scanradius, scanunits, scanstatics, scanscenery, verysafe, nunits, nil )
|
||||||
|
nfree = #spots
|
||||||
|
if nfree < nunits then
|
||||||
|
-- Not enough helo ports. Let's try also other terminal types.
|
||||||
|
--self:T2( string.format( "Helo group %s is at %s using terminal type %d.", self.SpawnTemplatePrefix, SpawnAirbase:GetName(), AIRBASE.TerminalType.HelicopterUsable ) )
|
||||||
|
spots = SpawnAirbase:FindFreeParkingSpotForAircraft( TemplateGroup, AIRBASE.TerminalType.HelicopterUsable, scanradius, scanunits, scanstatics, scanscenery, verysafe, nunits, nil )
|
||||||
|
nfree = #spots
|
||||||
|
end
|
||||||
|
else
|
||||||
|
-- Terminal type explicitly given.
|
||||||
|
--self:T2( string.format( "Helo group %s is at %s using terminal type %d.", self.SpawnTemplatePrefix, SpawnAirbase:GetName(), termtype ) )
|
||||||
|
spots = SpawnAirbase:FindFreeParkingSpotForAircraft( TemplateGroup, termtype, scanradius, scanunits, scanstatics, scanscenery, verysafe, nunits, nil )
|
||||||
|
nfree = #spots
|
||||||
|
end
|
||||||
|
|
||||||
|
if nfree >= nunits then
|
||||||
|
useexplicitspots = true
|
||||||
|
else
|
||||||
|
-- These places work procedural and have some kind of build in queue ==> Less effort.
|
||||||
|
--self:T2( string.format( "Group %s is spawned on farp %s using procedural spots.", self.SpawnTemplatePrefix, SpawnAirbase:GetName() ) )
|
||||||
|
nfree = SpawnAirbase:GetFreeParkingSpotsNumber( termtype, true )
|
||||||
|
spots = SpawnAirbase:GetFreeParkingSpotsTable( termtype, true )
|
||||||
|
end
|
||||||
|
elseif spawnonship or spawnonfarp or spawnonrunway then
|
||||||
|
-- These places work procedural and have some kind of build in queue ==> Less effort.
|
||||||
|
--self:T2( string.format( "Group %s is spawned on farp/ship/runway %s.", self.SpawnTemplatePrefix, SpawnAirbase:GetName() ) )
|
||||||
|
nfree = SpawnAirbase:GetFreeParkingSpotsNumber( termtype, true )
|
||||||
|
spots = SpawnAirbase:GetFreeParkingSpotsTable( termtype, true )
|
||||||
|
else
|
||||||
|
if ishelo then
|
||||||
|
if termtype == nil then
|
||||||
-- Helo is spawned. Try exclusive helo spots first.
|
-- Helo is spawned. Try exclusive helo spots first.
|
||||||
--self:T2( string.format( "Helo group %s is at %s using terminal type %d.", self.SpawnTemplatePrefix, SpawnAirbase:GetName(), AIRBASE.TerminalType.HelicopterOnly ) )
|
--self:T2( string.format( "Helo group %s is at %s using terminal type %d.", self.SpawnTemplatePrefix, SpawnAirbase:GetName(), AIRBASE.TerminalType.HelicopterOnly ) )
|
||||||
spots = SpawnAirbase:FindFreeParkingSpotForAircraft( TemplateGroup, AIRBASE.TerminalType.HelicopterOnly, scanradius, scanunits, scanstatics, scanscenery, verysafe, nunits, Parkingdata )
|
spots = SpawnAirbase:FindFreeParkingSpotForAircraft( TemplateGroup, AIRBASE.TerminalType.HelicopterOnly, scanradius, scanunits, scanstatics, scanscenery, verysafe, nunits, Parkingdata )
|
||||||
@@ -2659,7 +2717,7 @@ function SPAWN:ParkAircraft( SpawnAirbase, TerminalType, Parkingdata, SpawnIndex
|
|||||||
local _notenough = false
|
local _notenough = false
|
||||||
|
|
||||||
-- Need to differentiate some cases again.
|
-- Need to differentiate some cases again.
|
||||||
if spawnonship or spawnonfarp or spawnonrunway then
|
if (spawnonship or spawnonfarp or spawnonrunway) and not useexplicitspots then
|
||||||
|
|
||||||
-- On free spot required in these cases.
|
-- On free spot required in these cases.
|
||||||
if nfree >= 1 then
|
if nfree >= 1 then
|
||||||
|
|||||||
Reference in New Issue
Block a user