From d26a938ba4c16db4bef1e215d79f4af46d2adb73 Mon Sep 17 00:00:00 2001 From: FlightControl_Master Date: Tue, 29 Aug 2017 22:20:38 +0200 Subject: [PATCH] Fixed detection reports * Detection reports of DETECTION classes now are returned as a REPORT object. So they can be streamed with various delimiters \n or , or other... * If a coordinate needs to be represented by BR or BRAA, then a "source" controllable is required, which is usually the player aircraft. If not given, the coordinate will be returned in MGRS mode!!! --- Moose Development/Moose/Core/Point.lua | 17 +++++++++++++---- .../Moose/Functional/Detection.lua | 18 +++++++++--------- 2 files changed, 22 insertions(+), 13 deletions(-) diff --git a/Moose Development/Moose/Core/Point.lua b/Moose Development/Moose/Core/Point.lua index d9e55dc04..7f9b04620 100644 --- a/Moose Development/Moose/Core/Point.lua +++ b/Moose Development/Moose/Core/Point.lua @@ -838,8 +838,12 @@ do -- COORDINATE if ModeA2A then if Settings:IsA2A_BRAA() then - local Coordinate = Controllable:GetCoordinate() - return self:ToStringBRA( Coordinate, Settings ) + if Controllable then + local Coordinate = Controllable:GetCoordinate() + return self:ToStringBRA( Coordinate, Settings ) + else + return self:ToStringMGRS( Settings ) + end end if Settings:IsA2A_BULLS() then local Coalition = Controllable:GetCoalition() @@ -856,8 +860,13 @@ do -- COORDINATE end else if Settings:IsA2G_BR() then - local Coordinate = Controllable:GetCoordinate() - return Controllable and self:ToStringBR( Coordinate, Settings ) or self:ToStringMGRS( Settings ) + -- If no Controllable is given to calculate the BR from, then MGRS will be used!!! + if Controllable then + local Coordinate = Controllable:GetCoordinate() + return Controllable and self:ToStringBR( Coordinate, Settings ) or self:ToStringMGRS( Settings ) + else + return self:ToStringMGRS( Settings ) + end end if Settings:IsA2G_LL_DMS() then return self:ToStringLLDMS( Settings ) diff --git a/Moose Development/Moose/Functional/Detection.lua b/Moose Development/Moose/Functional/Detection.lua index 7908f1a43..b2ce1538b 100644 --- a/Moose Development/Moose/Functional/Detection.lua +++ b/Moose Development/Moose/Functional/Detection.lua @@ -1940,14 +1940,14 @@ do -- DETECTION_UNITS end end - --TODO: solve Index reference - local DetectedItemCoordinate = self:GetDetectedItemCoordinate( Index ) - local DetectedItemCoordText = DetectedItemCoordinate:ToString( AttackGroup, Settings ) + --TODO: solve Index reference + local DetectedItemCoordinate = self:GetDetectedItemCoordinate( Index ) + local DetectedItemCoordText = DetectedItemCoordinate:ToString( AttackGroup, Settings ) - local ThreatLevelA2G = self:GetDetectedItemThreatLevel( DetectedItem ) + local ThreatLevelA2G = self:GetDetectedItemThreatLevel( Index ) - local Report = REPORT:New() - Report:Add(DetectedItemID .. ", " .. DetectedItemCoordText) + local Report = REPORT:New() + Report:Add(DetectedItemID .. ", " .. DetectedItemCoordText) Report:Add( string.format( "Threat: [%s]", string.rep( "■", ThreatLevelA2G ) ) ) Report:Add( string.format("Type: %s%s", UnitCategoryText, UnitDistanceText ) ) return Report @@ -1968,7 +1968,7 @@ do -- DETECTION_UNITS local DetectedItem = DetectedItem -- #DETECTION_BASE.DetectedItem local ReportSummary = self:DetectedItemReportSummary( DetectedItemID, AttackGroup ) Report:SetTitle( "Detected units:" ) - Report:Add( ReportSummary ) + Report:Add( ReportSummary:Text() ) end local ReportText = Report:Text() @@ -2198,7 +2198,7 @@ do -- DETECTION_TYPES local DetectedItem = DetectedItem -- #DETECTION_BASE.DetectedItem local ReportSummary = self:DetectedItemReportSummary( DetectedItemTypeName, AttackGroup ) Report:SetTitle( "Detected types:" ) - Report:Add( ReportSummary ) + Report:Add( ReportSummary:Text() ) end local ReportText = Report:Text() @@ -2352,7 +2352,7 @@ do -- DETECTION_AREAS local DetectedItem = DetectedItem -- #DETECTION_BASE.DetectedItem local ReportSummary = self:DetectedItemReportSummary( DetectedItemIndex, AttackGroup ) Report:SetTitle( "Detected areas:" ) - Report:Add( ReportSummary ) + Report:Add( ReportSummary:Text() ) end local ReportText = Report:Text()