Skip to content

Commit

Permalink
Discard updates from pilots above 5000ft and distance > 10nm
Browse files Browse the repository at this point in the history
Todo: Replace hardcoded distance with configurable
  • Loading branch information
Herve committed Jan 29, 2025
1 parent c7862e7 commit f279422
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/core/DataManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,14 @@ DataManager::MessageType DataManager::deltaEuroscopeToBackend(const std::array<t
Json::Value& message) {
message.clear();

// Do not push updates to server if simulated update or either of the conditions is met:
// - Above 5000ft
// - More than 10nm away from origin
if (!data[EuroscopeData].isSimulated &&
((data[EuroscopeData].trueAltitude > 5000) || (data[EuroscopeData].distanceFromOrigin > 10.0))) {
return DataManager::MessageType::None;
}

if (data[ServerData].callsign == "" && data[EuroscopeData].callsign != "") {
return DataManager::MessageType::Post;
} else {
Expand Down Expand Up @@ -516,6 +524,9 @@ types::Pilot DataManager::CFlightPlanToPilot(const EuroScopePlugIn::CFlightPlan
// position data
pilot.latitude = flightplan.GetFPTrackPosition().GetPosition().m_Latitude;
pilot.longitude = flightplan.GetFPTrackPosition().GetPosition().m_Longitude;
pilot.trueAltitude = flightplan.GetFPTrackPosition().GetPressureAltitude();
pilot.distanceFromOrigin = flightplan.GetDistanceFromOrigin();
pilot.isSimulated = flightplan.GetSimulated();

// flightplan & clearance data
pilot.origin = flightplan.GetFlightPlanData().GetOrigin();
Expand Down
5 changes: 5 additions & 0 deletions src/types/Pilot.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,12 @@ typedef struct Pilot_t {

double latitude = 0.0;
double longitude = 0.0;

double trueAltitude = 0.0;
double distanceFromOrigin = 0.0;

bool taxizoneIsTaxiout = false;
bool isSimulated = false;

// flightplan & clearance data

Expand Down

0 comments on commit f279422

Please sign in to comment.