mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-05 17:35:34 +08:00
refs #865, use same function for removing outdated aircraft parts
* in airspace monitor * in XP traffic.cpp
This commit is contained in:
committed by
Mathew Sutcliffe
parent
309d593607
commit
e3d81c6c44
@@ -118,5 +118,11 @@ namespace BlackMisc
|
||||
return this->m_remoteAircraftProvider->updateAircraftEnabled(callsign, enabledForRedering);
|
||||
}
|
||||
|
||||
void IRemoteAircraftProvider::removeOutdatedParts(CAircraftPartsList &partsList)
|
||||
{
|
||||
const auto predicate = [now = partsList.front().getMSecsSinceEpoch()](const auto & p) { return p.getMSecsSinceEpoch() >= now - PartsPerCallsignMaxAgeInSeconds * 1000; };
|
||||
const auto newEnd = std::find_if(partsList.rbegin(), partsList.rend(), predicate).base();
|
||||
partsList.erase(newEnd, partsList.end());
|
||||
}
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
@@ -48,7 +48,7 @@ namespace BlackMisc
|
||||
{
|
||||
public:
|
||||
static constexpr int MaxSituationsPerCallsign = 6; //!< How many situations per callsign
|
||||
static constexpr int PartsPerCallsignMaxAgeInSeconds = 20; //!< How many seconds to keep parts for
|
||||
static constexpr int PartsPerCallsignMaxAgeInSeconds = 20; //!< How many seconds to keep parts for interpolation
|
||||
|
||||
//! Situations per callsign
|
||||
using CSituationsPerCallsign = QHash<BlackMisc::Aviation::CCallsign, BlackMisc::Aviation::CAircraftSituationList>;
|
||||
@@ -165,6 +165,9 @@ namespace BlackMisc
|
||||
std::function<void(const BlackMisc::Aviation::CCallsign &)> removedAircraftSlot,
|
||||
std::function<void(const BlackMisc::Simulation::CAirspaceAircraftSnapshot &)> aircraftSnapshot
|
||||
) = 0;
|
||||
|
||||
//! Remove outdated aircraft parts
|
||||
void static removeOutdatedParts(Aviation::CAircraftPartsList &partsList);
|
||||
};
|
||||
|
||||
//! Class which can be directly used to access an \sa IRemoteAircraftProvider object
|
||||
|
||||
Reference in New Issue
Block a user