Skip to content
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
25 changes: 23 additions & 2 deletions VFPC/analyzeFP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,10 @@ bool CVFPCPlugin::IsDestinationMatch(const string& destination, const json& rule
return true; // No destination restriction
}
for (const auto& dest : rule["destinations"]) {
if (destination.find(dest.get<string>()) != string::npos) {
if (destination.find(dest.get<string>()) != string::npos) { // Check if wildcard is present
return true;
}
else if (destination.rfind(dest.get<string>().substr(0, dest.get<string>().find("*")), 0) == 0) { // Check if ICAO starts with required prefix
return true;
}
}
Expand Down Expand Up @@ -259,8 +262,26 @@ bool CVFPCPlugin::IsAirwayMatch(const string& route, const json& rule)

string CVFPCPlugin::CheckAltitude(int rfl, const json& rules)
{
// Check allowed flight levels
// Check for time restrictions (ENVAR M750 DADON G581)
rfl = rfl / 100;
if (rules.contains("time")) {

time_t curr_time;
curr_time = time(NULL);
tm* tm_gmt = gmtime(&curr_time);

for (const auto& time : rules["time"]) {
if (tm_gmt->tm_hour >= time["start"].get<int>() && tm_gmt->tm_hour <= time["end"].get<int>()) {
for (const auto& fl : time["unavailableLevels"]) {
if (rfl == stoi(fl.get<string>())) {
return "FLR"; // Level is time restricted
}
}
}
}
}

// Check allowed flight levels
if (rules.contains("allowed_fls")) {
for (const auto& fl : rules["allowed_fls"]) {
if (rfl == stoi(fl.get<string>())) {
Expand Down