mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-05 17:35:34 +08:00
refs #395, improvements for snapshot / restricted aircraft handling
* fixed isCurrentThreadCreatingThread and renamed to isCurrentThreadObjectThread (this check was never working), added 2 more thread checks * changed remove aircraft function to return number of returned aircraft (like with the containers this allows to avoid unnecessary signals) * removed unused function ps_recalculateRenderedAircraft() / SimulatorCommon * using Queued airspaceAircraftSnapshot signal for binding (functor connect does not provide connection type) * extened ASSERTs to check threads * simulator: initial situation function with return value (success?) * simulator: avoid unneccessary copy and provide correct rendered flag in add aircraft function
This commit is contained in:
@@ -23,7 +23,8 @@ namespace BlackMisc
|
||||
const CSimulatedAircraftList &allAircraft,
|
||||
bool restricted, int maxAircraft, const CLength &maxRenderedDistance, const CLength &maxRenderedBoundary) :
|
||||
m_timestampMsSinceEpoch(QDateTime::currentMSecsSinceEpoch()),
|
||||
m_restricted(restricted)
|
||||
m_restricted(restricted),
|
||||
m_threadName(QThread::currentThread()->objectName())
|
||||
{
|
||||
m_renderingEnabled = !restricted || (
|
||||
maxAircraft > 0 &&
|
||||
@@ -38,45 +39,46 @@ namespace BlackMisc
|
||||
m_aircraftCallsignsByDistance = aircraft.getCallsigns();
|
||||
m_vtolAircraftCallsignsByDistance = vtolAircraft.getCallsigns();
|
||||
|
||||
// no restrictions, just find by attributes
|
||||
if (!restricted)
|
||||
{
|
||||
m_enabledAircraftCallsignsByDistance = aircraft.findByEnabled(true).getCallsigns();
|
||||
m_disabledAircraftCallsignsByDistance = aircraft.findByEnabled(false).getCallsigns();
|
||||
m_enabledVtolAircraftCallsignsByDistance = vtolAircraft.findByEnabled(true).getCallsigns();
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
// if no rendering all aircraft are disabled
|
||||
if (!m_renderingEnabled)
|
||||
{
|
||||
m_disabledAircraftCallsignsByDistance = aircraft.getCallsigns();
|
||||
return;
|
||||
}
|
||||
|
||||
int count = 0;
|
||||
for (const CSimulatedAircraft ¤tAircraft : aircraft)
|
||||
// no rendering, this means all aircraft are disabled
|
||||
if (!m_renderingEnabled)
|
||||
{
|
||||
m_disabledAircraftCallsignsByDistance = aircraft.getCallsigns();
|
||||
return;
|
||||
}
|
||||
|
||||
// restricted
|
||||
int count = 0; // when max. aircraft reached?
|
||||
for (const CSimulatedAircraft ¤tAircraft : aircraft)
|
||||
{
|
||||
CCallsign cs(currentAircraft.getCallsign());
|
||||
if (currentAircraft.isEnabled())
|
||||
{
|
||||
CCallsign cs(currentAircraft.getCallsign());
|
||||
if (currentAircraft.isEnabled())
|
||||
{
|
||||
CLength distance(currentAircraft.getDistanceToOwnAircraft());
|
||||
if (count >= maxAircraft ||
|
||||
(!maxRenderedDistance.isNull() && distance >= maxRenderedBoundary) ||
|
||||
(!maxRenderedBoundary.isNull() && distance >= maxRenderedBoundary))
|
||||
{
|
||||
m_disabledAircraftCallsignsByDistance.push_back(cs);
|
||||
}
|
||||
else
|
||||
{
|
||||
count++;
|
||||
m_enabledAircraftCallsignsByDistance.push_back(cs);
|
||||
if (currentAircraft.isVtol()) { m_enabledVtolAircraftCallsignsByDistance.push_back(cs); }
|
||||
}
|
||||
}
|
||||
else
|
||||
CLength distance(currentAircraft.getDistanceToOwnAircraft());
|
||||
if (count >= maxAircraft ||
|
||||
(!maxRenderedDistance.isNull() && distance >= maxRenderedBoundary) ||
|
||||
(!maxRenderedBoundary.isNull() && distance >= maxRenderedBoundary))
|
||||
{
|
||||
m_disabledAircraftCallsignsByDistance.push_back(cs);
|
||||
}
|
||||
else
|
||||
{
|
||||
count++;
|
||||
m_enabledAircraftCallsignsByDistance.push_back(cs);
|
||||
if (currentAircraft.isVtol()) { m_enabledVtolAircraftCallsignsByDistance.push_back(cs); }
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_disabledAircraftCallsignsByDistance.push_back(cs);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user