Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug where an undefined arrival airport will cause plugin to crash #26

Merged
merged 4 commits into from
Jul 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions AT3/AT3Tags.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -703,7 +703,7 @@ string AT3Tags::GetRouteCodeLine4(CFlightPlan& FlightPlan, CRadarTarget& RadarTa
lineStr = lineStr.substr(0, lineStr.find("_"));
}
}
else if (strlen(FlightPlan.GetFlightPlanData().GetArrivalRwy()) != 0) {
else if (arptSet.find(FlightPlan.GetFlightPlanData().GetDestination()) != arptSet.end() && strlen(FlightPlan.GetFlightPlanData().GetArrivalRwy()) != 0) {
for (auto& rte : rteJson[FlightPlan.GetFlightPlanData().GetDestination()][runway.substr(0, 2)]["routes"].items()) { //matches exact route only for auto assigning route code
if (fpRoute.find(rte.value()["route"]) != string::npos) {
lineStr = rte.key();
Expand Down Expand Up @@ -752,7 +752,7 @@ string AT3Tags::GetAPPDEPLine4(CFlightPlan& FlightPlan, CRadarTarget& RadarTarge
lineStr = lineStr.substr(0, lineStr.find("_")); //always get route from spad/flight strip in case of version mismatch
}
}
else if (strlen(FlightPlan.GetFlightPlanData().GetArrivalRwy()) != 0) {
else if (arptSet.find(FlightPlan.GetFlightPlanData().GetDestination()) != arptSet.end() && strlen(FlightPlan.GetFlightPlanData().GetArrivalRwy()) != 0) {
string app = GetAvailableApps(FlightPlan.GetFlightPlanData().GetDestination(), FlightPlan.GetFlightPlanData().GetArrivalRwy())[0]; //selects default app if no assignment, which is [0]
if (app.find("_") != string::npos) {
lineStr = app.substr(0, app.find("_"));
Expand All @@ -762,7 +762,7 @@ string AT3Tags::GetAPPDEPLine4(CFlightPlan& FlightPlan, CRadarTarget& RadarTarge
}

if (lineStr.length() < 1) {
if (strlen(FlightPlan.GetFlightPlanData().GetSidName()) != 0) {
if (arptSet.find(FlightPlan.GetFlightPlanData().GetOrigin()) != arptSet.end() && strlen(FlightPlan.GetFlightPlanData().GetSidName()) != 0) {
lineStr = FlightPlan.GetFlightPlanData().GetSidName();
}
else {
Expand All @@ -787,7 +787,7 @@ string AT3Tags::GetAMCLine4(CFlightPlan& FlightPlan, CRadarTarget& RadarTarget)
lineStr = lineStr.substr(0, lineStr.find("_"));
}
}
else if (strlen(FlightPlan.GetFlightPlanData().GetArrivalRwy()) != 0) {
else if (arptSet.find(FlightPlan.GetFlightPlanData().GetDestination()) != arptSet.end() && strlen(FlightPlan.GetFlightPlanData().GetArrivalRwy()) != 0) {
string app = GetAvailableApps(FlightPlan.GetFlightPlanData().GetDestination(), FlightPlan.GetFlightPlanData().GetArrivalRwy())[0]; //selects default app if no assignment, which is [0]
if (app.find("_") != string::npos) {
lineStr = app.substr(0, app.find("_"));
Expand Down Expand Up @@ -908,9 +908,13 @@ string AT3Tags::GetVSIndicator(CFlightPlan& FlightPlan, CRadarTarget& RadarTarge

string AT3Tags::GetFormattedArrivalRwy(CFlightPlan& FlightPlan, CRadarTarget& RadarTarget)
{
string runway = FlightPlan.GetFlightPlanData().GetArrivalRwy();
if (runway.length() < 3) {
runway.insert(runway.length(), 3 - runway.length(), ' ');
if (arptSet.find(FlightPlan.GetFlightPlanData().GetDestination()) != arptSet.end()) {
string runway = FlightPlan.GetFlightPlanData().GetArrivalRwy();
if (runway.length() < 3) {
runway.insert(runway.length(), 3 - runway.length(), ' ');
}
return runway;
} else {
return " ";
}
return runway;
}
Loading