Skip to content

Commit

Permalink
- fixes null ref exception for tsd data when not connected
Browse files Browse the repository at this point in the history
  • Loading branch information
FalcoGer committed May 21, 2024
1 parent 543f712 commit 13ae8a6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CoordinateConverter/DCS/Aircraft/AH64/AH64TSDOptionData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1219,6 +1219,10 @@ static public AH64TSDOptionData ReadFromAC(bool isPilot)
public List<DCSCommand> GenerateCommands(bool isPilot)
{
AH64TSDOptionData startingCondition = ReadFromAC(isPilot);
if (startingCondition == null)
{
return new List<DCSCommand>();
}
EPhase currentPhase = startingCondition.Phase;
int mfd = isPilot ? (int)AH64.EDeviceCode.PLT_RMFD : (int)AH64.EDeviceCode.CPG_RMFD;

Expand Down
6 changes: 5 additions & 1 deletion CoordinateConverter/DCS/Tools/FormAH64DTC.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1873,7 +1873,11 @@ private void nudManRange_ValueChanged(object sender, EventArgs e)
#region TSD
private void btn_getMapSettings_Click(object sender, EventArgs e)
{
data.TSDData = AH64TSDOptionData.ReadFromAC(IsPilot);
var newTsdData = AH64TSDOptionData.ReadFromAC(IsPilot);
if (newTsdData != null)
{
data.TSDData = newTsdData;
}
RefreshControls();
}

Expand Down

0 comments on commit 13ae8a6

Please sign in to comment.