From aff1d3c7db751f8bdfe362649c5960ff2655bbf2 Mon Sep 17 00:00:00 2001 From: leka1986 <83298840+leka1986@users.noreply.github.com> Date: Sun, 19 Apr 2026 20:35:20 +0200 Subject: [PATCH] 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. --- Moose Development/Moose/Core/Spawn.lua | 100 +++++++++++++++++++------ 1 file changed, 79 insertions(+), 21 deletions(-) diff --git a/Moose Development/Moose/Core/Spawn.lua b/Moose Development/Moose/Core/Spawn.lua index 02c0cf478..a7f0dff23 100644 --- a/Moose Development/Moose/Core/Spawn.lua +++ b/Moose Development/Moose/Core/Spawn.lua @@ -2178,15 +2178,43 @@ function SPAWN:SpawnAtAirbase( SpawnAirbase, Takeoff, TakeoffAltitude, TerminalT local scanscenery = 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. - 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. nfree = SpawnAirbase:GetFreeParkingSpotsNumber( 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 if ishelo then if termtype == nil then @@ -2238,7 +2266,7 @@ function SPAWN:SpawnAtAirbase( SpawnAirbase, Takeoff, TakeoffAltitude, TerminalT local _notenough = false -- Need to differentiate some cases again. - if autoparking then + if autoparking and not useexplicitspots then -- On free spot required in these cases. if nfree >= 1 then @@ -2582,21 +2610,51 @@ function SPAWN:ParkAircraft( SpawnAirbase, TerminalType, Parkingdata, SpawnIndex local scanscenery = false local verysafe = false - -- Number of free parking spots at the airbase. - if 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 ) - --[[ - elseif Parkingdata~=nil then - -- Parking data explicitly set by user as input parameter. - nfree=#Parkingdata - spots=Parkingdata - ]] - else - if ishelo then + -- Use exact parking data when provided, otherwise let helicopters on 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. + if Parkingdata~=nil then + -- Parking data explicitly set by user as input parameter. + nfree = #Parkingdata + spots = Parkingdata + useexplicitspots = true + elseif spawnonfarp and ishelo 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. --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 ) @@ -2659,7 +2717,7 @@ function SPAWN:ParkAircraft( SpawnAirbase, TerminalType, Parkingdata, SpawnIndex local _notenough = false -- 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. if nfree >= 1 then