diff --git a/Moose Development/Moose/Ops/FlightControl.lua b/Moose Development/Moose/Ops/FlightControl.lua index 7ae1c2650..9cfedacba 100644 --- a/Moose Development/Moose/Ops/FlightControl.lua +++ b/Moose Development/Moose/Ops/FlightControl.lua @@ -290,12 +290,13 @@ end -- @param Core.Event#EVENTDATA EventData function FLIGHTCONTROL:OnEventBirth(EventData) self:F3({EvendData=EventData}) - - self:I(self.lid..string.format("BIRTH: unit = %s", tostring(EventData.IniUnitName))) - self:I(self.lid..string.format("BIRTH: group = %s", tostring(EventData.IniGroupName))) - + if EventData and EventData.IniGroupName and EventData.Place and EventData.Place:GetName()==self.airbasename then + self:I(self.lid..string.format("BIRTH: unit = %s", tostring(EventData.IniUnitName))) + self:I(self.lid..string.format("BIRTH: group = %s", tostring(EventData.IniGroupName))) + + -- We delay this, to have all elements of the group in the game. self:ScheduleOnce(0.1, self._CreateFlightGroup, self, EventData.IniGroup) @@ -395,7 +396,7 @@ end function FLIGHTCONTROL:_CheckQueues() -- Print queues - --self:_PrintQueue(self.flights, "All flights") + self:_PrintQueue(self.flights, "All flights") self:_PrintQueue(self.Qparking, "Parking") self:_PrintQueue(self.Qtakeoff, "Takeoff") self:_PrintQueue(self.Qwaiting, "Holding") @@ -413,14 +414,22 @@ function FLIGHTCONTROL:_CheckQueues() -- Number of parking groups. local nparking=#self.Qparking + -- Get next flight in line: either holding or parking. local flight, isholding=self:_GetNextFight() + -- Check if somebody wants something. if flight and ntakeoff==0 and nlanding==0 then if isholding then + -------------------- + -- Holding flight -- + -------------------- + + -- Get free parking spots. local n,parking=self:_GetFreeParkingSpots() + -- Get number of alive elements. local Ne=self:GetNelements() @@ -437,6 +446,10 @@ function FLIGHTCONTROL:_CheckQueues() end else + + -------------------- + -- Takeoff flight -- + -------------------- -- Check if flight is AI. Humans have to request taxi via F10 menu. if flight.ai then @@ -1401,6 +1414,8 @@ function FLIGHTCONTROL:_LandAI(flight, parking) -- Waypoints. local wp={} + + -- Current pos. wp[#wp+1]=self.group:GetCoordinate():WaypointAir(nil, COORDINATE.WaypointType.TurningPoint, COORDINATE.WaypointAction.FlyoverPoint, UTILS.KnotsToKmph(SpeedTo), true , nil, {}, "Current Pos") -- Approach point: 10 NN in direction of runway. diff --git a/Moose Development/Moose/Ops/FlightGroup.lua b/Moose Development/Moose/Ops/FlightGroup.lua index 554fabe61..b32536aa7 100644 --- a/Moose Development/Moose/Ops/FlightGroup.lua +++ b/Moose Development/Moose/Ops/FlightGroup.lua @@ -1525,13 +1525,6 @@ function FLIGHTGROUP:onafterHold(From, Event, To, airbase, SpeedTo, SpeedHold, S local p1=nil local wpap=nil - -- Altitude above ground for a glide slope of 3�. - local alpha=math.rad(3) - local x1=UTILS.NMToMeters(10) - local x2=UTILS.NMToMeters(5) - local h1=x1*math.tan(alpha) - local h2=x2*math.tan(alpha) - -- Do we have a flight control? local fc=_DATABASE:GetFlightControl(airbase:GetName()) if fc then @@ -1579,27 +1572,6 @@ function FLIGHTGROUP:onafterHold(From, Event, To, airbase, SpeedTo, SpeedHold, S -- Set route points. Template.route.points=wp - if fc then - local n,parking=fc:_GetFreeParkingSpots() - -- Get number of alive elements. - local Ne=self:GetNelements() - - if n>=Ne then - for i,unit in pairs(Template.units) do - local spot=parking[i] --Ops.FlightControl#FLIGHTCONTROL.ParkingSpot - spot.reserved=unit.name - unit.parking_landing=spot.TerminalID - local text=string.format("FF Reserving parking spot %d for unit %s", spot.TerminalID, tostring(unit.name)) - env.info(text) - end - --[[ - for _,_spot in pairs(parking) do - local spot=_spot --Ops.FlightControl#FLIGHTCONTROL.ParkingSpot - end - ]] - end - end - MESSAGE:New("Respawning group"):ToAll() --Respawn the group.