From 6f581cadf14ca3060d28fe62ab584a98b420dfeb Mon Sep 17 00:00:00 2001 From: FlightControl Date: Thu, 13 Jul 2017 21:35:48 +0200 Subject: [PATCH] Fixes issue where A2G cannot be selected for A2G tasks with an airplane. Added the IsInstanceOf check in COORDINATE:ToString method. If Task is given, (the Task), then it is checked which parent task it was from. If A2A, the mode will be A2A, if A2G or CARGO, the mode will be A2G. If Task was not given, then the unit type will decide upon the A2A or A2G mode. --- Moose Development/Moose/Actions/Act_Route.lua | 3 +- Moose Development/Moose/Core/Point.lua | 31 ++++++++++++++++--- 2 files changed, 29 insertions(+), 5 deletions(-) diff --git a/Moose Development/Moose/Actions/Act_Route.lua b/Moose Development/Moose/Actions/Act_Route.lua index 4c36460a9..7f98b8b1a 100644 --- a/Moose Development/Moose/Actions/Act_Route.lua +++ b/Moose Development/Moose/Actions/Act_Route.lua @@ -174,6 +174,7 @@ do -- ACT_ROUTE end + local Task = self:GetTask() -- This is to dermine that the coordinates are for a specific task mode (A2A or A2G). local CC = self:GetTask():GetMission():GetCommandCenter() if CC then if CC:IsModeWWII() then @@ -198,7 +199,7 @@ do -- ACT_ROUTE RouteText = Coordinate:ToStringFromRP( ShortestReferencePoint, ShortestReferenceName, Controllable ) end else - RouteText = Coordinate:ToString( Controllable ) + RouteText = Coordinate:ToString( Controllable, nil, Task ) end end diff --git a/Moose Development/Moose/Core/Point.lua b/Moose Development/Moose/Core/Point.lua index 2e3a97d6a..241dec604 100644 --- a/Moose Development/Moose/Core/Point.lua +++ b/Moose Development/Moose/Core/Point.lua @@ -794,16 +794,39 @@ do -- COORDINATE -- @param #COORDINATE self -- @param Wrapper.Controllable#CONTROLLABLE Controllable -- @param Core.Settings#SETTINGS Settings + -- @param Tasking.Task#TASK Task The task for which coordinates need to be calculated. -- @return #string The coordinate Text in the configured coordinate system. - function COORDINATE:ToString( Controllable, Settings ) -- R2.2 + function COORDINATE:ToString( Controllable, Settings, Task ) -- R2.2 self:E( { Controllable = Controllable } ) local Settings = Settings or ( Controllable and _DATABASE:GetPlayerSettings( Controllable:GetPlayerName() ) ) or _SETTINGS - - local IsAir = Controllable and Controllable:IsAirPlane() or false - if IsAir then + local ModeA2A = true + + if Task then + if Task:IsInstanceOf( TASK_A2A ) then + ModeA2A = true + else + if Task:IsInstanceOf( TASK_A2G ) then + ModeA2A = false + else + if Task:IsInstanceOf( TASK_CARGO ) then + ModeA2A = false + end + end + end + else + local IsAir = Controllable and Controllable:IsAirPlane() or false + if IsAir then + ModeA2A = true + else + ModeA2A = false + end + end + + + if ModeA2A then if Settings:IsA2A_BRAA() then local Coordinate = Controllable:GetCoordinate() return self:ToStringBRA( Coordinate, Settings )