|
@@ -36,8 +36,7 @@ using namespace aman;
|
|
|
static std::string __receivedAmanData;
|
|
|
|
|
|
static std::size_t receiveCurl(void* ptr, std::size_t size, std::size_t nmemb, void* stream) {
|
|
|
- (void)stream;
|
|
|
-
|
|
|
+ std::ignore = stream;
|
|
|
std::string serverResult = static_cast<char*>(ptr);
|
|
|
__receivedAmanData += serverResult;
|
|
|
return size * nmemb;
|
|
@@ -69,7 +68,7 @@ PlugIn::PlugIn() :
|
|
|
/* get the dll-path */
|
|
|
char path[MAX_PATH + 1] = { 0 };
|
|
|
const gsl::span<char, MAX_PATH + 1> span(path);
|
|
|
- GetModuleFileNameA((HINSTANCE)&__ImageBase, span.data(), span.size());
|
|
|
+ GetModuleFileNameA(gsl::narrow_cast<HINSTANCE>(&__ImageBase), span.data(), span.size());
|
|
|
PathRemoveFileSpecA(span.data());
|
|
|
std::string dllPath = span.data();
|
|
|
|
|
@@ -95,7 +94,7 @@ PlugIn::PlugIn() :
|
|
|
this->validateBackendData();
|
|
|
}
|
|
|
|
|
|
-PlugIn::~PlugIn() noexcept {
|
|
|
+PlugIn::~PlugIn() {
|
|
|
Backend::instance().deinitialize();
|
|
|
ZmqContext::instance().deinitialize();
|
|
|
google::protobuf::ShutdownProtobufLibrary();
|
|
@@ -174,7 +173,7 @@ void PlugIn::validateBackendData() {
|
|
|
}
|
|
|
|
|
|
/* incompatible communication version */
|
|
|
- if (PLUGIN_MAJOR_VERSION != std::atoi(entries[0].c_str()) || PLUGIN_MINOR_VERSION != std::atoi(entries[1].c_str())) {
|
|
|
+ if (PLUGIN_MAJOR_VERSION != std::atoi(gsl::at(entries, 0).c_str()) || PLUGIN_MINOR_VERSION != std::atoi(gsl::at(entries, 1).c_str())) {
|
|
|
MessageBoxA(nullptr, "Plugin version is outdated. An update is required", "AMAN-Error", MB_OK);
|
|
|
return;
|
|
|
}
|
|
@@ -200,11 +199,11 @@ EuroScopePlugIn::CRadarScreen* PlugIn::OnRadarScreenCreated(const char* displayN
|
|
|
return this->m_screen.get();
|
|
|
}
|
|
|
|
|
|
-aman::Aircraft* PlugIn::generateAircraftMessage(EuroScopePlugIn::CRadarTarget& target) {
|
|
|
+aman::Aircraft* PlugIn::generateAircraftMessage(const EuroScopePlugIn::CRadarTarget& target) const {
|
|
|
if (false == target.IsValid() || false == target.GetCorrelatedFlightPlan().IsValid())
|
|
|
return nullptr;
|
|
|
|
|
|
- auto flightPlan = target.GetCorrelatedFlightPlan();
|
|
|
+ const auto flightPlan = target.GetCorrelatedFlightPlan();
|
|
|
std::string callsign(target.GetCallsign());
|
|
|
aman::Aircraft* retval = new aman::Aircraft();
|
|
|
|
|
@@ -237,7 +236,7 @@ aman::Aircraft* PlugIn::generateAircraftMessage(EuroScopePlugIn::CRadarTarget& t
|
|
|
}
|
|
|
|
|
|
void PlugIn::generateAircraftReportMessage(EuroScopePlugIn::CRadarTarget& radarTarget, aman::AircraftReport* report) {
|
|
|
- auto flightPlan = radarTarget.GetCorrelatedFlightPlan();
|
|
|
+ const auto flightPlan = radarTarget.GetCorrelatedFlightPlan();
|
|
|
|
|
|
/* ignore invalid flightplans */
|
|
|
if (false == flightPlan.IsValid())
|
|
@@ -252,12 +251,12 @@ void PlugIn::generateAircraftReportMessage(EuroScopePlugIn::CRadarTarget& radarT
|
|
|
return;
|
|
|
|
|
|
/* filter invalid destinations */
|
|
|
- auto destination = std::string_view(flightPlan.GetFlightPlanData().GetDestination());
|
|
|
+ const auto destination = std::string_view(flightPlan.GetFlightPlanData().GetDestination());
|
|
|
if (4 != destination.length())
|
|
|
return;
|
|
|
|
|
|
/* filter by distance to destination */
|
|
|
- double distanceNM = flightPlan.GetDistanceToDestination();
|
|
|
+ const double distanceNM = flightPlan.GetDistanceToDestination();
|
|
|
if (5.0 > distanceNM || 250.0 < distanceNM)
|
|
|
return;
|
|
|
|
|
@@ -312,7 +311,7 @@ void PlugIn::generateAircraftReportMessage(EuroScopePlugIn::CRadarTarget& radarT
|
|
|
auto split = String::splitString(element.GetName(), " ");
|
|
|
|
|
|
/* find the correct star */
|
|
|
- if (0 != split.size() && destination == split[0]) {
|
|
|
+ if (0 != split.size() && destination == gsl::at(split, 0)) {
|
|
|
/* get the IAF */
|
|
|
EuroScopePlugIn::CPosition position;
|
|
|
if (true == element.GetPosition(&position, 0)) {
|
|
@@ -333,13 +332,13 @@ void PlugIn::generateAircraftReportMessage(EuroScopePlugIn::CRadarTarget& radarT
|
|
|
}
|
|
|
|
|
|
if (0 != iafName.length()) {
|
|
|
- auto iafDistance = currentPosition.DistanceTo(iafPosition);
|
|
|
+ const auto iafDistance = currentPosition.DistanceTo(iafPosition);
|
|
|
|
|
|
/* calculate the distance to the IAF */
|
|
|
double distanceToIaf = 0.0f;
|
|
|
for (int i = 1; i < flightPlan.GetPositionPredictions().GetPointsNumber(); ++i) {
|
|
|
- double distance = flightPlan.GetPositionPredictions().GetPosition(i).DistanceTo(currentPosition);
|
|
|
- double headingDelta = std::abs(radarTarget.GetPosition().GetReportedHeading() - flightPlan.GetPositionPredictions().GetPosition(i).DirectionTo(iafPosition));
|
|
|
+ const double distance = flightPlan.GetPositionPredictions().GetPosition(i).DistanceTo(currentPosition);
|
|
|
+ const double headingDelta = std::abs(radarTarget.GetPosition().GetReportedHeading() - flightPlan.GetPositionPredictions().GetPosition(i).DirectionTo(iafPosition));
|
|
|
|
|
|
/*
|
|
|
* 1. no direct way to IAF -> some direct given -> stop after lateral passing
|
|
@@ -371,9 +370,10 @@ void PlugIn::generateAircraftReportMessage(EuroScopePlugIn::CRadarTarget& radarT
|
|
|
|
|
|
/* set the report time */
|
|
|
std::stringstream stream;
|
|
|
- auto reportTime = std::chrono::utc_clock::now();
|
|
|
+ const auto reportTime = std::chrono::utc_clock::now();
|
|
|
stream << std::format("{0:%Y%m%d%H%M%S}", reportTime);
|
|
|
- report->set_reporttime(String::splitString(stream.str(), ".")[0]);
|
|
|
+ const auto elements = String::splitString(stream.str(), ".");
|
|
|
+ report->set_reporttime(gsl::at(elements, 0));
|
|
|
}
|
|
|
|
|
|
bool PlugIn::OnCompileCommand(const char* cmdline) {
|
|
@@ -435,12 +435,13 @@ void PlugIn::OnGetTagItem(EuroScopePlugIn::CFlightPlan flightPlan, EuroScopePlug
|
|
|
std::transform(destination.begin(), destination.end(), destination.begin(), ::toupper);
|
|
|
#pragma warning(default: 4244)
|
|
|
|
|
|
- bool planExpected, forced;
|
|
|
+ bool planExpected = false, forced = false;
|
|
|
+ const gsl::span<char, 16> tagString(itemString, 16UL);
|
|
|
|
|
|
this->m_updateQueueLock.lock();
|
|
|
|
|
|
/* check if the inbound is forced */
|
|
|
- auto cIt = std::find(this->m_forcedToBackendCallsigns.cbegin(), this->m_forcedToBackendCallsigns.cend(), callsign);
|
|
|
+ const auto cIt = std::find(this->m_forcedToBackendCallsigns.cbegin(), this->m_forcedToBackendCallsigns.cend(), callsign);
|
|
|
forced = this->m_forcedToBackendCallsigns.cend() != cIt;
|
|
|
|
|
|
/* check if the inbound is expected to be planned */
|
|
@@ -475,7 +476,7 @@ void PlugIn::OnGetTagItem(EuroScopePlugIn::CFlightPlan flightPlan, EuroScopePlug
|
|
|
*colorCode = EuroScopePlugIn::TAG_COLOR_DEFAULT;
|
|
|
}
|
|
|
else {
|
|
|
- itemString[0] = '\0';
|
|
|
+ gsl::at(tagString, 0) = '\0';
|
|
|
}
|
|
|
}
|
|
|
else {
|
|
@@ -490,7 +491,7 @@ void PlugIn::OnFunctionCall(int functionId, const char* itemString, POINT pt, RE
|
|
|
std::ignore = pt;
|
|
|
std::ignore = area;
|
|
|
|
|
|
- auto radarTarget = this->RadarTargetSelectASEL();
|
|
|
+ const auto radarTarget = this->RadarTargetSelectASEL();
|
|
|
if (false == radarTarget.IsValid() || false == radarTarget.GetCorrelatedFlightPlan().IsValid())
|
|
|
return;
|
|
|
|