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.
This commit is contained in:
FlightControl 2017-07-13 21:35:48 +02:00
parent f8cca7d510
commit 6f581cadf1
2 changed files with 29 additions and 5 deletions

View File

@ -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

View File

@ -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
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 )