From d6c919a097fd3febe1b7acd52596ab47840ec097 Mon Sep 17 00:00:00 2001 From: Wingthor Date: Thu, 13 Feb 2020 12:16:56 +0100 Subject: [PATCH 1/5] Added some line to docs to tell Spawn state might not be as expected. Added: Requested assets spawn in various "Engagement Rules" (ROE) and Alerts modes. If your assets will cross into dangerous areas, be sure to change these states. You can do this in @{#WAREHOUSE:OnAfterAssetSpawned}(*From, *Event, *To, *group, *asset, *request)) function. Initial Spawn states is as follows: GROUND: ROE, "Return Fire" Alarm, "Green" AIR: ROE, "Return Fire" Reaction to Threat, "Passive Defense" NAVAL ROE, "Return Fire" Alarm,"N/A" Solves issue #1260 --- Moose Development/Moose/Functional/Warehouse.lua | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Moose Development/Moose/Functional/Warehouse.lua b/Moose Development/Moose/Functional/Warehouse.lua index 999eb97c9..284a95cea 100644 --- a/Moose Development/Moose/Functional/Warehouse.lua +++ b/Moose Development/Moose/Functional/Warehouse.lua @@ -282,6 +282,13 @@ -- -- Assets of the warehouse can be requested by other MOOSE warehouses. A request will first be scrutinized to check if can be fulfilled at all. If the request is valid, it is -- put into the warehouse queue and processed as soon as possible. + +-- Requested assets spawn in various "Rule of Engagement Rules" (ROE) and Alerts modes. If your assets will cross into dangerous areas, be sure to change these states. You can do this in @{#WAREHOUSE:OnAfterAssetSpawned}(*From, *Event, *To, *group, *asset, *request)) function. +-- +-- Initial Spawn states is as follows: +-- GROUND: ROE, "Return Fire" Alarm, "Green" +-- AIR: ROE, "Return Fire" Reaction to Threat, "Passive Defense" +-- NAVAL ROE, "Return Fire" Alarm,"N/A" -- -- A request can be added by the @{#WAREHOUSE.AddRequest}(*warehouse*, *AssetDescriptor*, *AssetDescriptorValue*, *nAsset*, *TransportType*, *nTransport*, *Prio*, *Assignment*) function. -- The parameters are From 9583168c4d0250a421b29acfb585384523922fd7 Mon Sep 17 00:00:00 2001 From: 132nd-Entropy Date: Thu, 20 Feb 2020 14:38:11 +0100 Subject: [PATCH 2/5] Update ATIS.lua --- Moose Development/Moose/Ops/ATIS.lua | 32 ++++++++++++++-------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/Moose Development/Moose/Ops/ATIS.lua b/Moose Development/Moose/Ops/ATIS.lua index db3be94ab..f5c1199a6 100644 --- a/Moose Development/Moose/Ops/ATIS.lua +++ b/Moose Development/Moose/Ops/ATIS.lua @@ -354,10 +354,10 @@ ATIS.Alphabet = { --- Runway correction for converting true to magnetic heading. -- @type ATIS.RunwayM2T --- @field #number Caucasus 0° (East). --- @field #number Nevada +12° (East). --- @field #number Normandy -10° (West). --- @field #number PersianGulf +2° (East). +-- @field #number Caucasus 0° (East). +-- @field #number Nevada +12° (East). +-- @field #number Normandy -10° (West). +-- @field #number PersianGulf +2° (East). ATIS.RunwayM2T={ Caucasus=0, Nevada=12, @@ -709,9 +709,9 @@ function ATIS:SetMapMarks(switch) return self end ---- Set magnetic runway headings as depicted on the runway, *e.g.* "13" for 130° or "25L" for the left runway with magnetic heading 250°. +--- Set magnetic runway headings as depicted on the runway, *e.g.* "13" for 130° or "25L" for the left runway with magnetic heading 250�. -- @param #ATIS self --- @param #table headings Magnetic headings. Inverse (-180°) headings are added automatically. You only need to specify one heading per runway direction. "L"eft and "R" right can also be appended. +-- @param #table headings Magnetic headings. Inverse (-180�) headings are added automatically. You only need to specify one heading per runway direction. "L"eft and "R" right can also be appended. -- @return #ATIS self function ATIS:SetRunwayHeadingsMagnetic(headings) @@ -826,12 +826,12 @@ end -- -- To get *true* from *magnetic* heading one has to add easterly or substract westerly variation, e.g -- --- A magnetic heading of 180° corresponds to a true heading of +-- A magnetic heading of 180° corresponds to a true heading of -- --- * 186° on the Caucaus map --- * 192° on the Nevada map --- * 170° on the Normany map --- * 182° on the Persian Gulf map +-- * 186° on the Caucaus map +-- * 192° on the Nevada map +-- * 170° on the Normany map +-- * 182° on the Persian Gulf map -- -- Likewise, to convert *magnetic* into *true* heading, one has to substract easterly and add westerly variation. -- @@ -1085,7 +1085,7 @@ function ATIS:onafterBroadcast(From, Event, To) local g= 9.80665 --[m/s^2] local M= 0.0289644 --[kg/mol] local T0=coord:GetTemperature(0)+273.15 --[K] Temp at sea level. - local TS=288.15 -- Standard Temperature assumed by Altimeter is 15°C + local TS=288.15 -- Standard Temperature assumed by Altimeter is 15°C local q=qnh*100 -- Calculate Pressure. @@ -1197,10 +1197,10 @@ function ATIS:onafterBroadcast(From, Event, To) --- Temperature --- ------------------- - -- Temperature in °C (or °F). + -- Temperature in °C (or °F). local temperature=coord:GetTemperature(height+5) - -- Convert to °F. + -- Convert to °F. if self.TDegF then temperature=UTILS.CelciusToFarenheit(temperature) end @@ -1796,7 +1796,7 @@ end --- Get runway from user supplied magnetic heading. -- @param #ATIS self -- @param #number windfrom Wind direction (from) in degrees. --- @return #string Runway magnetic heading divided by ten (and rounded). Eg, "13" for 130°. +-- @return #string Runway magnetic heading divided by ten (and rounded). Eg, "13" for 130�. function ATIS:GetMagneticRunway(windfrom) local diffmin=nil @@ -1839,7 +1839,7 @@ function ATIS:GetNavPoint(navpoints, runway, left) local navL=self:GetRunwayLR(nav.runway) local hdgD=UTILS.HdgDiff(navy,rwyy) - if hdgD<=15 then --We allow an error of +-15° here. + if hdgD<=15 then --We allow an error of +-15° here. if navL==nil or (navL==true and left==true) or (navL==false and left==false) then return nav end From 042cc7a85f18e8b96e65dc884165bcab7758f5ac Mon Sep 17 00:00:00 2001 From: 132nd-Entropy Date: Thu, 20 Feb 2020 15:04:00 +0100 Subject: [PATCH 3/5] Update ATIS.lua --- Moose Development/Moose/Ops/ATIS.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Moose Development/Moose/Ops/ATIS.lua b/Moose Development/Moose/Ops/ATIS.lua index f5c1199a6..dfd9fbebe 100644 --- a/Moose Development/Moose/Ops/ATIS.lua +++ b/Moose Development/Moose/Ops/ATIS.lua @@ -709,9 +709,9 @@ function ATIS:SetMapMarks(switch) return self end ---- Set magnetic runway headings as depicted on the runway, *e.g.* "13" for 130° or "25L" for the left runway with magnetic heading 250�. +--- Set magnetic runway headings as depicted on the runway, *e.g.* "13" for 130° or "25L" for the left runway with magnetic heading 250°. -- @param #ATIS self --- @param #table headings Magnetic headings. Inverse (-180�) headings are added automatically. You only need to specify one heading per runway direction. "L"eft and "R" right can also be appended. +-- @param #table headings Magnetic headings. Inverse (-180°) headings are added automatically. You only need to specify one heading per runway direction. "L"eft and "R" right can also be appended. -- @return #ATIS self function ATIS:SetRunwayHeadingsMagnetic(headings) @@ -1796,7 +1796,7 @@ end --- Get runway from user supplied magnetic heading. -- @param #ATIS self -- @param #number windfrom Wind direction (from) in degrees. --- @return #string Runway magnetic heading divided by ten (and rounded). Eg, "13" for 130�. +-- @return #string Runway magnetic heading divided by ten (and rounded). Eg, "13" for 130°. function ATIS:GetMagneticRunway(windfrom) local diffmin=nil From fedee49eb112869b17805752ecd065cedc606b79 Mon Sep 17 00:00:00 2001 From: Pikes Date: Sat, 22 Feb 2020 16:35:18 +0000 Subject: [PATCH 4/5] Update Airbase.lua https://github.com/FlightControl-Master/MOOSE/issues/1279 I dont know if anything else needs to be done apart from this. --- Moose Development/Moose/Wrapper/Airbase.lua | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/Moose Development/Moose/Wrapper/Airbase.lua b/Moose Development/Moose/Wrapper/Airbase.lua index 14c93a7a9..541412c3b 100644 --- a/Moose Development/Moose/Wrapper/Airbase.lua +++ b/Moose Development/Moose/Wrapper/Airbase.lua @@ -217,7 +217,14 @@ AIRBASE.Normandy = { ["Funtington"] = "Funtington", ["Tangmere"] = "Tangmere", ["Ford"] = "Ford", - } + ["Goulet"] = "Goulet", + ["Argentan"] = "Argentan", + ["Vrigny"] = "Vrigny", + ["Essay"] = "Essay", + ["Hauterive"] = "Hauterive", + ["Barville"] = "Barville", + ["Conches"] = "Conches", +} --- These are all airbases of the Persion Gulf Map: -- @@ -329,7 +336,7 @@ AIRBASE.TerminalType = { --- Runway data. -- @type AIRBASE.Runway -- @field #number heading Heading of the runway in degrees. --- @field #string idx Runway ID: heading 070° ==> idx="07". +-- @field #string idx Runway ID: heading 070° ==> idx="07". -- @field #number length Length of runway in meters. -- @field Core.Point#COORDINATE position Position of runway start. -- @field Core.Point#COORDINATE endpoint End point of runway. @@ -1107,7 +1114,7 @@ function AIRBASE:GetRunwayData(magvar, mark) -- Heading of runway. local hdg=c1:HeadingTo(c2) - -- Runway ID: heading=070° ==> idx="07" + -- Runway ID: heading=070° ==> idx="07" local idx=string.format("%02d", UTILS.Round((hdg-magvar)/10, 0)) -- Runway table. @@ -1217,7 +1224,7 @@ function AIRBASE:GetActiveRunway(magvar) local dot=UTILS.VecDot(Vwind, Vrunway) -- Debug. - --env.info(string.format("runway=%03d° dot=%.3f", runway.heading, dot)) + --env.info(string.format("runway=%03d° dot=%.3f", runway.heading, dot)) -- New min? if dotmin==nil or dot Date: Tue, 25 Feb 2020 21:35:00 +0100 Subject: [PATCH 5/5] Fixes & Improvements --- Moose Development/Moose/Core/RadioQueue.lua | 12 +++++++-- Moose Development/Moose/Ops/ATIS.lua | 4 ++- Moose Development/Moose/Utilities/Utils.lua | 7 ++++-- Moose Development/Moose/Wrapper/Airbase.lua | 28 +++++++++++++++++---- 4 files changed, 41 insertions(+), 10 deletions(-) diff --git a/Moose Development/Moose/Core/RadioQueue.lua b/Moose Development/Moose/Core/RadioQueue.lua index 7ee3c02ae..756b5a967 100644 --- a/Moose Development/Moose/Core/RadioQueue.lua +++ b/Moose Development/Moose/Core/RadioQueue.lua @@ -351,13 +351,21 @@ function RADIOQUEUE:Broadcast(transmission) self.senderinit=true end + -- Set subtitle only if duration>0 sec. + local subtitle=nil + local duration=nil + if transmission.subtitle and transmission.subduration and transmission.subduration>0 then + subtitle=transmission.subtitle + duration=transmission.subduration + end + -- Command to tranmit the call. local commandTransmit={ id = "TransmitMessage", params = { file=filename, - duration=transmission.subduration, - subtitle=transmission.subtitle or "", + duration=duration, + subtitle=subtitle, loop=false, }} diff --git a/Moose Development/Moose/Ops/ATIS.lua b/Moose Development/Moose/Ops/ATIS.lua index dfd9fbebe..7dbb616dd 100644 --- a/Moose Development/Moose/Ops/ATIS.lua +++ b/Moose Development/Moose/Ops/ATIS.lua @@ -130,6 +130,7 @@ -- **Note** that you should use a different relay unit for each ATIS! -- -- By default, subtitles are displayed for 10 seconds. This can be changed using @{#ATIS.SetSubtitleDuration}(*duration*) with *duration* being the duration in seconds. +-- Setting a *duration* of 0 will completely disable all subtitles. -- -- ## Active Runway -- @@ -523,7 +524,7 @@ _ATIS={} --- ATIS class version. -- @field #string version -ATIS.version="0.6.3" +ATIS.version="0.6.4" ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -- TODO list @@ -1537,6 +1538,7 @@ function ATIS:onafterBroadcast(From, Event, To) -- Runway length. if self.rwylength then + local runact=self.airbase:GetActiveRunway(self.runwaym2t) local length=runact.length if not self.metric then length=UTILS.MetersToFeet(length) diff --git a/Moose Development/Moose/Utilities/Utils.lua b/Moose Development/Moose/Utilities/Utils.lua index 7346dcc38..d31ae647a 100644 --- a/Moose Development/Moose/Utilities/Utils.lua +++ b/Moose Development/Moose/Utilities/Utils.lua @@ -474,8 +474,11 @@ UTILS.tostringMGRS = function(MGRS, acc) --R2.1 if acc == 0 then return MGRS.UTMZone .. ' ' .. MGRS.MGRSDigraph else - return MGRS.UTMZone .. ' ' .. MGRS.MGRSDigraph .. ' ' .. string.format('%0' .. acc .. 'd', UTILS.Round(MGRS.Easting/(10^(5-acc)), 0)) - .. ' ' .. string.format('%0' .. acc .. 'd', UTILS.Round(MGRS.Northing/(10^(5-acc)), 0)) + --return MGRS.UTMZone .. ' ' .. MGRS.MGRSDigraph .. ' ' .. string.format('%0' .. acc .. 'd', UTILS.Round(MGRS.Easting/(10^(5-acc)), 0)) + -- .. ' ' .. string.format('%0' .. acc .. 'd', UTILS.Round(MGRS.Northing/(10^(5-acc)), 0)) + + -- Truncate rather than round MGRS grid! + return string.format("%s %s %s %s", MGRS.UTMZone, MGRS.MGRSDigraph, string.sub(tostring(MGRS.Easting), 1, acc), string.sub(tostring(MGRS.Northing), 1, acc)) end end diff --git a/Moose Development/Moose/Wrapper/Airbase.lua b/Moose Development/Moose/Wrapper/Airbase.lua index 541412c3b..ccfbc5a59 100644 --- a/Moose Development/Moose/Wrapper/Airbase.lua +++ b/Moose Development/Moose/Wrapper/Airbase.lua @@ -352,7 +352,13 @@ function AIRBASE:Register( AirbaseName ) local self = BASE:Inherit( self, POSITIONABLE:New( AirbaseName ) ) --#AIRBASE self.AirbaseName = AirbaseName self.AirbaseID = self:GetID(true) - self.AirbaseZone = ZONE_RADIUS:New( AirbaseName, self:GetVec2(), 2500 ) + local vec2=self:GetVec2() + if vec2 then + self.AirbaseZone = ZONE_RADIUS:New( AirbaseName, vec2, 2500 ) + else + self:E(string.format("ERROR: Cound not get position Vec2 of airbase %s", AirbaseName)) + end + return self end @@ -450,7 +456,7 @@ function AIRBASE:GetID(unique) else - for DCSAirbaseId, DCSAirbase in pairs(world.getAirbases()) do + for DCSAirbaseId, DCSAirbase in ipairs(world.getAirbases()) do -- Get the airbase name. local AirbaseName = DCSAirbase:getName() @@ -458,8 +464,12 @@ function AIRBASE:GetID(unique) -- This gives the incorrect value to be inserted into the airdromeID for DCS 2.5.6! local airbaseID=tonumber(DCSAirbase:getID()) + local airbaseCategory=self:GetAirbaseCategory() + + --env.info(string.format("FF airbase=%s id=%s category=%s", tostring(AirbaseName), tostring(airbaseID), tostring(airbaseCategory))) + -- No way AFIK to get the DCS version. So we check if the event exists. That should tell us if we are on DCS 2.5.6 or prior to that. - if world.event.S_EVENT_KILL and world.event.S_EVENT_KILL>0 and self:GetAirbaseCategory()==Airbase.Category.AIRDROME then + if world.event.S_EVENT_KILL and world.event.S_EVENT_KILL>0 and airbaseCategory==Airbase.Category.AIRDROME then -- We have to take the key value of this loop! airbaseID=DCSAirbaseId @@ -471,7 +481,7 @@ function AIRBASE:GetID(unique) end if AirbaseName==self.AirbaseName then - if self:GetAirbaseCategory()==Airbase.Category.SHIP then + if airbaseCategory==Airbase.Category.SHIP then -- Ships get a negative sign as their unit number might be the same as the ID of another airbase. return unique and -airbaseID or airbaseID else @@ -1011,7 +1021,15 @@ end -- @param #AIRBASE self -- @return #number Category of airbase from GetDesc().category. function AIRBASE:GetAirbaseCategory() - return self:GetDesc().category + local desc=self:GetDesc() + local category=Airbase.Category.AIRDROME + + if desc and desc.category then + category=desc.category + else + self:E(string.format("ERROR: Cannot get category of airbase %s due to DCS 2.5.6 bug! Assuming it is an AIRDROME for now...", tostring(self.AirbaseName))) + end + return category end