This commit is contained in:
Frank
2020-01-22 22:53:22 +01:00
parent fe7df16ac0
commit 37d2602f2d
2 changed files with 57 additions and 35 deletions
+43 -33
View File
@@ -314,11 +314,29 @@ function FLIGHTCONTROL:onafterStatus()
-- Get free parking spots.
--local nfree=self:_GetFreeParkingSpots()
local nfree=self.Nparkingspots
local Nflights= #self.flights
local NQparking=#self.Qparking
local NQtaxiout=#self.Qtaxiout
local NQreadyto=#self.Qreadyto
local NQtakeoff=#self.Qtakeoff
--local NQtravel2=#self.Qtravel2
local NQwaiting=#self.Qwaiting
local NQlanding=#self.Qlanding
local NQtaxiinb=#self.Qtaxiinb
local NQarrived=#self.Qarrived
local Nqueues=NQparking+NQtaxiout+NQreadyto+NQtakeoff+NQwaiting+NQlanding+NQtaxiinb+NQarrived
-- Info text.
local text=string.format("State %s - Runway %s - Parking %d/%d - Flights=%s: Qpark=%d Qtakeoff=%d Qland=%d Qhold=%d",
self:GetState(), runway.idx, nfree, self.Nparkingspots, #self.flights, #self.Qparking, #self.Qtakeoff, #self.Qlanding, #self.Qwaiting)
local text=string.format("State %s - Runway %s - Parking %d/%d - Flights=%s: Qpark=%d Qtxout=%d Qready=%d Qto=%d | Qhold=%d Qland=%d Qtxinb=%d Qarr=%d",
self:GetState(), runway.idx, nfree, self.Nparkingspots, #self.flights, #self.Qparking, #self.Qtaxiout, #self.Qreadyto, #self.Qtakeoff, #self.Qwaiting, #self.Qlanding, #self.Qtaxiinb, #self.Qarrived)
self:I(self.lid..text)
if Nflights==Nqueues then
--Check!
else
self:I(string.format("Warning: Number of total flights != number of flights in queue: Ntot=%d, Nqueues=%d", Nflights, Nqueues))
end
-- Next status update in ~30 seconds.
self:__Status(-20)
@@ -872,12 +890,12 @@ end
function FLIGHTCONTROL:_AddFlightToReady4TakoffQueue(flight)
-- Check if already in queue.
if self:_InQueue(self.Qtaxiout, flight.group) then
if self:_InQueue(self.Qreadyto, flight.group) then
return false
end
-- Add flight to table.
table.insert(self.Qtaxiout, flight)
table.insert(self.Qreadyto, flight)
return true
end
@@ -1261,13 +1279,19 @@ function FLIGHTCONTROL:_PlayerRequestTaxi(groupname)
if flight then
local runway=self:GetActiveRunwayText()
MESSAGE:New(string.format("You are cleared to taxi to runway %s", runway), 5):ToAll()
if flight:IsParking() then
for _,_element in pairs(flight.elements) do
local element=_element --Ops.FlightGroup#FLIGHTGROUP.Element
flight:ElementTaxiing(element)
local runway=self:GetActiveRunwayText()
MESSAGE:New(string.format("You are cleared to taxi to runway %s", runway), 5):ToAll()
for _,_element in pairs(flight.elements) do
local element=_element --Ops.FlightGroup#FLIGHTGROUP.Element
flight:ElementTaxiing(element)
end
else
MESSAGE:New(string.format("Negative, you must be PARKING to request TAXI!"), 5):ToAll()
end
else
@@ -1286,6 +1310,7 @@ function FLIGHTCONTROL:_PlayerRequestTakeoff(groupname)
local flight=_DATABASE:GetFlightGroup(groupname)
if flight then
if flight:IsTaxiing() then
if #self.Qlanding==0 and self.Qtakeoff==0 then
@@ -1293,16 +1318,16 @@ function FLIGHTCONTROL:_PlayerRequestTakeoff(groupname)
self:_AddFlightToTakeoffQueue(flight)
elseif #self.Qlanding>0 then
MESSAGE:New("Negative ghostrider, other flights are currently landing. Talk to you soon.", 5):ToAll()
self:_AddFlightToTakeoffQueue(flight)
self:_AddFlightToReady4TakoffQueue(flight)
elseif #self.Qtakeoff>0 then
MESSAGE:New("Negative ghostrider, other flights are ahead of you.", 5):ToAll()
MESSAGE:New("Negative ghostrider, other flights are ahead of you. Talk to you soon.", 5):ToAll()
self:_AddFlightToReady4TakoffQueue(flight)
end
else
MESSAGE:New(string.format("You must request TAXI before you can request TAKEOFF!"), 5):ToAll()
MESSAGE:New(string.format("Negative, you must request TAXI before you can request TAKEOFF!"), 5):ToAll()
end
end
@@ -1353,8 +1378,12 @@ function FLIGHTCONTROL:_RemoveFlight(flight)
self:_RemoveFlightFromQueue(self.Qwaiting, flight, "holding")
self:_RemoveFlightFromQueue(self.Qlanding, flight, "landing")
self:_RemoveFlightFromQueue(self.Qtaxiinb, flight, "taxiINB")
self:_RemoveFlightFromQueue(self.Qparking, flight, "parking")
self:_RemoveFlightFromQueue(self.Qtaxiout, flight, "taxiOUT")
self:_RemoveFlightFromQueue(self.Qreadyto, flight, "readyTO")
self:_RemoveFlightFromQueue(self.Qtakeoff, flight, "takeoff")
self:_RemoveFlightFromQueue(self.Qarrived, flight, "arrived")
self:_RemoveFlightFromQueue(self.flights, flight, "flights")
end
@@ -1552,25 +1581,6 @@ function FLIGHTCONTROL:_CheckACstatus(unitset)
end
--- Command AI flight to orbit.
-- @param #FLIGHTCONTROL self
-- @param Ops.FlightGroup#FLIGHTGROUP flight Flight group.
-- @param #number stack Holding stack.
-- @param #boolean respawn If true respawn the group. Otherwise reset the mission task with new waypoints.
function FLIGHTCONTROL:_WaitAI(flight, stack, respawn)
-- Set flag to something other than -100 and <0
flight.flag=stack
-- Holding point.
local holding=self:_GetHoldingpoint(flight)
local altitude=holding.pos0.y
local angels=UTILS.MetersToFeet(altitude)/1000
flight:Hold(self.airbase, holding.pos0)
end
--- Tell AI to land at the airbase. Flight is added to the landing queue.
-- @param #FLIGHTCONTROL self
-- @param Ops.FlightGroup#FLIGHTGROUP flight Flight group.
+14 -2
View File
@@ -1466,9 +1466,11 @@ function FLIGHTGROUP:onafterFlightTaxiing(From, Event, To)
self.flightcontrol:_RemoveFlightFromQueue(self.flightcontrol.Qparking, self, "parking")
-- Add AI flight to takeoff queue.
if self.ai then
if self.ai then
-- AI flights go directly to takeoff as we don't know when they finished taxiing.
self.flightcontrol:_AddFlightToTakeoffQueue(self)
else
-- Human flights go to taxi out queue. They will go to the ready for takeoff queue when they request it.
self.flightcontrol:_AddFlightToTaxiOutQueue(self)
end
@@ -1534,6 +1536,8 @@ function FLIGHTGROUP:onafterFlightLanded(From, Event, To, airbase)
-- Remove flight from landing queue.
if self.flightcontrol and airbase and self.flightcontrol.airbasename==airbase:GetName() then
self.flightcontrol:_RemoveFlightFromQueue(self.flightcontrol.Qlanding, self, "landing")
-- TODO: add flight to taxiinb queue.
--self.flightcontrol:_Add
end
end
@@ -1544,6 +1548,14 @@ end
-- @param #string To To state.
function FLIGHTGROUP:onafterFlightArrived(From, Event, To)
self:T(self.sid..string.format("Flight arrived %s", self.groupname))
-- Remove flight from landing queue.
if self.flightcontrol then
self.flightcontrol:_RemoveFlightFromQueue(self.flightcontrol.Qtaxiinb, self, "taxiINB")
-- TODO: add flight to arrived queue
--self.flightcontrol:_AddFl
end
end
--- On after "FlightDead" event.
@@ -1704,7 +1716,7 @@ function FLIGHTGROUP:onafterPassingWaypoint(From, Event, To, n, N)
if self.destination and n>1 and n==N-1 then
--self:__Hold(1, self.destination)
self:__Hold(1, self.destination)
end
end