From 4618e810391f4d55029cd98b448750ea10dd3026 Mon Sep 17 00:00:00 2001 From: funkyfranky Date: Mon, 30 Oct 2017 12:37:13 +0100 Subject: [PATCH] RAT bug fix Holding and final waypoint fixed when aircraft chang the flightplan. --- Moose Development/Moose/Functional/RAT.lua | 25 ++++++++++++---------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/Moose Development/Moose/Functional/RAT.lua b/Moose Development/Moose/Functional/RAT.lua index f375c903e..ab553a06f 100644 --- a/Moose Development/Moose/Functional/RAT.lua +++ b/Moose Development/Moose/Functional/RAT.lua @@ -129,8 +129,6 @@ -- @field #string skill Skill of AI. -- @field #boolean ATCswitch Enable/disable ATC if set to true/false. -- @field #string parking_id String with a special parking ID for the aircraft. --- @field #number wp_final Index of the final waypoint. --- @field #number wp_holding Index of the holding waypoint. -- @field #boolean radio If true/false disables radio messages from the RAT groups. -- @field #number frequency Radio frequency used by the RAT groups. -- @field #string modulation Ratio modulation. Either "FM" or "AM". @@ -350,8 +348,6 @@ RAT={ skill="High", -- Skill of AI. ATCswitch=true, -- Enable ATC. parking_id=nil, -- Specific parking ID when aircraft are spawned at airports. - wp_final=nil, -- Index of the final waypoint. - wp_holding=nil, -- Index of the holding waypoint. radio=nil, -- If true/false disables radio messages from the RAT groups. frequency=nil, -- Radio frequency used by the RAT groups. modulation=nil, -- Ratio modulation. Either "FM" or "AM". @@ -1470,7 +1466,7 @@ function RAT:_SpawnWithRoute(_departure, _destination, _takeoff, _landing, _live end -- Set flight plan. - local departure, destination, waypoints = self:_SetRoute(takeoff, landing, _departure, _destination, _waypoint) + local departure, destination, waypoints, WPholding, WPfinal = self:_SetRoute(takeoff, landing, _departure, _destination, _waypoint) -- Return nil if we could not find a departure destination or waypoints if not (departure and destination and waypoints) then @@ -1554,6 +1550,8 @@ function RAT:_SpawnWithRoute(_departure, _destination, _takeoff, _landing, _live -- Each aircraft gets its own takeoff type. self.ratcraft[self.SpawnIndex].takeoff=takeoff self.ratcraft[self.SpawnIndex].landing=landing + self.ratcraft[self.SpawnIndex].wpholding=WPholding + self.ratcraft[self.SpawnIndex].wpfinal=WPfinal -- Livery self.ratcraft[self.SpawnIndex].livery=livery @@ -2202,6 +2200,8 @@ function RAT:_SetRoute(takeoff, landing, _departure, _destination, _waypoint) -- Waypoints and coordinates local wp={} local c={} + local wpholding=nil + local wpfinal=nil -- Departure/Take-off c[#c+1]=Pdeparture @@ -2299,7 +2299,7 @@ function RAT:_SetRoute(takeoff, landing, _departure, _destination, _waypoint) wp[#wp+1]=self:_Waypoint(#wp+1, RAT.wp.holding, c[#wp+1], VxHolding, H_holding+h_holding) self.waypointdescriptions[#wp]="Holding Point" self.waypointstatus[#wp]=RAT.status.Holding - self.wp_holding=#wp + wpholding=#wp -- Final destination. c[#c+1]=Pdestination @@ -2310,7 +2310,7 @@ function RAT:_SetRoute(takeoff, landing, _departure, _destination, _waypoint) end -- Final Waypoint - self.wp_final=#wp + wpfinal=#wp -- Fill table with waypoints. local waypoints={} @@ -2324,9 +2324,9 @@ function RAT:_SetRoute(takeoff, landing, _departure, _destination, _waypoint) -- Return departure, destination and waypoints. if self.returnzone then -- We return the actual zone here because returning the departure leads to problems with commute. - return departure, destination_returnzone, waypoints + return departure, destination_returnzone, waypoints, wpholding, wpfinal else - return departure, destination, waypoints + return departure, destination, waypoints, wpholding, wpfinal end end @@ -3477,6 +3477,9 @@ function RAT._WaypointFunction(group, rat, wp) local departure=rat.ratcraft[sdx].departure:GetName() local destination=rat.ratcraft[sdx].destination:GetName() local landing=rat.ratcraft[sdx].landing + local WPholding=rat.ratcraft[sdx].wpholding + local WPfinal=rat.ratcraft[sdx].wpfinal + -- For messages local text @@ -3491,7 +3494,7 @@ function RAT._WaypointFunction(group, rat, wp) --rat.ratcraft[sdx].status=status rat:_SetStatus(group, status) - if wp==rat.wp_holding then + if wp==WPholding then -- Aircraft arrived at holding point text=string.format("Flight %s to %s ATC: Holding and awaiting landing clearance.", group:GetName(), destination) @@ -3504,7 +3507,7 @@ function RAT._WaypointFunction(group, rat, wp) end end - if wp==rat.wp_final then + if wp==WPfinal then text=string.format("Flight %s arrived at final destination %s.", group:GetName(), destination) MESSAGE:New(text, 10):ToAllIf(rat.reportstatus) env.info(RAT.id..text)