Skip to content

Commit 0970705

Browse files
authored
Merge pull request #34 from vatsimhk/dev
v2.0.2
2 parents 32542df + b6306f2 commit 0970705

File tree

5 files changed

+55
-18
lines changed

5 files changed

+55
-18
lines changed

AT3/AT3Tags.cpp

+30-11
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
#include <array>
88
#include <chrono>
99
#include <ctime>
10+
#include <boost/algorithm/string.hpp>
11+
#include <boost/format.hpp>
1012

1113
using namespace EuroScopePlugIn;
1214

@@ -671,7 +673,6 @@ string AT3Tags::GetRouteCodeLine4(CFlightPlan& FlightPlan, CRadarTarget& RadarTa
671673
string spadCurrent = FlightPlan.GetControllerAssignedData().GetScratchPadString();
672674
string flightStrip = FlightPlan.GetControllerAssignedData().GetFlightStripAnnotation(3);
673675
string runway = FlightPlan.GetFlightPlanData().GetArrivalRwy();
674-
string fpRoute = FlightPlan.GetFlightPlanData().GetRoute();
675676
string lineStr;
676677

677678
size_t startContainer = flightStrip.find("/R/");
@@ -685,6 +686,18 @@ string AT3Tags::GetRouteCodeLine4(CFlightPlan& FlightPlan, CRadarTarget& RadarTa
685686
}
686687
}
687688
else if (arptSet.find(FlightPlan.GetFlightPlanData().GetDestination()) != arptSet.end() && strlen(FlightPlan.GetFlightPlanData().GetArrivalRwy()) != 0) {
689+
690+
// resolve flightplan route and remove stepclimb info to avoid the interference
691+
vector<string> route = split(FlightPlan.GetFlightPlanData().GetRoute(), ' ');
692+
string fpRoute = "";
693+
for (std::size_t i = 0; i < route.size(); i++) {
694+
if (i != 0 && i != route.size()) {
695+
route[i] = route[i].substr(0, route[i].find_first_of('/'));
696+
}
697+
boost::to_upper(route[i]);
698+
fpRoute = fpRoute + route[i] + " ";
699+
}
700+
688701
for (auto& rte : rteJson[FlightPlan.GetFlightPlanData().GetDestination()][runway.substr(0, 2)]["routes"].items()) { //matches exact route only for auto assigning route code
689702
if (fpRoute.find(rte.value()["route"]) != string::npos) {
690703
lineStr = rte.key();
@@ -734,11 +747,14 @@ string AT3Tags::GetAPPDEPLine4(CFlightPlan& FlightPlan, CRadarTarget& RadarTarge
734747
}
735748
}
736749
else if (arptSet.find(FlightPlan.GetFlightPlanData().GetDestination()) != arptSet.end() && strlen(FlightPlan.GetFlightPlanData().GetArrivalRwy()) != 0) {
737-
string app = GetAvailableApps(FlightPlan.GetFlightPlanData().GetDestination(), FlightPlan.GetFlightPlanData().GetArrivalRwy())[0]; //selects default app if no assignment, which is [0]
738-
if (app.find("_") != string::npos) {
739-
lineStr = app.substr(0, app.find("_"));
740-
string spadItem = "/A/" + app + "/A//";
741-
FlightPlan.GetControllerAssignedData().SetFlightStripAnnotation(2, spadItem.c_str());
750+
vector<string> appsVec = GetAvailableApps(FlightPlan.GetFlightPlanData().GetDestination(), FlightPlan.GetFlightPlanData().GetArrivalRwy());
751+
if (appsVec.size() > 0) {
752+
string app = appsVec[0]; //selects default app if no assignment, which is [0]
753+
if (app.find("_") != string::npos) {
754+
lineStr = app.substr(0, app.find("_"));
755+
string spadItem = "/A/" + app + "/A//";
756+
FlightPlan.GetControllerAssignedData().SetFlightStripAnnotation(2, spadItem.c_str());
757+
}
742758
}
743759
}
744760

@@ -769,11 +785,14 @@ string AT3Tags::GetAMCLine4(CFlightPlan& FlightPlan, CRadarTarget& RadarTarget)
769785
}
770786
}
771787
else if (arptSet.find(FlightPlan.GetFlightPlanData().GetDestination()) != arptSet.end() && strlen(FlightPlan.GetFlightPlanData().GetArrivalRwy()) != 0) {
772-
string app = GetAvailableApps(FlightPlan.GetFlightPlanData().GetDestination(), FlightPlan.GetFlightPlanData().GetArrivalRwy())[0]; //selects default app if no assignment, which is [0]
773-
if (app.find("_") != string::npos) {
774-
lineStr = app.substr(0, app.find("_"));
775-
string spadItem = "/A/" + app + "/A//";
776-
FlightPlan.GetControllerAssignedData().SetFlightStripAnnotation(2, spadItem.c_str());
788+
vector<string> appsVec = GetAvailableApps(FlightPlan.GetFlightPlanData().GetDestination(), FlightPlan.GetFlightPlanData().GetArrivalRwy());
789+
if (appsVec.size() > 0) {
790+
string app = appsVec[0]; //selects default app if no assignment, which is [0]
791+
if (app.find("_") != string::npos) {
792+
lineStr = app.substr(0, app.find("_"));
793+
string spadItem = "/A/" + app + "/A//";
794+
FlightPlan.GetControllerAssignedData().SetFlightStripAnnotation(2, spadItem.c_str());
795+
}
777796
}
778797
}
779798

AT3/AT3Tags.hpp

+18
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
#include "MAESTROapi.h"
1212
#include <chrono>
1313
#include <ctime>
14+
#include <boost/algorithm/string.hpp>
15+
#include <boost/format.hpp>
1416

1517
using namespace std;
1618
using namespace EuroScopePlugIn;
@@ -95,4 +97,20 @@ class AT3Tags :
9597
COLORREF colorAssumed;
9698
COLORREF colorNotAssumed;
9799
COLORREF colorRedundant;
100+
101+
private:
102+
template <typename Out>
103+
void split(const string& s, char delim, Out result) {
104+
istringstream iss(s);
105+
string item;
106+
while (getline(iss, item, delim)) {
107+
*result++ = item;
108+
}
109+
}
110+
111+
vector<string> split(const string& s, char delim) {
112+
vector<string> elems;
113+
split(s, delim, back_inserter(elems));
114+
return elems;
115+
}
98116
};

Constant.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#include <gdiplus.h>
44

55
#define MY_PLUGIN_NAME "HKCP"
6-
#define MY_PLUGIN_VERSION "2.0.1"
6+
#define MY_PLUGIN_VERSION "2.0.2"
77
#define MY_PLUGIN_DEVELOPER "HKvACC, Jan Fries, Hendrik Peter, Sven Czarnian"
88
#define MY_PLUGIN_COPYRIGHT "GPL v3"
99
#define MY_PLUGIN_VIEW_AVISO "Hong Kong Controller Plugin"

MissedApproach/MissedApproachAlarm.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -476,11 +476,11 @@ void MissedApproachAlarm::OnFlightPlanControllerAssignedDataUpdate(CFlightPlan F
476476
}
477477
}
478478

479-
// Trigger alarm (APP)
479+
// Clear Scratchpad
480480
scratchPadString.erase(0, strlen("MISAP_"));
481481
controllerData.SetScratchPadString(scratchPadString.c_str());
482482

483-
// Don't add to vector unless runway is selected and active
483+
// Don't Trigger alarm (APP) unless runway is selected and active
484484
if (find(activeMAPPRunways.begin(), activeMAPPRunways.end(), data.GetArrivalRwy()) == activeMAPPRunways.end()) return;
485485
missedAcftData.push_back(FlightPlan.GetCallsign());
486486
missedAcftData.push_back(data.GetDestination());

MissedApproach/MissedApproachPlugin.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,10 @@ void MissedApproachPlugin::ackMissedApproach(const char* callsign) {
5252
data = fpl.GetFlightPlanData();
5353
controllerData = fpl.GetControllerAssignedData();
5454

55-
string buf = controllerData.GetScratchPadString();
56-
buf.append("MISAP-ACK_");
55+
string buf = "MISAP-ACK_";
5756
buf.append(myself.GetPositionId());
57+
buf.append(controllerData.GetScratchPadString());
5858
controllerData.SetScratchPadString(buf.c_str());
59-
//couldn't find it, handle error
6059
}
6160

6261
void MissedApproachPlugin::resetMissedApproach(const char* callsign) {
@@ -118,5 +117,6 @@ bool MissedApproachPlugin::matchArrivalAirport(const char* arrivalArpt) {
118117
}
119118

120119
string MissedApproachPlugin::checkForAck(string scratchPadString) {
121-
return scratchPadString.substr(10, 2);
120+
auto it = scratchPadString.find("MISAP-ACK_");
121+
return scratchPadString.substr(it + 10, 2);
122122
}

0 commit comments

Comments
 (0)