mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-26 10:45:37 +08:00
Ref T632, use rendered and callsign as tie breaker if distance is equal in snapshot
This commit is contained in:
@@ -35,11 +35,11 @@ namespace BlackMisc
|
|||||||
if (allAircraft.isEmpty()) { return; }
|
if (allAircraft.isEmpty()) { return; }
|
||||||
|
|
||||||
CSimulatedAircraftList aircraft(allAircraft);
|
CSimulatedAircraftList aircraft(allAircraft);
|
||||||
aircraft.sortByDistanceToReferencePosition();
|
aircraft.sortByDistanceToReferencePositionRenderedCallsign();
|
||||||
int numberAll = aircraft.size();
|
const int numberAll = aircraft.size();
|
||||||
Q_ASSERT_X(numberAll == allAircraft.size(), Q_FUNC_INFO, "aircraft got lost");
|
Q_ASSERT_X(numberAll == allAircraft.size(), Q_FUNC_INFO, "aircraft got lost");
|
||||||
CSimulatedAircraftList vtolAircraft(aircraft.findByVtol(true));
|
const CSimulatedAircraftList vtolAircraft(aircraft.findByVtol(true));
|
||||||
int numberVtol = vtolAircraft.size();
|
const int numberVtol = vtolAircraft.size();
|
||||||
m_aircraftCallsignsByDistance = aircraft.getCallsigns();
|
m_aircraftCallsignsByDistance = aircraft.getCallsigns();
|
||||||
Q_ASSERT_X(m_aircraftCallsignsByDistance.size() == allAircraft.size(), Q_FUNC_INFO, "redundant or missing callsigns");
|
Q_ASSERT_X(m_aircraftCallsignsByDistance.size() == allAircraft.size(), Q_FUNC_INFO, "redundant or missing callsigns");
|
||||||
m_vtolAircraftCallsignsByDistance = vtolAircraft.getCallsigns();
|
m_vtolAircraftCallsignsByDistance = vtolAircraft.getCallsigns();
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ namespace BlackMisc
|
|||||||
CAirspaceAircraftSnapshot();
|
CAirspaceAircraftSnapshot();
|
||||||
|
|
||||||
//! Constructor
|
//! Constructor
|
||||||
CAirspaceAircraftSnapshot(const BlackMisc::Simulation::CSimulatedAircraftList &allAircraft,
|
CAirspaceAircraftSnapshot(const CSimulatedAircraftList &allAircraft,
|
||||||
bool restricted = false,
|
bool restricted = false,
|
||||||
bool renderingEnabled = true,
|
bool renderingEnabled = true,
|
||||||
int maxAircraft = 100,
|
int maxAircraft = 100,
|
||||||
|
|||||||
@@ -266,5 +266,15 @@ namespace BlackMisc
|
|||||||
}
|
}
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CSimulatedAircraftList::sortByDistanceToReferencePositionRenderedCallsign()
|
||||||
|
{
|
||||||
|
this->sort([ & ](const CSimulatedAircraft & a, const CSimulatedAircraft & b)
|
||||||
|
{
|
||||||
|
if (a.getRelativeDistance() != b.getRelativeDistance()) { return a.getRelativeDistance() < b.getRelativeDistance(); }
|
||||||
|
if (a.isRendered() != b.isRendered()) { return a.isRendered(); } // get the rendered first
|
||||||
|
return a.getCallsignAsString() < b.getCallsignAsString();
|
||||||
|
});
|
||||||
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|||||||
@@ -119,6 +119,9 @@ namespace BlackMisc
|
|||||||
|
|
||||||
//! Number of aircraft with parts
|
//! Number of aircraft with parts
|
||||||
int countAircraftPartsSynchronized() const;
|
int countAircraftPartsSynchronized() const;
|
||||||
|
|
||||||
|
//! Same as sortByDistanceToReferencePosition, but consider callsign and rendered as secondary criteria
|
||||||
|
void sortByDistanceToReferencePositionRenderedCallsign();
|
||||||
};
|
};
|
||||||
|
|
||||||
//! Aircraft per callsign
|
//! Aircraft per callsign
|
||||||
|
|||||||
Reference in New Issue
Block a user