mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-30 11:55:35 +08:00
refs #395, turned remote aircraft provider interface into thread safe interfaces
* references gone, situations, parts, aircraft now as threadsafe copy * read only interface gone (no longer references, so no longer needed)
This commit is contained in:
committed by
Mathew Sutcliffe
parent
24094eaf61
commit
6debd33b4f
@@ -108,7 +108,7 @@ namespace BlackSimPlugin
|
||||
|
||||
client->start();
|
||||
m_hashFs9Clients.insert(callsign, client);
|
||||
remoteAircraft().applyIfCallsign(callsign, CPropertyIndexVariantMap(CSimulatedAircraft::IndexRendered, CVariant::fromValue(true)));
|
||||
updateAircraftRendered(callsign, true, this->simulatorOriginator());
|
||||
CLogMessage(this).info("FS9: Added aircraft %1") << callsign.toQString();
|
||||
return true;
|
||||
}
|
||||
@@ -120,7 +120,7 @@ namespace BlackSimPlugin
|
||||
auto fs9Client = m_hashFs9Clients.value(callsign);
|
||||
fs9Client->quit();
|
||||
m_hashFs9Clients.remove(callsign);
|
||||
remoteAircraft().setRendered(callsign, false);
|
||||
updateAircraftRendered(callsign, false, this->simulatorOriginator());
|
||||
CLogMessage(this).info("FS9: Removed aircraft %1") << callsign.toQString();
|
||||
return true;
|
||||
}
|
||||
@@ -336,10 +336,10 @@ namespace BlackSimPlugin
|
||||
}
|
||||
|
||||
BlackCore::ISimulator *CSimulatorFs9Factory::create(
|
||||
const CSimulatorPluginInfo &info,
|
||||
IOwnAircraftProvider *ownAircraftProvider,
|
||||
IRemoteAircraftProvider *remoteAircraftProvider,
|
||||
QObject *parent)
|
||||
const CSimulatorPluginInfo &info,
|
||||
IOwnAircraftProvider *ownAircraftProvider,
|
||||
IRemoteAircraftProvider *remoteAircraftProvider,
|
||||
QObject *parent)
|
||||
{
|
||||
return new CSimulatorFs9(info, ownAircraftProvider, remoteAircraftProvider, parent);
|
||||
}
|
||||
|
||||
@@ -163,9 +163,9 @@ namespace BlackSimPlugin
|
||||
|
||||
// matched models
|
||||
CAircraftModel aircraftModel = modelMatching(newRemoteAircraftCopy);
|
||||
Q_ASSERT(newRemoteAircraft.getCallsign() == aircraftModel.getCallsign());
|
||||
this->providerUpdateAircraftModel(newRemoteAircraft.getCallsign(), aircraftModel, simulatorOriginator());
|
||||
CSimulatedAircraft aircraftAfterModelApplied = remoteAircraft().findFirstByCallsign(newRemoteAircraft.getCallsign());
|
||||
Q_ASSERT_X(newRemoteAircraft.getCallsign() == aircraftModel.getCallsign(), Q_FUNC_INFO, "mismatching callsigns");
|
||||
this->updateAircraftModel(newRemoteAircraft.getCallsign(), aircraftModel, simulatorOriginator());
|
||||
CSimulatedAircraft aircraftAfterModelApplied(getAircraftForCallsign(newRemoteAircraft.getCallsign()));
|
||||
aircraftAfterModelApplied.setRendered(true);
|
||||
emit modelMatchingCompleted(aircraftAfterModelApplied);
|
||||
|
||||
@@ -523,9 +523,10 @@ namespace BlackSimPlugin
|
||||
|
||||
bool CSimulatorFsx::removeRemoteAircraft(const CSimConnectObject &simObject)
|
||||
{
|
||||
m_simConnectObjects.remove(simObject.getCallsign());
|
||||
CCallsign callsign(simObject.getCallsign());
|
||||
m_simConnectObjects.remove(callsign);
|
||||
SimConnect_AIRemoveObject(m_hSimConnect, static_cast<SIMCONNECT_OBJECT_ID>(simObject.getObjectId()), static_cast<SIMCONNECT_DATA_REQUEST_ID>(simObject.getRequestId()));
|
||||
remoteAircraft().setRendered(simObject.getCallsign(), false);
|
||||
updateAircraftRendered(callsign, false, simulatorOriginator());
|
||||
CLogMessage(this).info("FSX: Removed aircraft %1") << simObject.getCallsign().toQString();
|
||||
return true;
|
||||
}
|
||||
@@ -615,7 +616,7 @@ namespace BlackSimPlugin
|
||||
|
||||
// nothing to do, reset request id and exit
|
||||
if (this->isPaused()) { return; } // no interpolation while paused
|
||||
int remoteAircraftNo = this->remoteAircraft().size();
|
||||
int remoteAircraftNo = this->getAircraftInRangeCount();
|
||||
if (remoteAircraftNo < 1) { m_interpolationRequest = 0; return; }
|
||||
|
||||
// interpolate and send to SIM
|
||||
|
||||
@@ -329,7 +329,7 @@ namespace BlackSimPlugin
|
||||
{
|
||||
//! \todo XP implement isRenderedAircraft correctly
|
||||
// work around, but not really telling me if callsign is really(!) visible in SIM
|
||||
return remoteAircraft().findFirstByCallsign(callsign).isRendered();
|
||||
return getAircraftForCallsign(callsign).isRendered();
|
||||
}
|
||||
|
||||
bool CSimulatorXPlane::updateOwnSimulatorCockpit(const BlackMisc::Aviation::CAircraft &aircraft, const QString &originator)
|
||||
@@ -369,7 +369,7 @@ namespace BlackSimPlugin
|
||||
// Is there any model matching required ????
|
||||
CAircraftIcao icao = newRemoteAircraft.getIcaoInfo();
|
||||
m_traffic->addPlane(newRemoteAircraft.getCallsign().asString(), icao.getAircraftDesignator(), icao.getAirlineDesignator(), icao.getLivery());
|
||||
remoteAircraft().applyIfCallsign(newRemoteAircraft.getCallsign(), CPropertyIndexVariantMap(CSimulatedAircraft::IndexRendered, CVariant::fromValue(true)));
|
||||
updateAircraftRendered(newRemoteAircraft.getCallsign(), true, simulatorOriginator());
|
||||
CLogMessage(this).info("XP: Added aircraft %1") << newRemoteAircraft.getCallsign().toQString();
|
||||
return true;
|
||||
}
|
||||
@@ -404,7 +404,7 @@ namespace BlackSimPlugin
|
||||
{
|
||||
Q_ASSERT(isConnected());
|
||||
m_traffic->removePlane(callsign.asString());
|
||||
remoteAircraft().setRendered(callsign, false);
|
||||
updateAircraftRendered(callsign, false, simulatorOriginator());
|
||||
CLogMessage(this).info("XP: Removed aircraft %1") << callsign.toQString();
|
||||
return true;
|
||||
}
|
||||
@@ -412,7 +412,7 @@ namespace BlackSimPlugin
|
||||
void CSimulatorXPlane::removeAllRemoteAircraft()
|
||||
{
|
||||
m_traffic->removeAllPlanes();
|
||||
remoteAircraft().markAllAsNotRendered();
|
||||
updateMarkAllAsNotRendered(simulatorOriginator());
|
||||
CLogMessage(this).info("XP: Removed all aircraft");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user