From e9fe11e9b3550bac534db5015bba7dab62c2316c Mon Sep 17 00:00:00 2001 From: 132nd-etcher <132nd-etcher@users.noreply.github.com> Date: Wed, 22 Nov 2017 09:07:18 +0100 Subject: [PATCH] RAT Trace Use BASE tracing methods in RAT --- Moose Development/Moose/Functional/RAT.lua | 217 +++++++++++---------- 1 file changed, 109 insertions(+), 108 deletions(-) diff --git a/Moose Development/Moose/Functional/RAT.lua b/Moose Development/Moose/Functional/RAT.lua index ab553a06f..f30d89ece 100644 --- a/Moose Development/Moose/Functional/RAT.lua +++ b/Moose Development/Moose/Functional/RAT.lua @@ -514,17 +514,17 @@ RAT.version="2.0.1" -- @usage yak2:RAT("RAT_YAK", "Yak2") will create a RAT object "yak2". The template group in the mission editor must have the name "RAT_YAK" but the group will be called "Yak2" in e.g. the F10 menu. function RAT:New(groupname, alias) + -- Inherit SPAWN class. + local self=BASE:Inherit(self, SPAWN:NewWithAlias(groupname, alias)) -- #RAT + -- Version info. - env.info(RAT.id.."Version "..RAT.version) + self:F(RAT.id.."Version "..RAT.version) -- Welcome message. - env.info(RAT.id.."Creating new RAT object from template: "..groupname) + self:F(RAT.id.."Creating new RAT object from template: "..groupname) -- Set alias. alias=alias or groupname - - -- Inherit SPAWN class. - local self=BASE:Inherit(self, SPAWN:NewWithAlias(groupname, alias)) -- #RAT -- Alias of groupname. self.alias=alias @@ -534,7 +534,7 @@ function RAT:New(groupname, alias) -- Check the group actually exists. if DCSgroup==nil then - env.error(RAT.id.."Group with name "..groupname.." does not exist in the mission editor!") + self:E(RAT.id.."ERROR: Group with name "..groupname.." does not exist in the mission editor!") return nil end @@ -563,7 +563,7 @@ function RAT:Spawn(naircraft) -- Make sure that this function is only been called once per RAT object. if self.spawninitialized==true then - env.error("Spawn function should only be called once per RAT object! Exiting and returning nil.") + self:E("ERROR: Spawn function should only be called once per RAT object! Exiting and returning nil.") return nil else self.spawninitialized=true @@ -685,7 +685,7 @@ function RAT:Spawn(naircraft) end end text=text..string.format("******************************************************\n") - env.info(RAT.id..text) + self:T(RAT.id..text) -- Create submenus. if self.f10menu then @@ -743,13 +743,13 @@ function RAT:_CheckConsistency() -- Only zones but not takeoff air == > Enable takeoff air. if self.Ndeparture_Zones>0 and self.takeoff~=RAT.wp.air then self.takeoff=RAT.wp.air - env.error(RAT.id.."At least one zone defined as departure and takeoff is NOT set to air. Enabling air start!") + self:E(RAT.id.."ERROR: At least one zone defined as departure and takeoff is NOT set to air. Enabling air start!") end -- No airport and no zone specified. if self.Ndeparture_Airports==0 and self.Ndeparture_Zone==0 then self.random_departure=true local text="No airports or zones found given in SetDeparture(). Enabling random departure airports!" - env.error(RAT.id..text) + self:E(RAT.id.."ERROR: "..text) MESSAGE:New(text, 30):ToAll() end end @@ -771,20 +771,20 @@ function RAT:_CheckConsistency() if self.Ndestination_Zones>0 and self.landing~=RAT.wp.air and not self.returnzone then self.landing=RAT.wp.air self.destinationzone=true - env.error(RAT.id.."At least one zone defined as destination and landing is NOT set to air. Enabling destination zone!") + self:E(RAT.id.."ERROR: At least one zone defined as destination and landing is NOT set to air. Enabling destination zone!") end -- No specified airport and no zone found at all. if self.Ndestination_Airports==0 and self.Ndestination_Zones==0 then self.random_destination=true local text="No airports or zones found given in SetDestination(). Enabling random destination airports!" - env.error(RAT.id..text) + self:E(RAT.id.."ERROR: "..text) MESSAGE:New(text, 30):ToAll() end end -- Destination zone and return zone should not be used together. if self.destinationzone and self.returnzone then - env.error(RAT.id.."Destination zone _and_ return to zone not possible! Disabling return to zone.") + self:E(RAT.id.."ERROR: Destination zone _and_ return to zone not possible! Disabling return to zone.") self.returnzone=false end -- If returning to a zone, we set the landing type to "air" if takeoff is in air. @@ -920,7 +920,7 @@ function RAT:SetDeparture(departurenames) names={departurenames} else -- error message - env.error(RAT.id.."Input parameter must be a string or a table in SetDeparture()!") + self:E(RAT.id.."ERROR: Input parameter must be a string or a table in SetDeparture()!") end -- Put names into arrays. @@ -933,7 +933,7 @@ function RAT:SetDeparture(departurenames) -- If it is not an airport, we assume it is a zone. table.insert(self.departure_ports, name) else - env.error(RAT.id.."ERROR! No departure airport or zone found with name "..name) + self:E(RAT.id.."ERROR: No departure airport or zone found with name "..name) end end @@ -957,7 +957,7 @@ function RAT:SetDestination(destinationnames) names={destinationnames} else -- Error message. - env.error(RAT.id.."Input parameter must be a string or a table in SetDestination()!") + self:E(RAT.id.."ERROR: Input parameter must be a string or a table in SetDestination()!") end -- Put names into arrays. @@ -970,7 +970,7 @@ function RAT:SetDestination(destinationnames) -- If it is not an airport, we assume it is a zone. table.insert(self.destination_ports, name) else - env.error(RAT.id.."ERROR! No destination airport or zone found with name "..name) + self:E(RAT.id.."ERROR: No destination airport or zone found with name "..name) end end @@ -1134,7 +1134,7 @@ end -- @param #string id Parking ID of the aircraft. function RAT:SetParkingID(id) self.parking_id=id - env.info(RAT.id.."Setting parking ID to "..self.parking_id) + self:T(RAT.id.."Setting parking ID to "..self.parking_id) end --- Enable Radio. Overrules the ME setting. @@ -1392,7 +1392,7 @@ function RAT:_InitAircraft(DCSgroup) self.category=RAT.cat.heli else self.category="other" - env.error(RAT.id.."Group of RAT is neither airplane nor helicopter!") + self:E(RAT.id.."ERROR: Group of RAT is neither airplane nor helicopter!") end -- Get type of aircraft. @@ -1430,7 +1430,7 @@ function RAT:_InitAircraft(DCSgroup) text=text..string.format("Eff range = %6.1f km (with 95 percent initial fuel amount)\n", self.aircraft.Reff/1000) text=text..string.format("Ceiling = %6.1f km = FL%3.0f\n", self.aircraft.ceiling/1000, self.aircraft.ceiling/RAT.unit.FL2m) text=text..string.format("******************************************************\n") - env.info(RAT.id..text) + self:T(RAT.id..text) end @@ -1482,7 +1482,7 @@ function RAT:_SpawnWithRoute(_departure, _destination, _takeoff, _landing, _live -- Choose random livery. livery=self.livery[math.random(#self.livery)] local text=string.format("Chosen livery for group %s: %s", self:_AnticipatedGroupName(), livery) - env.info(RAT.id..text) + self:T(RAT.id..text) else livery=nil end @@ -1592,7 +1592,7 @@ end function RAT:ClearForLanding(name) trigger.action.setUserFlag(name, 1) local flagvalue=trigger.misc.getUserFlag(name) - env.info(RAT.id.."ATC: User flag value (landing) for "..name.." set to "..flagvalue) + self:T(RAT.id.."ATC: User flag value (landing) for "..name.." set to "..flagvalue) end --- Respawn a group. @@ -1711,8 +1711,10 @@ function RAT:_Respawn(group) end if self.debug then - env.info(RAT.id..string.format("self.takeoff, takeoff, _takeoff = %s, %s, %s", tostring(self.takeoff), tostring(takeoff), tostring(_takeoff))) - env.info(RAT.id..string.format("self.landing, landing, _landing = %s, %s, %s", tostring(self.landing), tostring(landing), tostring(_landing))) + local text + text=string.format("self.takeoff, takeoff, _takeoff = %s, %s, %s", tostring(self.takeoff), tostring(takeoff), tostring(_takeoff)) + text=text.."\n"..string.format("self.landing, landing, _landing = %s, %s, %s", tostring(self.landing), tostring(landing), tostring(_landing)) + self:T(RAT.id..text) end -- Spawn new group. @@ -1795,7 +1797,7 @@ function RAT:_SetRoute(takeoff, landing, _departure, _destination, _waypoint) departure=ZONE:New(_departure) else local text=string.format("ERROR: Specified departure airport %s does not exist for %s!", _departure, self.alias) - env.error(RAT.id..text) + self:E(RAT.id.."ERROR: "..text) end else @@ -1806,7 +1808,7 @@ function RAT:_SetRoute(takeoff, landing, _departure, _destination, _waypoint) if not departure then local text=string.format("No valid departure airport could be found for %s.", self.alias) MESSAGE:New(text, 60):ToAll() - env.error(RAT.id..text) + self:E(RAT.id.."ERROR: "..text) return nil end @@ -1873,7 +1875,7 @@ function RAT:_SetRoute(takeoff, landing, _departure, _destination, _waypoint) mindist=math.max(self.mindist, mindist) local text=string.format("Adjusting min distance to %d km (for given min FL%03d)", mindist/1000, self.FLminuser/RAT.unit.FL2m) - env.info(RAT.id..text) + self:T(RAT.id..text) end -- DESTINATION AIRPORT @@ -1891,7 +1893,7 @@ function RAT:_SetRoute(takeoff, landing, _departure, _destination, _waypoint) destination=ZONE:New(_destination) else local text=string.format("ERROR: Specified destination airport/zone %s does not exist for %s!", _destination, self.alias) - env.error(RAT.id..text) + self:E(RAT.id.."ERROR: "..text) end else @@ -1920,7 +1922,7 @@ function RAT:_SetRoute(takeoff, landing, _departure, _destination, _waypoint) if not destination then local text=string.format("No valid destination airport could be found for %s!", self.alias) MESSAGE:New(text, 60):ToAll() - env.error(RAT.id..text) + self:E(RAT.id.."ERROR: "..text) return nil end @@ -1928,7 +1930,7 @@ function RAT:_SetRoute(takeoff, landing, _departure, _destination, _waypoint) if destination:GetName()==departure:GetName() then local text=string.format("%s: Destination and departure are identical. Airport/zone %s.", self.alias, destination:GetName()) MESSAGE:New(text, 30):ToAll() - env.error(RAT.id..text) + self:E(RAT.id.."ERROR: "..text) end -- Get a random point inside zone return zone. @@ -2190,7 +2192,7 @@ function RAT:_SetRoute(takeoff, landing, _departure, _destination, _waypoint) text=text..string.format("h_descent_max = %6.1f m\n", h_descent_max) end text=text..string.format("******************************************************\n") - env.info(RAT.id..text) + self:T(RAT.id..text) -- Ensure that cruise distance is positve. Can be slightly negative in special cases. And we don't want to turn back. if d_cruise<0 then @@ -2376,10 +2378,10 @@ function RAT:_PickDeparture(takeoff) if takeoff==RAT.wp.air then dep=ZONE:New(name) else - env.error(RAT.id.."Takeoff is not in air. Cannot use "..name.." as departure!") + self:E(RAT.id.."ERROR: Takeoff is not in air. Cannot use "..name.." as departure!") end else - env.error(RAT.id.."No airport or zone found with name "..name) + self:E(RAT.id.."ERROR: No airport or zone found with name "..name) end -- Add to departures table. @@ -2392,7 +2394,7 @@ function RAT:_PickDeparture(takeoff) end -- Info message. - env.info(RAT.id.."Number of possible departures = "..#departures) + self:T(RAT.id.."Number of possible departures = "..#departures) -- Select departure airport or zone. local departure=departures[math.random(#departures)] @@ -2404,12 +2406,12 @@ function RAT:_PickDeparture(takeoff) else text="Chosen departure airport: "..departure:GetName().." (ID "..departure:GetID()..")" end - env.info(RAT.id..text) + self:T(RAT.id..text) if self.debug then MESSAGE:New(text, 30):ToAll() end else - env.error(RAT.id.."No departure airport or zone found.") + self:E(RAT.id.."ERROR: No departure airport or zone found.") departure=nil end @@ -2474,10 +2476,10 @@ function RAT:_PickDestination(departure, q, minrange, maxrange, random, landing) if landing==RAT.wp.air then dest=ZONE:New(name) else - env.error(RAT.id.."Landing is not in air. Cannot use zone "..name.." as destination!") + self:E(RAT.id.."ERROR: Landing is not in air. Cannot use zone "..name.." as destination!") end else - env.error(RAT.id.."No airport or zone found with name "..name) + self:E(RAT.id.."ERROR: No airport or zone found with name "..name) end if dest then @@ -2489,7 +2491,7 @@ function RAT:_PickDestination(departure, q, minrange, maxrange, random, landing) table.insert(destinations, dest) else local text=string.format("Destination %s is ouside range. Distance = %5.1f km, min = %5.1f km, max = %5.1f km.", name, distance, minrange, maxrange) - env.info(RAT.id..text) + self:T(RAT.id..text) end end @@ -2498,7 +2500,7 @@ function RAT:_PickDestination(departure, q, minrange, maxrange, random, landing) end -- Info message. - env.info(RAT.id.."Number of possible destinations = "..#destinations) + self:T(RAT.id.."Number of possible destinations = "..#destinations) if #destinations > 0 then --- Compare distance of destination airports. @@ -2530,13 +2532,13 @@ function RAT:_PickDestination(departure, q, minrange, maxrange, random, landing) else text=string.format("Chosen destination airport: %s (ID %d).", destination:GetName(), destination:GetID()) end - env.info(RAT.id..text) + self:T(RAT.id..text) if self.debug then MESSAGE:New(text, 30):ToAll() end else - env.error(RAT.id.."No destination airport or zone found.") + self:E(RAT.id.."ERROR: No destination airport or zone found.") destination=nil end @@ -2624,8 +2626,8 @@ function RAT:_GetAirportsOfMap() if self.debug then local text1="MOOSE: Airport ID = ".._myab:GetID().." and Name = ".._myab:GetName()..", Category = ".._myab:GetCategory()..", TypeName = ".._myab:GetTypeName() --local text2="DCS : Airport ID = "..airbase:getID().." and Name = "..airbase:getName()..", Category = "..airbase:getCategory()..", TypeName = "..airbase:getTypeName() - env.info(RAT.id..text1) - --env.info(RAT.id..text2) + self:T(RAT.id..text1) + --self:T(RAT.id..text2) end end @@ -2653,7 +2655,7 @@ function RAT:_GetAirportsOfCoalition() if #self.airports==0 then local text="No possible departure/destination airports found!" MESSAGE:New(text, 60):ToAll() - env.error(RAT.id..text) + self:E(RAT.id.."ERROR: "..text) end end @@ -2784,7 +2786,7 @@ function RAT:Status(message, forID) text=text..string.format("Position change = %8.1f m since %3.0f seconds.", Dg, dTlast) end if self.debug then - env.info(RAT.id..text) + self:T(RAT.id..text) end if message then MESSAGE:New(text, 20):ToAll() @@ -2797,7 +2799,7 @@ function RAT:Status(message, forID) -- Despawn unit if it did not move more then 50 m in the last 180 seconds. if stationary then local text=string.format("Group %s is despawned after being %4.0f seconds inaktive on ground.", self.alias, dTlast) - env.info(RAT.id..text) + self:T(RAT.id..text) self:_Despawn(group) end -- Despawn group if life is < 10% and distance travelled < 100 m. @@ -2809,7 +2811,7 @@ function RAT:Status(message, forID) if self.ratcraft[i].despawnme then local text=string.format("Flight %s will be despawned NOW!", self.alias) - env.info(RAT.id..text) + self:T(RAT.id..text) -- Despawn old group. self:_Respawn(self.ratcraft[i].group) self:_Despawn(self.ratcraft[i].group) @@ -2818,14 +2820,14 @@ function RAT:Status(message, forID) else if self.debug then local text=string.format("Group %i does not exist.", i) - env.info(RAT.id..text) + self:T(RAT.id..text) end end end if (message and not forID) then local text=string.format("Alive groups of %s: %d", self.alias, self.alive) - env.info(RAT.id..text) + self:T(RAT.id..text) MESSAGE:New(text, 20):ToAll() end @@ -2843,12 +2845,12 @@ function RAT:_GetLife(group) life=unit:GetLife()/unit:GetLife0()*100 else if self.debug then - env.error(RAT.id.."Unit does not exist in RAT_Getlife(). Returning zero.") + self:E(RAT.id.."ERROR: Unit does not exist in RAT_Getlife(). Returning zero.") end end else if self.debug then - env.error(RAT.id.."Group does not exist in RAT_Getlife(). Returning zero.") + self:E(RAT.id.."ERROR: Group does not exist in RAT_Getlife(). Returning zero.") end end return life @@ -2870,7 +2872,7 @@ function RAT:_SetStatus(group, status) local no3 = status==RAT.status.Holding local text=string.format("Flight %s: %s.", group:GetName(), status) - env.info(RAT.id..text) + self:T(RAT.id..text) if (not (no1 or no2 or no3)) then MESSAGE:New(text, 10):ToAllIf(self.reportstatus) @@ -2897,7 +2899,7 @@ function RAT:_OnBirth(EventData) if EventPrefix == self.alias then local text="Event: Group "..SpawnGroup:GetName().." was born." - env.info(RAT.id..text) + self:T(RAT.id..text) -- Set status. local status @@ -2914,7 +2916,7 @@ function RAT:_OnBirth(EventData) end else if self.debug then - env.error("Group does not exist in RAT:_OnBirthDay().") + self:E(RAT.id.."ERROR: Group does not exist in RAT:_OnBirthDay().") end end end @@ -2936,7 +2938,7 @@ function RAT:_EngineStartup(EventData) if EventPrefix == self.alias then local text="Event: Group "..SpawnGroup:GetName().." started engines." - env.info(RAT.id..text) + self:T(RAT.id..text) -- Set status. local status @@ -2953,7 +2955,7 @@ function RAT:_EngineStartup(EventData) else if self.debug then - env.error("Group does not exist in RAT:_EngineStartup().") + self:E(RAT.id.."ERROR: Group does not exist in RAT:_EngineStartup().") end end end @@ -2975,7 +2977,7 @@ function RAT:_OnTakeoff(EventData) if EventPrefix == self.alias then local text="Event: Group "..SpawnGroup:GetName().." is airborne." - env.info(RAT.id..text) + self:T(RAT.id..text) -- Set status. local status=RAT.status.EventTakeoff @@ -2984,7 +2986,7 @@ function RAT:_OnTakeoff(EventData) if self.respawn_after_takeoff then text="Event: Group "..SpawnGroup:GetName().." will be respawned." - env.info(RAT.id..text) + self:T(RAT.id..text) -- Respawn group. self:_Respawn(SpawnGroup) @@ -2995,7 +2997,7 @@ function RAT:_OnTakeoff(EventData) else if self.debug then - env.error("Group does not exist in RAT:_OnTakeoff().") + self:E(RAT.id.."ERROR: Group does not exist in RAT:_OnTakeoff().") end end end @@ -3017,7 +3019,7 @@ function RAT:_OnLand(EventData) if EventPrefix == self.alias then local text="Event: Group "..SpawnGroup:GetName().." landed." - env.info(RAT.id..text) + self:T(RAT.id..text) -- Set status. --self:_SetStatus(SpawnGroup, "Taxiing (after landing)") @@ -3031,7 +3033,7 @@ function RAT:_OnLand(EventData) if self.respawn_at_landing and not self.norespawn then text="Event: Group "..SpawnGroup:GetName().." will be respawned." - env.info(RAT.id..text) + self:T(RAT.id..text) -- Respawn group. self:_Respawn(SpawnGroup) @@ -3042,7 +3044,7 @@ function RAT:_OnLand(EventData) else if self.debug then - env.error("Group does not exist in RAT:_OnLand().") + self:E(RAT.id.."ERROR: Group does not exist in RAT:_OnLand().") end end end @@ -3064,7 +3066,7 @@ function RAT:_OnEngineShutdown(EventData) if EventPrefix == self.alias then local text="Event: Group "..SpawnGroup:GetName().." shut down its engines." - env.info(RAT.id..text) + self:T(RAT.id..text) -- Set status. --self:_SetStatus(SpawnGroup, "Parking (shutting down engines)") @@ -3073,7 +3075,7 @@ function RAT:_OnEngineShutdown(EventData) if not self.respawn_at_landing and not self.norespawn then text="Event: Group "..SpawnGroup:GetName().." will be respawned." - env.info(RAT.id..text) + self:T(RAT.id..text) -- Respawn group. self:_Respawn(SpawnGroup) @@ -3081,7 +3083,7 @@ function RAT:_OnEngineShutdown(EventData) -- Despawn group. text="Event: Group "..SpawnGroup:GetName().." will be destroyed now." - env.info(RAT.id..text) + self:T(RAT.id..text) self:_Despawn(SpawnGroup) end @@ -3089,7 +3091,7 @@ function RAT:_OnEngineShutdown(EventData) else if self.debug then - env.error("Group does not exist in RAT:_OnEngineShutdown().") + self:E(RAT.id.."ERROR: Group does not exist in RAT:_OnEngineShutdown().") end end end @@ -3111,7 +3113,7 @@ function RAT:_OnDead(EventData) if EventPrefix == self.alias then local text="Event: Group "..SpawnGroup:GetName().." died." - env.info(RAT.id..text) + self:T(RAT.id..text) -- Set status. --self:_SetStatus(SpawnGroup, "Destroyed (after dead)") @@ -3123,7 +3125,7 @@ function RAT:_OnDead(EventData) else if self.debug then - env.error("Group does not exist in RAT:_OnDead().") + self:E(RAT.id.."ERROR: Group does not exist in RAT:_OnDead().") end end end @@ -3136,7 +3138,7 @@ function RAT:_OnCrash(EventData) if SpawnGroup then - env.info(string.format("%sGroup %s crashed!", RAT.id, SpawnGroup:GetName())) + self:T(string.format("%sGroup %s crashed!", RAT.id, SpawnGroup:GetName())) -- Get the template name of the group. This can be nil if this was not a spawned group. local EventPrefix = self:_GetPrefixFromGroup(SpawnGroup) @@ -3147,7 +3149,7 @@ function RAT:_OnCrash(EventData) if EventPrefix == self.alias then local text="Event: Group "..SpawnGroup:GetName().." crashed." - env.info(RAT.id..text) + self:T(RAT.id..text) -- Set status. --self:_SetStatus(SpawnGroup, "Crashed") @@ -3163,7 +3165,7 @@ function RAT:_OnCrash(EventData) else if self.debug then - env.error("Group does not exist in RAT:_OnCrash().") + self:E(RAT.id.."ERROR: Group does not exist in RAT:_OnCrash().") end end end @@ -3265,7 +3267,7 @@ function RAT:_Waypoint(index, Type, Coord, Speed, Altitude, Airport) _Action="Turning Point" _alttype="BARO" else - env.error("Unknown waypoint type in RAT:Waypoint() function!") + self:E(RAT.id.."ERROR: Unknown waypoint type in RAT:Waypoint() function!") _Type="Turning Point" _Action="Turning Point" _alttype="RADIO" @@ -3294,7 +3296,7 @@ function RAT:_Waypoint(index, Type, Coord, Speed, Altitude, Airport) end text=text.."******************************************************\n" if self.debug then - env.info(RAT.id..text) + self:T(RAT.id..text) end -- define waypoint @@ -3323,16 +3325,16 @@ function RAT:_Waypoint(index, Type, Coord, Speed, Altitude, Airport) if AirbaseCategory == Airbase.Category.SHIP then RoutePoint.linkUnit = AirbaseID RoutePoint.helipadId = AirbaseID - --env.info(RAT.id.."WP: Ship id = "..AirbaseID) + --self:T(RAT.id.."WP: Ship id = "..AirbaseID) elseif AirbaseCategory == Airbase.Category.HELIPAD then RoutePoint.linkUnit = AirbaseID RoutePoint.helipadId = AirbaseID - --env.info(RAT.id.."WP: Helipad id = "..AirbaseID) + --self:T(RAT.id.."WP: Helipad id = "..AirbaseID) elseif AirbaseCategory == Airbase.Category.AIRDROME then RoutePoint.airdromeId = AirbaseID - --env.info(RAT.id.."WP: Airdrome id = "..AirbaseID) + --self:T(RAT.id.."WP: Airdrome id = "..AirbaseID) else - --env.error(RAT.id.."Unknown Airport categoryin _Waypoint()!") + --self:E(RAT.id.."Unknown Airport categoryin _Waypoint()!") end end -- properties @@ -3401,9 +3403,9 @@ function RAT:_Routeinfo(waypoints, comment) -- send message if self.debug then - --env.info(RAT.id..text) + --self:T(RAT.id..text) end - env.info(RAT.id..text) + self:T(RAT.id..text) -- return total route length in meters return total @@ -3486,7 +3488,7 @@ function RAT._WaypointFunction(group, rat, wp) -- Info on passing waypoint. text=string.format("Flight %s passing waypoint #%d %s.", group:GetName(), wp, rat.waypointdescriptions[wp]) - env.info(RAT.id..text) + self:T(RAT.id..text) -- New status. local status=rat.waypointstatus[wp] @@ -3510,12 +3512,12 @@ function RAT._WaypointFunction(group, rat, wp) 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) + self:T(RAT.id..text) if landing==RAT.wp.air then text=string.format("Activating despawn switch for flight %s! Group will be detroyed soon.", group:GetName()) MESSAGE:New(text, 30):ToAllIf(rat.debug) - env.info(RAT.id..text) + self:T(RAT.id..text) -- Enable despawn switch. Next time the status function is called, the aircraft will be despawned. rat.ratcraft[sdx].despawnme=true end @@ -3551,7 +3553,7 @@ function RAT:_TaskFunction(FunctionString, ... ) DCSTask = self.templategroup:TaskWrappedAction(self.templategroup:CommandDoScript(table.concat(DCSScript))) - --env.info(RAT.id.."Taskfunction:") + --self:T(RAT.id.."Taskfunction:") --self:E( DCSTask ) return DCSTask @@ -3593,7 +3595,7 @@ function RAT:_FLmax(alpha, beta, d, phi, h0) text=text..string.format( "FLmax = FL%3.0f = %6.1f m.\n", h2/RAT.unit.FL2m, h2) text=text..string.format( "FLmax = FL%3.0f = %6.1f m.", h3/RAT.unit.FL2m, h3) if self.debug then - env.info(RAT.id..text) + self:T(RAT.id..text) end return h3+h0 end @@ -3669,7 +3671,7 @@ end -- @param Wrapper.Group#GROUP group Group for which the ROE is set. -- @param #string roe ROE of group. function RAT:_SetROE(group, roe) - env.info(RAT.id.."Setting ROE to "..roe.." for group "..group:GetName()) + self:T(RAT.id.."Setting ROE to "..roe.." for group "..group:GetName()) if self.roe==RAT.ROE.returnfire then group:OptionROEReturnFire() elseif self.roe==RAT.ROE.weaponfree then @@ -3685,7 +3687,7 @@ end -- @param Wrapper.Group#GROUP group Group for which the ROT is set. -- @param #string rot ROT of group. function RAT:_SetROT(group, rot) - env.info(RAT.id.."Setting ROT to "..rot.." for group "..group:GetName()) + self:T(RAT.id.."Setting ROT to "..rot.." for group "..group:GetName()) if self.rot==RAT.ROT.passive then group:OptionROTPassiveDefense() elseif self.rot==RAT.ROT.evade then @@ -3707,7 +3709,7 @@ function RAT:_SetCoalitionTable() elseif self.friendly==RAT.coal.sameonly then self.ctable={self.coalition} else - env.error("Unknown friendly coalition in _SetCoalitionTable(). Defaulting to NEUTRAL.") + self:E(RAT.id.."ERROR: Unknown friendly coalition in _SetCoalitionTable(). Defaulting to NEUTRAL.") self.ctable={self.coalition, coalition.side.NEUTRAL} end end @@ -3784,7 +3786,7 @@ function RAT:_Randomize(value, fac, lower, upper) -- debug info if self.debug then local text=string.format("Random: value = %6.2f, fac = %4.2f, min = %6.2f, max = %6.2f, r = %6.2f", value, fac, min, max, r) - env.info(RAT.id..text) + self:T(RAT.id..text) end return r @@ -3832,7 +3834,7 @@ function RAT:_PlaceMarkers(waypoints, index) self:_SetMarker(self.waypointdescriptions[i], waypoints[i], index) if self.debug then local text=string.format("Marker at waypoint #%d: %s for flight #%d", i, self.waypointdescriptions[i], index) - env.info(RAT.id..text) + self:T(RAT.id..text) end end end @@ -3847,7 +3849,7 @@ function RAT:_SetMarker(text, wp, index) RAT.markerid=RAT.markerid+1 self.markerids[#self.markerids+1]=RAT.markerid if self.debug then - env.info(RAT.id..self.SpawnTemplatePrefix..": placing marker with ID "..RAT.markerid..": "..text) + self:T(RAT.id..self.SpawnTemplatePrefix..": placing marker with ID "..RAT.markerid..": "..text) end -- Convert to coordinate. local vec={x=wp.x, y=wp.alt, z=wp.y} @@ -3940,7 +3942,7 @@ function RAT:_ModifySpawnTemplate(waypoints, livery) -- Parking spot. UnitTemplate.parking = nil UnitTemplate.parking_id = self.parking_id - --env.info(RAT.id.."Parking ID "..tostring(self.parking_id)) + --self:T(RAT.id.."Parking ID "..tostring(self.parking_id)) -- Initial altitude UnitTemplate.alt=PointVec3.y @@ -3988,9 +3990,9 @@ end -- @param #table airports_map List of all airports of the map. function RAT:_ATCInit(airports_map) if not RAT.ATC.init then - env.info(RAT.id.."Starting RAT ATC.") - env.info(RAT.id.."Simultanious = "..RAT.ATC.Nclearance) - env.info(RAT.id.."Delay = "..RAT.ATC.delay) + local text + text="Starting RAT ATC.\nSimultanious = "..RAT.ATC.Nclearance.."\n".."Delay = "..RAT.ATC.delay) + self:T(RAT.id..text) RAT.ATC.init=true for _,ap in pairs(airports_map) do local name=ap:GetName() @@ -4013,7 +4015,7 @@ end -- @param #string name Group name of the flight. -- @param #string dest Name of the destination airport. function RAT:_ATCAddFlight(name, dest) - env.info(string.format("%sATC %s: Adding flight %s with destination %s.", RAT.id, dest, name, dest)) + self:T(string.format("%sATC %s: Adding flight %s with destination %s.", RAT.id, dest, name, dest)) RAT.ATC.flight[name]={} RAT.ATC.flight[name].destination=dest RAT.ATC.flight[name].Tarrive=-1 @@ -4038,7 +4040,7 @@ end -- @param #string name Group name of the flight. -- @param #number time Time the fight first registered. function RAT:_ATCRegisterFlight(name, time) - env.info(RAT.id.."Flight ".. name.." registered at ATC for landing clearance.") + self:T(RAT.id.."Flight ".. name.." registered at ATC for landing clearance.") RAT.ATC.flight[name].Tarrive=time RAT.ATC.flight[name].holding=0 end @@ -4069,7 +4071,7 @@ function RAT:_ATCStatus() -- Aircraft is holding. local text=string.format("ATC %s: Flight %s is holding for %i:%02d. %s.", dest, name, hold/60, hold%60, busy) - env.info(RAT.id..text) + self:T(RAT.id..text) elseif hold==RAT.ATC.onfinal then @@ -4077,15 +4079,15 @@ function RAT:_ATCStatus() local Tfinal=Tnow-RAT.ATC.flight[name].Tonfinal local text=string.format("ATC %s: Flight %s is on final. Waiting %i:%02d for landing event.", dest, name, Tfinal/60, Tfinal%60) - env.info(RAT.id..text) + self:T(RAT.id..text) elseif hold==RAT.ATC.unregistered then -- Aircraft has not arrived at holding point. - --env.info(string.format("ATC %s: Flight %s is not registered yet (hold %d).", dest, name, hold)) + --self:T(string.format("ATC %s: Flight %s is not registered yet (hold %d).", dest, name, hold)) else - env.error(RAT.id.."Unknown holding time in RAT:_ATCStatus().") + self:E(RAT.id.."ERROR: Unknown holding time in RAT:_ATCStatus().") end end @@ -4127,12 +4129,12 @@ function RAT:_ATCCheck() -- Debug message. local text=string.format("ATC %s: Flight %s runway is busy. You are #%d of %d in landing queue. Your holding time is %i:%02d.", name, flight,qID, nqueue, RAT.ATC.flight[flight].holding/60, RAT.ATC.flight[flight].holding%60) - env.info(RAT.id..text) + self:T(RAT.id..text) else local text=string.format("ATC %s: Flight %s was cleared for landing. Your holding time was %i:%02d.", name, flight, RAT.ATC.flight[flight].holding/60, RAT.ATC.flight[flight].holding%60) - env.info(RAT.id..text) + self:T(RAT.id..text) -- Clear flight for landing. RAT:_ATCClearForLanding(name, flight) @@ -4172,7 +4174,7 @@ function RAT:_ATCClearForLanding(airport, flight) -- Debug message. local text1=string.format("ATC %s: Flight %s cleared for landing (flag=%d).", airport, flight, flagvalue) local text2=string.format("ATC %s: Flight %s you are cleared for landing.", airport, flight) - env.info( RAT.id..text1) + self:T( RAT.id..text1) MESSAGE:New(text2, 10):ToAll() end @@ -4214,9 +4216,9 @@ function RAT:_ATCFlightLanded(name) local text2=string.format("ATC %s: Number of flights still on final %d.", dest, RAT.ATC.airport[dest].Nonfinal) local text3=string.format("ATC %s: Traffic report: Number of planes landed in total %d. Flights/hour = %3.2f.", dest, RAT.ATC.airport[dest].traffic, TrafficPerHour) local text4=string.format("ATC %s: Flight %s landed. Welcome to %s.", dest, name, dest) - env.info(RAT.id..text1) - env.info(RAT.id..text2) - env.info(RAT.id..text3) + self:T(RAT.id..text1) + self:T(RAT.id..text2) + self:T(RAT.id..text3) MESSAGE:New(text4, 10):ToAll() end @@ -4269,4 +4271,3 @@ function RAT:_ATCQueue() end end ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ -