mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-14 08:45:36 +08:00
refs #369, changed interpolation to a working (but still too bad performing) version
* using split by callsign everywhere * helper function to insert_front * revised linear interpolator * renamed to remoteAircraft * renamed to container() in providers (gettters are usually copies) Issues why changes did so long: * insert in list is not adding in front, but same as push_back (that was confusing) * naming of values before/after in interpolator was ambigious * QMap keeps values sorted by key, not arbitrarily
This commit is contained in:
@@ -122,7 +122,7 @@ namespace BlackCore
|
||||
{
|
||||
bool s1 = connect(this, &CAirspaceMonitor::addedRemoteAircraftSituation, situationSlot);
|
||||
bool s2 = connect(this, &CAirspaceMonitor::addedRemoteAircraftParts, partsSlot);
|
||||
bool s3 = connect(this, &CAirspaceMonitor::removedAircraft, removedAircraftSlot);
|
||||
bool s3 = connect(this, &CAirspaceMonitor::removedRemoteAircraft, removedAircraftSlot);
|
||||
return s1 && s2 && s3;
|
||||
}
|
||||
|
||||
@@ -487,10 +487,11 @@ namespace BlackCore
|
||||
|
||||
void CAirspaceMonitor::removeAllAircraft()
|
||||
{
|
||||
m_aircraftWatchdog.removeAll();
|
||||
m_aircraftWatchdog.removeAll(); // upfront
|
||||
for (CAircraft aircraft : m_aircraftInRange)
|
||||
{
|
||||
emit removedAircraft(aircraft.getCallsign());
|
||||
const CCallsign cs(aircraft.getCallsign());
|
||||
emit removedRemoteAircraft(cs);
|
||||
}
|
||||
m_aircraftSituations.clear();
|
||||
m_aircraftParts.clear();
|
||||
@@ -562,7 +563,11 @@ namespace BlackCore
|
||||
remoteAircraft.setClient(remoteClient);
|
||||
remoteAircraft.setModel(remoteClient.getAircraftModel());
|
||||
|
||||
bool dataComplete = remoteAircraft.hasValidAircraftDesignator() && remoteAircraft.hasValidRealName();
|
||||
// check if the name and ICAO query went properly through
|
||||
bool dataComplete =
|
||||
remoteAircraft.hasValidAircraftDesignator() &&
|
||||
(!m_serverSupportsNameQuery || remoteAircraft.hasValidRealName());
|
||||
|
||||
if (trial < 3 && !dataComplete)
|
||||
{
|
||||
// allow another period for the client data to arrive, otherwise go ahead
|
||||
@@ -571,7 +576,7 @@ namespace BlackCore
|
||||
}
|
||||
|
||||
Q_ASSERT(remoteAircraft.hasValidAircraftDesignator());
|
||||
Q_ASSERT(remoteAircraft.hasValidRealName());
|
||||
Q_ASSERT(!m_serverSupportsNameQuery || remoteAircraft.hasValidRealName());
|
||||
emit this->readyForModelMatching(remoteAircraft);
|
||||
}
|
||||
|
||||
@@ -816,13 +821,16 @@ namespace BlackCore
|
||||
{
|
||||
Q_ASSERT(BlackCore::isCurrentThreadCreatingThread(this));
|
||||
bool contains = this->m_aircraftInRange.containsCallsign(callsign);
|
||||
|
||||
// if with contains false remove here, in case of inconsistencies
|
||||
this->m_aircraftWatchdog.removeCallsign(callsign);
|
||||
this->m_otherClients.removeByCallsign(callsign);
|
||||
this->removeFromAircraftCaches(callsign);
|
||||
|
||||
if (contains)
|
||||
{
|
||||
this->m_aircraftInRange.removeByCallsign(callsign);
|
||||
this->removeFromAircraftCaches(callsign);
|
||||
emit this->removedAircraft(callsign);
|
||||
emit this->removedRemoteAircraft(callsign);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -36,8 +36,16 @@ namespace BlackCore
|
||||
|
||||
void CAirspaceWatchdog::resetCallsign(const CCallsign &callsign)
|
||||
{
|
||||
Q_ASSERT(m_callsignTimestamps.contains(callsign));
|
||||
m_callsignTimestamps[callsign] = QDateTime::currentDateTimeUtc();
|
||||
if (m_callsignTimestamps.contains(callsign))
|
||||
{
|
||||
m_callsignTimestamps[callsign] = QDateTime::currentDateTimeUtc();
|
||||
}
|
||||
else
|
||||
{
|
||||
// that should rarely happen
|
||||
CLogMessage(this).warning("Watchdog reset for non-existing callsign: %1") << callsign;
|
||||
this->addCallsign(callsign);
|
||||
}
|
||||
}
|
||||
|
||||
void CAirspaceWatchdog::removeCallsign(const CCallsign &callsign)
|
||||
|
||||
@@ -76,7 +76,8 @@ namespace BlackCore
|
||||
connect(this->m_airspace, &CAirspaceMonitor::changedAtcStationsBooked, this, &CContextNetwork::changedAtcStationsBooked);
|
||||
connect(this->m_airspace, &CAirspaceMonitor::changedAtcStationOnlineConnectionStatus, this, &CContextNetwork::changedAtcStationOnlineConnectionStatus);
|
||||
connect(this->m_airspace, &CAirspaceMonitor::changedAircraftInRange, this, &CContextNetwork::changedAircraftInRange);
|
||||
connect(this->m_airspace, &CAirspaceMonitor::removedAircraft, this, &CContextNetwork::removedAircraft);
|
||||
connect(this->m_airspace, &CAirspaceMonitor::removedRemoteAircraft, this, &IContextNetwork::removedAircraft);
|
||||
connect(this->m_airspace, &CAirspaceMonitor::removedRemoteAircraft, this, &CContextNetwork::removedRemoteAircraft);
|
||||
connect(this->m_airspace, &CAirspaceMonitor::readyForModelMatching, this, &CContextNetwork::readyForModelMatching);
|
||||
connect(this->m_airspace, &CAirspaceMonitor::addedRemoteAircraftParts, this, &CContextNetwork::addedRemoteAircraftParts);
|
||||
connect(this->m_airspace, &CAirspaceMonitor::addedRemoteAircraftSituation, this, &CContextNetwork::addedRemoteAircraftSituation);
|
||||
@@ -124,9 +125,9 @@ namespace BlackCore
|
||||
}
|
||||
|
||||
bool CContextNetwork::connectRemoteAircraftProviderSignals(
|
||||
std::function<void (const CAircraftSituation &)> situationSlot,
|
||||
std::function<void (const CAircraftParts &)> partsSlot,
|
||||
std::function<void (const CCallsign &)> removedAircraftSlot)
|
||||
std::function<void (const CAircraftSituation &)> situationSlot,
|
||||
std::function<void (const CAircraftParts &)> partsSlot,
|
||||
std::function<void (const CCallsign &)> removedAircraftSlot)
|
||||
{
|
||||
Q_ASSERT(this->m_airspace);
|
||||
return this->m_airspace->connectRemoteAircraftProviderSignals(situationSlot, partsSlot, removedAircraftSlot);
|
||||
@@ -286,7 +287,7 @@ namespace BlackCore
|
||||
void CContextNetwork::ps_fsdConnectionStatusChanged(INetwork::ConnectionStatus from, INetwork::ConnectionStatus to)
|
||||
{
|
||||
CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << from << to;
|
||||
auto fromOld = this->m_currentStatus;
|
||||
auto fromOld = this->m_currentStatus; // own status cached
|
||||
this->m_currentStatus = to;
|
||||
|
||||
if (fromOld == INetwork::Disconnecting)
|
||||
@@ -296,6 +297,13 @@ namespace BlackCore
|
||||
from = INetwork::Disconnecting;
|
||||
}
|
||||
|
||||
if (to == INetwork::Disconnected)
|
||||
{
|
||||
// make sure airspace is really cleaned up
|
||||
Q_ASSERT(m_airspace);
|
||||
m_airspace->clear();
|
||||
}
|
||||
|
||||
// send 1st position
|
||||
if (to == INetwork::Connected)
|
||||
{
|
||||
|
||||
@@ -80,13 +80,14 @@ namespace BlackCore
|
||||
// must not prefixed virtual (though they are) -> warning
|
||||
|
||||
//! \copydoc IRemoteAircraftProviderReadOnly::addedRemoteAircraftSituation
|
||||
void addedRemoteAircraftSituation(const BlackMisc::Aviation::CAircraftSituation &situation) override;
|
||||
void addedRemoteAircraftSituation(const BlackMisc::Aviation::CAircraftSituation &situation);
|
||||
|
||||
//! \copydoc IRemoteAircraftProviderReadOnly::addedRemoteAircraftPart
|
||||
void addedRemoteAircraftParts(const BlackMisc::Aviation::CAircraftParts &parts) override;
|
||||
void addedRemoteAircraftParts(const BlackMisc::Aviation::CAircraftParts &parts);
|
||||
|
||||
//! \copydoc IRemoteAircraftProviderReadOnly::removedAircraft
|
||||
void removedAircraft(const BlackMisc::Aviation::CCallsign &callsign) override;
|
||||
//! \sa IContextNetwork::removedAircraft() which is the equivalent when using IContextNetwork
|
||||
void removedRemoteAircraft(const BlackMisc::Aviation::CCallsign &callsign);
|
||||
|
||||
public slots:
|
||||
//! \copydoc IContextNetwork::readAtcBookingsFromSource()
|
||||
|
||||
@@ -235,9 +235,9 @@ namespace BlackCore
|
||||
// use readyForModelMatching instead of CAirspaceMonitor::addedAircraft, as it contains client information
|
||||
bool c = connect(networkContext, &IContextNetwork::readyForModelMatching, this, &CContextSimulator::ps_addRemoteAircraft);
|
||||
Q_ASSERT(c);
|
||||
c = connect(networkContext, &IContextNetwork::removedAircraft, this, &CContextSimulator::ps_removeRemoteAircraft);
|
||||
c = connect(networkContext, &IContextNetwork::removedAircraft, this, &CContextSimulator::ps_removedRemoteAircraft);
|
||||
Q_ASSERT(c);
|
||||
c = connect(networkContext, &IContextNetwork::changedRenderedAircraftModel, this->m_simulator, &ISimulator::changeRenderedAircraftModel);
|
||||
c = connect(networkContext, &IContextNetwork::changedRenderedAircraftModel, this->m_simulator, &ISimulator::changeRemoteAircraftModel);
|
||||
Q_ASSERT(c);
|
||||
c = connect(networkContext, &IContextNetwork::changedAircraftEnabled, this->m_simulator, &ISimulator::changeAircraftEnabled);
|
||||
Q_ASSERT(c);
|
||||
@@ -314,11 +314,11 @@ namespace BlackCore
|
||||
this->m_simulator->addRemoteAircraft(remoteAircraft);
|
||||
}
|
||||
|
||||
void CContextSimulator::ps_removeRemoteAircraft(const CCallsign &callsign)
|
||||
void CContextSimulator::ps_removedRemoteAircraft(const CCallsign &callsign)
|
||||
{
|
||||
Q_ASSERT(this->m_simulator);
|
||||
if (!this->m_simulator) return;
|
||||
this->m_simulator->removeRenderedAircraft(callsign);
|
||||
if (!this->m_simulator) { return; }
|
||||
this->m_simulator->removeRemoteAircraft(callsign);
|
||||
}
|
||||
|
||||
void CContextSimulator::ps_onConnectionStatusChanged(ISimulator::ConnectionStatus status)
|
||||
|
||||
@@ -127,7 +127,7 @@ namespace BlackCore
|
||||
void ps_addRemoteAircraft(const BlackMisc::Simulation::CSimulatedAircraft &remoteAircraft);
|
||||
|
||||
//! \copydoc ISimulator::removeRemoteAircraft
|
||||
void ps_removeRemoteAircraft(const BlackMisc::Aviation::CCallsign &callsign);
|
||||
void ps_removedRemoteAircraft(const BlackMisc::Aviation::CCallsign &callsign);
|
||||
|
||||
//! Handle new connection status
|
||||
void ps_onConnectionStatusChanged(ISimulator::ConnectionStatus status);
|
||||
|
||||
@@ -83,10 +83,10 @@ namespace BlackCore
|
||||
virtual bool addRemoteAircraft(const BlackMisc::Simulation::CSimulatedAircraft &remoteAircraft) = 0;
|
||||
|
||||
//! Remove remote aircraft from simulator
|
||||
virtual bool removeRenderedAircraft(const BlackMisc::Aviation::CCallsign &callsign) = 0;
|
||||
virtual bool removeRemoteAircraft(const BlackMisc::Aviation::CCallsign &callsign) = 0;
|
||||
|
||||
//! Change remote aircraft per property
|
||||
virtual bool changeRenderedAircraftModel(const BlackMisc::Simulation::CSimulatedAircraft &aircraft, const QString &originator) = 0;
|
||||
virtual bool changeRemoteAircraftModel(const BlackMisc::Simulation::CSimulatedAircraft &aircraft, const QString &originator) = 0;
|
||||
|
||||
//! Aircraft got enabled / disabled
|
||||
virtual bool changeAircraftEnabled(const BlackMisc::Simulation::CSimulatedAircraft &aircraft, const QString &originator) = 0;
|
||||
|
||||
Reference in New Issue
Block a user