mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-16 10:25:36 +08:00
refactor: Remove TerrainProbe from msfs2024 code
This commit is contained in:
@@ -549,6 +549,12 @@ namespace swift::core
|
|||||||
if (!this->isConnectedAndNotShuttingDown()) { return; }
|
if (!this->isConnectedAndNotShuttingDown()) { return; }
|
||||||
Q_ASSERT_X(!callsign.isEmpty(), Q_FUNC_INFO, "missing callsign");
|
Q_ASSERT_X(!callsign.isEmpty(), Q_FUNC_INFO, "missing callsign");
|
||||||
|
|
||||||
|
// TODO TZ remove when testing is done
|
||||||
|
CLogMessage(this).info(u"CAirspaceMonitor::sendReadyForModelMatching "
|
||||||
|
u"callsign %1 ")
|
||||||
|
<< callsign;
|
||||||
|
// TODO remove
|
||||||
|
|
||||||
// set flag and init ts
|
// set flag and init ts
|
||||||
Readiness &readiness = this->addMatchingReadinessFlag(callsign, rf);
|
Readiness &readiness = this->addMatchingReadinessFlag(callsign, rf);
|
||||||
|
|
||||||
@@ -769,12 +775,15 @@ namespace swift::core
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// for request
|
||||||
|
// #SBBER750:DAL483:FSIPIR:0:BER:A320:::::L2J:PMDG 737-800 AIRBERLIN (D-ABKM)
|
||||||
|
// and also for information
|
||||||
|
// #SBFSC751 : BER636 : FSIPI : 0 ::EC35:: :: : H2T : AIRBUS H135 NORSK LUFTAMBULANSE
|
||||||
void CAirspaceMonitor::onCustomFSInnPacketReceived(const CCallsign &callsign, const QString &airlineIcaoDesignator,
|
void CAirspaceMonitor::onCustomFSInnPacketReceived(const CCallsign &callsign, const QString &airlineIcaoDesignator,
|
||||||
const QString &aircraftIcaoDesignator,
|
const QString &aircraftIcaoDesignator,
|
||||||
const QString &combinedAircraftType, const QString &modelString)
|
const QString &combinedAircraftType, const QString &modelString)
|
||||||
{
|
{
|
||||||
// TODO TZ remove when testing is done
|
// TODO TZ remove when testing is done
|
||||||
// #SBBER750:DAL483:FSIPIR:0:BER:A320:::::L2J:PMDG 737-800 AIRBERLIN (D-ABKM)
|
|
||||||
CLogMessage(this).info(u"CAirspaceMonitor::onCustomFSInnPacketReceived CHECK:"
|
CLogMessage(this).info(u"CAirspaceMonitor::onCustomFSInnPacketReceived CHECK:"
|
||||||
u"callsign %1 "
|
u"callsign %1 "
|
||||||
u"airlineIcaoDesignator %2 "
|
u"airlineIcaoDesignator %2 "
|
||||||
@@ -853,11 +862,11 @@ namespace swift::core
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// #SBDAL483:BER636:PI:GEN:EQUIPMENT=B738:AIRLINE=DAL:LIVERY=swift_l1855a1787m13853
|
||||||
void CAirspaceMonitor::onIcaoCodesReceived(const CCallsign &callsign, const QString &aircraftIcaoDesignator,
|
void CAirspaceMonitor::onIcaoCodesReceived(const CCallsign &callsign, const QString &aircraftIcaoDesignator,
|
||||||
const QString &airlineIcaoDesignator, const QString &livery)
|
const QString &airlineIcaoDesignator, const QString &livery)
|
||||||
{
|
{
|
||||||
// TODO TZ remove logmessage when testing is done
|
// TODO TZ remove logmessage when testing is done
|
||||||
// #SBDAL483:BER636:PI:GEN:EQUIPMENT=B738:AIRLINE=DAL:LIVERY=swift_l1855a1787m13853
|
|
||||||
CLogMessage(this).info(u"CAirspaceMonitor::onIcaoCodesReceived CHECK:"
|
CLogMessage(this).info(u"CAirspaceMonitor::onIcaoCodesReceived CHECK:"
|
||||||
u"callsign %1 "
|
u"callsign %1 "
|
||||||
u"aircraftIcaoDesignator %2 "
|
u"aircraftIcaoDesignator %2 "
|
||||||
@@ -888,6 +897,8 @@ namespace swift::core
|
|||||||
const CSimulatedAircraft aircraft = this->addOrUpdateAircraftInRange(
|
const CSimulatedAircraft aircraft = this->addOrUpdateAircraftInRange(
|
||||||
callsign, aircraftIcaoDesignator, airlineIcaoDesignator, livery, client.getQueriedModelString(),
|
callsign, aircraftIcaoDesignator, airlineIcaoDesignator, livery, client.getQueriedModelString(),
|
||||||
CAircraftModel::TypeQueriedFromNetwork, pReverseLookupMessages);
|
CAircraftModel::TypeQueriedFromNetwork, pReverseLookupMessages);
|
||||||
|
|
||||||
|
// we do not change manually assigned models
|
||||||
if (aircraft.getModel().getModelType() != CAircraftModel::TypeManuallySet)
|
if (aircraft.getModel().getModelType() != CAircraftModel::TypeManuallySet)
|
||||||
{
|
{
|
||||||
this->addReverseLookupMessages(callsign, reverseLookupMessages);
|
this->addReverseLookupMessages(callsign, reverseLookupMessages);
|
||||||
@@ -1211,6 +1222,7 @@ namespace swift::core
|
|||||||
u"incomming modelType %4 ")
|
u"incomming modelType %4 ")
|
||||||
<< aircraft.getModelType() << callsign.toQString() << aircraftIcao << modelType;
|
<< aircraft.getModelType() << callsign.toQString() << aircraftIcao << modelType;
|
||||||
|
|
||||||
|
// we do not change manually assigned models
|
||||||
if (!aircraft.getModel().hasValidDbKey() && aircraft.getModelType() != CAircraftModel::TypeManuallySet)
|
if (!aircraft.getModel().hasValidDbKey() && aircraft.getModelType() != CAircraftModel::TypeManuallySet)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ namespace swift::simplugin::msfs2024common
|
|||||||
setupProvider, remoteAircraftProvider, logger))
|
setupProvider, remoteAircraftProvider, logger))
|
||||||
{
|
{
|
||||||
this->resetCameraPositions();
|
this->resetCameraPositions();
|
||||||
m_type = aircraft.isTerrainProbe() ? TerrainProbe : AircraftNonAtc;
|
m_type = AircraftNonAtc;
|
||||||
m_interpolator->initCorrespondingModel(aircraft.getModel());
|
m_interpolator->initCorrespondingModel(aircraft.getModel());
|
||||||
m_callsignByteArray = aircraft.getCallsignAsString().toLatin1();
|
m_callsignByteArray = aircraft.getCallsignAsString().toLatin1();
|
||||||
}
|
}
|
||||||
@@ -43,7 +43,7 @@ namespace swift::simplugin::msfs2024common
|
|||||||
{
|
{
|
||||||
m_aircraft = aircraft;
|
m_aircraft = aircraft;
|
||||||
m_callsignByteArray = aircraft.getCallsignAsString().toLatin1();
|
m_callsignByteArray = aircraft.getCallsignAsString().toLatin1();
|
||||||
m_type = aircraft.isTerrainProbe() ? TerrainProbe : AircraftNonAtc;
|
m_type = AircraftNonAtc;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSimConnectObject::setAircraftModelString(const QString &modelString)
|
void CSimConnectObject::setAircraftModelString(const QString &modelString)
|
||||||
@@ -78,7 +78,6 @@ namespace swift::simplugin::msfs2024common
|
|||||||
DWORD os = 0;
|
DWORD os = 0;
|
||||||
switch (this->getType())
|
switch (this->getType())
|
||||||
{
|
{
|
||||||
case TerrainProbe: os = static_cast<DWORD>(CSimulatorMsfs2024::offsetSimObjTerrainProbe(offset)); break;
|
|
||||||
case AircraftNonAtc:
|
case AircraftNonAtc:
|
||||||
case AircraftSimulatedObject:
|
case AircraftSimulatedObject:
|
||||||
default: os = static_cast<DWORD>(CSimulatorMsfs2024::offsetSimObjAircraft(offset)); break;
|
default: os = static_cast<DWORD>(CSimulatorMsfs2024::offsetSimObjAircraft(offset)); break;
|
||||||
@@ -233,7 +232,6 @@ namespace swift::simplugin::msfs2024common
|
|||||||
|
|
||||||
CSimConnectObject::SimObjectType CSimConnectObject::requestIdToType(DWORD requestId)
|
CSimConnectObject::SimObjectType CSimConnectObject::requestIdToType(DWORD requestId)
|
||||||
{
|
{
|
||||||
if (CSimulatorMsfs2024::isRequestForSimObjTerrainProbe(requestId)) { return TerrainProbe; }
|
|
||||||
if (CSimulatorMsfs2024::isRequestForSimObjAircraft(requestId)) { return AircraftNonAtc; }
|
if (CSimulatorMsfs2024::isRequestForSimObjAircraft(requestId)) { return AircraftNonAtc; }
|
||||||
Q_ASSERT_X(false, Q_FUNC_INFO, "Wrong range");
|
Q_ASSERT_X(false, Q_FUNC_INFO, "Wrong range");
|
||||||
return AircraftNonAtc;
|
return AircraftNonAtc;
|
||||||
@@ -243,13 +241,12 @@ namespace swift::simplugin::msfs2024common
|
|||||||
{
|
{
|
||||||
static const QString a1("aircraft (non ATC)");
|
static const QString a1("aircraft (non ATC)");
|
||||||
static const QString a2("aircraft (sim.object)");
|
static const QString a2("aircraft (sim.object)");
|
||||||
static const QString p("probe");
|
// static const QString p("probe");
|
||||||
static const QString u("unknown");
|
static const QString u("unknown");
|
||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
case AircraftNonAtc: return a1;
|
case AircraftNonAtc: return a1;
|
||||||
case AircraftSimulatedObject: return a2;
|
case AircraftSimulatedObject: return a2;
|
||||||
case TerrainProbe: return p;
|
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
return u;
|
return u;
|
||||||
@@ -296,6 +293,7 @@ namespace swift::simplugin::msfs2024common
|
|||||||
return this->getSimObjectForObjectId(objectId).getCallsign();
|
return this->getSimObjectForObjectId(objectId).getCallsign();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO TZ optimize?
|
||||||
CCallsignSet CSimConnectObjects::getAllCallsigns(bool withoutProbes) const
|
CCallsignSet CSimConnectObjects::getAllCallsigns(bool withoutProbes) const
|
||||||
{
|
{
|
||||||
if (this->isEmpty()) { return CCallsignSet(); }
|
if (this->isEmpty()) { return CCallsignSet(); }
|
||||||
@@ -308,6 +306,7 @@ namespace swift::simplugin::msfs2024common
|
|||||||
return callsigns;
|
return callsigns;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO TZ optimize?
|
||||||
QStringList CSimConnectObjects::getAllCallsignStrings(bool sorted, bool withoutProbes) const
|
QStringList CSimConnectObjects::getAllCallsignStrings(bool sorted, bool withoutProbes) const
|
||||||
{
|
{
|
||||||
return this->getAllCallsigns(withoutProbes).getCallsignStrings(sorted);
|
return this->getAllCallsigns(withoutProbes).getCallsignStrings(sorted);
|
||||||
@@ -382,17 +381,17 @@ namespace swift::simplugin::msfs2024common
|
|||||||
return c > 0;
|
return c > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int CSimConnectObjects::removeAllProbes()
|
// int CSimConnectObjects::removeAllProbes()
|
||||||
{
|
//{
|
||||||
const QList<CSimConnectObject> probes = this->getProbes();
|
// const QList<CSimConnectObject> probes = this->getProbes();
|
||||||
int c = 0;
|
// int c = 0;
|
||||||
for (const CSimConnectObject &probe : probes)
|
// for (const CSimConnectObject &probe : probes)
|
||||||
{
|
// {
|
||||||
this->remove(probe.getCallsign());
|
// this->remove(probe.getCallsign());
|
||||||
c++;
|
// c++;
|
||||||
}
|
// }
|
||||||
return c;
|
// return c;
|
||||||
}
|
// }
|
||||||
|
|
||||||
bool CSimConnectObjects::containsPendingAdded() const
|
bool CSimConnectObjects::containsPendingAdded() const
|
||||||
{
|
{
|
||||||
@@ -479,32 +478,6 @@ namespace swift::simplugin::msfs2024common
|
|||||||
return l;
|
return l;
|
||||||
}
|
}
|
||||||
|
|
||||||
CSimConnectObject CSimConnectObjects::getNotPendingProbe() const
|
|
||||||
{
|
|
||||||
for (const CSimConnectObject &simObject : *this)
|
|
||||||
{
|
|
||||||
if (simObject.getType() == CSimConnectObject::TerrainProbe && !simObject.isPending()) { return simObject; }
|
|
||||||
}
|
|
||||||
return CSimConnectObject();
|
|
||||||
}
|
|
||||||
|
|
||||||
CSimConnectObject CSimConnectObjects::getOldestNotPendingProbe() const
|
|
||||||
{
|
|
||||||
CSimConnectObject oldestProbe;
|
|
||||||
for (const CSimConnectObject &simObject : *this)
|
|
||||||
{
|
|
||||||
if (simObject.getType() == CSimConnectObject::TerrainProbe && !simObject.isPending())
|
|
||||||
{
|
|
||||||
if (!oldestProbe.hasCreatedTimestamp() ||
|
|
||||||
oldestProbe.getCreatedTimestamp() > simObject.getCreatedTimestamp())
|
|
||||||
{
|
|
||||||
oldestProbe = simObject;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return oldestProbe;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CSimConnectObjects::containsType(CSimConnectObject::SimObjectType type) const
|
bool CSimConnectObjects::containsType(CSimConnectObject::SimObjectType type) const
|
||||||
{
|
{
|
||||||
for (const CSimConnectObject &simObject : *this)
|
for (const CSimConnectObject &simObject : *this)
|
||||||
|
|||||||
@@ -27,7 +27,6 @@ namespace swift::simplugin::msfs2024common
|
|||||||
{
|
{
|
||||||
AircraftNonAtc,
|
AircraftNonAtc,
|
||||||
AircraftSimulatedObject,
|
AircraftSimulatedObject,
|
||||||
TerrainProbe,
|
|
||||||
AllTypes
|
AllTypes
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -80,9 +79,6 @@ namespace swift::simplugin::msfs2024common
|
|||||||
//! Aircraft NON ATC?
|
//! Aircraft NON ATC?
|
||||||
bool isAircraftNonAtc() const { return this->getType() == AircraftNonAtc; }
|
bool isAircraftNonAtc() const { return this->getType() == AircraftNonAtc; }
|
||||||
|
|
||||||
//! Probe?
|
|
||||||
bool isTerrainProbe() const { return this->getType() == TerrainProbe; }
|
|
||||||
|
|
||||||
//! Set the type
|
//! Set the type
|
||||||
void setType(SimObjectType type) { m_type = type; }
|
void setType(SimObjectType type) { m_type = type; }
|
||||||
|
|
||||||
@@ -424,9 +420,6 @@ namespace swift::simplugin::msfs2024common
|
|||||||
//! Get by type
|
//! Get by type
|
||||||
QList<CSimConnectObject> getByType(CSimConnectObject::SimObjectType type) const;
|
QList<CSimConnectObject> getByType(CSimConnectObject::SimObjectType type) const;
|
||||||
|
|
||||||
//! All probes
|
|
||||||
QList<CSimConnectObject> getProbes() const { return this->getByType(CSimConnectObject::TerrainProbe); }
|
|
||||||
|
|
||||||
//! All aircraft
|
//! All aircraft
|
||||||
QList<CSimConnectObject> getAircraft() const;
|
QList<CSimConnectObject> getAircraft() const;
|
||||||
|
|
||||||
@@ -439,9 +432,6 @@ namespace swift::simplugin::msfs2024common
|
|||||||
//! Contains object of type
|
//! Contains object of type
|
||||||
bool containsType(CSimConnectObject::SimObjectType type) const;
|
bool containsType(CSimConnectObject::SimObjectType type) const;
|
||||||
|
|
||||||
//! Probe?
|
|
||||||
bool containsProbe() const { return this->containsType(CSimConnectObject::TerrainProbe); }
|
|
||||||
|
|
||||||
//! Aircraft?
|
//! Aircraft?
|
||||||
bool containsAircraft() const;
|
bool containsAircraft() const;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -343,34 +343,6 @@ namespace swift::simplugin::msfs2024common
|
|||||||
.arg(m_requestSimObjectDataCount);
|
.arg(m_requestSimObjectDataCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CSimulatorMsfs2024::requestElevation(const ICoordinateGeodetic &reference, const CCallsign &aircraftCallsign)
|
|
||||||
{
|
|
||||||
// this is the 32bit FSX version, the P3D x64 is overridden!
|
|
||||||
|
|
||||||
if (this->isShuttingDownOrDisconnected()) { return false; }
|
|
||||||
if (!this->isUsingFsxTerrainProbe()) { return false; }
|
|
||||||
if (reference.isNull()) { return false; }
|
|
||||||
const CSimConnectObject simObject = m_simConnectObjects.getOldestNotPendingProbe(); // probes round robin
|
|
||||||
if (!simObject.isConfirmedAdded()) { return false; }
|
|
||||||
m_simConnectObjects[simObject.getCallsign()].resetTimestampToNow(); // mark probe as just used
|
|
||||||
|
|
||||||
CCoordinateGeodetic pos(reference);
|
|
||||||
pos.setGeodeticHeight(terrainProbeAltitude());
|
|
||||||
|
|
||||||
SIMCONNECT_DATA_INITPOSITION position = this->coordinateToFsxPosition(pos);
|
|
||||||
const HRESULT hr = this->logAndTraceSendId(
|
|
||||||
SimConnect_SetDataOnSimObject(m_hSimConnect, CSimConnectDefinitions::DataRemoteAircraftSetPosition,
|
|
||||||
simObject.getObjectId(), 0, 0, sizeof(SIMCONNECT_DATA_INITPOSITION),
|
|
||||||
&position),
|
|
||||||
simObject, "Cannot request AI elevation", Q_FUNC_INFO, "SimConnect_SetDataOnSimObject");
|
|
||||||
|
|
||||||
if (isFailure(hr)) { return false; }
|
|
||||||
|
|
||||||
const bool ok = this->requestTerrainProbeData(simObject, aircraftCallsign);
|
|
||||||
if (ok) { emit this->requestedElevation(aircraftCallsign); }
|
|
||||||
return ok;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CSimulatorMsfs2024::CacheSimObjectAndLiveries(const SIMCONNECT_RECV_ENUMERATE_SIMOBJECT_AND_LIVERY_LIST *msg)
|
void CSimulatorMsfs2024::CacheSimObjectAndLiveries(const SIMCONNECT_RECV_ENUMERATE_SIMOBJECT_AND_LIVERY_LIST *msg)
|
||||||
{
|
{
|
||||||
for (unsigned i = 0; i < msg->dwArraySize; ++i)
|
for (unsigned i = 0; i < msg->dwArraySize; ++i)
|
||||||
@@ -722,10 +694,6 @@ namespace swift::simplugin::msfs2024common
|
|||||||
{
|
{
|
||||||
DWORD v = static_cast<DWORD>(CSimConnectDefinitions::SimObjectEndMarker);
|
DWORD v = static_cast<DWORD>(CSimConnectDefinitions::SimObjectEndMarker);
|
||||||
if (isRequestForSimObjAircraft(requestId)) { v = (requestId - RequestSimObjAircraftStart) / MaxSimObjAircraft; }
|
if (isRequestForSimObjAircraft(requestId)) { v = (requestId - RequestSimObjAircraftStart) / MaxSimObjAircraft; }
|
||||||
else if (isRequestForSimObjTerrainProbe(requestId))
|
|
||||||
{
|
|
||||||
v = (requestId - RequestSimObjTerrainProbeStart) / MaxSimObjProbes;
|
|
||||||
}
|
|
||||||
Q_ASSERT_X(v <= CSimConnectDefinitions::SimObjectEndMarker, Q_FUNC_INFO, "Invalid value");
|
Q_ASSERT_X(v <= CSimConnectDefinitions::SimObjectEndMarker, Q_FUNC_INFO, "Invalid value");
|
||||||
return static_cast<CSimConnectDefinitions::SimObjectRequest>(v);
|
return static_cast<CSimConnectDefinitions::SimObjectRequest>(v);
|
||||||
}
|
}
|
||||||
@@ -849,13 +817,6 @@ namespace swift::simplugin::msfs2024common
|
|||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
SIMCONNECT_DATA_REQUEST_ID CSimulatorMsfs2024::obtainRequestIdForSimObjTerrainProbe()
|
|
||||||
{
|
|
||||||
const SIMCONNECT_DATA_REQUEST_ID id = m_requestIdSimObjTerrainProbe++;
|
|
||||||
if (id > RequestSimObjTerrainProbeEnd) { m_requestIdSimObjTerrainProbe = RequestSimObjTerrainProbeStart; }
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CSimulatorMsfs2024::releaseAIControl(const CSimConnectObject &simObject, SIMCONNECT_DATA_REQUEST_ID requestId)
|
bool CSimulatorMsfs2024::releaseAIControl(const CSimConnectObject &simObject, SIMCONNECT_DATA_REQUEST_ID requestId)
|
||||||
{
|
{
|
||||||
const SIMCONNECT_OBJECT_ID objectId = simObject.getObjectId();
|
const SIMCONNECT_OBJECT_ID objectId = simObject.getObjectId();
|
||||||
@@ -1096,15 +1057,10 @@ namespace swift::simplugin::msfs2024common
|
|||||||
}
|
}
|
||||||
else { --m_skipCockpitUpdateCycles; }
|
else { --m_skipCockpitUpdateCycles; }
|
||||||
|
|
||||||
|
// TODO TZ check if we need to update terrain probes
|
||||||
// slower updates
|
// slower updates
|
||||||
if (m_ownAircraftUpdateCycles % 10 == 0)
|
if (m_ownAircraftUpdateCycles % 10 == 0)
|
||||||
{
|
{
|
||||||
// init terrain probes here has the advantage we can also switch it on/off at runtime
|
|
||||||
if (m_useFsxTerrainProbe && !m_initFsxTerrainProbes)
|
|
||||||
{
|
|
||||||
this->physicallyInitAITerrainProbes(position, 2); // init probe
|
|
||||||
}
|
|
||||||
|
|
||||||
// SB3 offsets updating
|
// SB3 offsets updating
|
||||||
m_simulatorInternals.setValue(QStringLiteral("fsx/sb3"), boolToEnabledDisabled(m_useSbOffsets));
|
m_simulatorInternals.setValue(QStringLiteral("fsx/sb3"), boolToEnabledDisabled(m_useSbOffsets));
|
||||||
m_simulatorInternals.setValue(QStringLiteral("fsx/sb3packets"), m_useSbOffsets ?
|
m_simulatorInternals.setValue(QStringLiteral("fsx/sb3packets"), m_useSbOffsets ?
|
||||||
@@ -1297,11 +1253,6 @@ namespace swift::simplugin::msfs2024common
|
|||||||
void CSimulatorMsfs2024::verifyAddedRemoteAircraft(const CSimulatedAircraft &remoteAircraftIn)
|
void CSimulatorMsfs2024::verifyAddedRemoteAircraft(const CSimulatedAircraft &remoteAircraftIn)
|
||||||
{
|
{
|
||||||
if (this->isShuttingDownOrDisconnected()) { return; }
|
if (this->isShuttingDownOrDisconnected()) { return; }
|
||||||
if (remoteAircraftIn.isTerrainProbe())
|
|
||||||
{
|
|
||||||
this->verifyAddedTerrainProbe(remoteAircraftIn);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
CStatusMessage msg;
|
CStatusMessage msg;
|
||||||
CSimulatedAircraft remoteAircraft = remoteAircraftIn;
|
CSimulatedAircraft remoteAircraft = remoteAircraftIn;
|
||||||
@@ -1524,36 +1475,6 @@ namespace swift::simplugin::msfs2024common
|
|||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSimulatorMsfs2024::verifyAddedTerrainProbe(const CSimulatedAircraft &remoteAircraftIn)
|
|
||||||
{
|
|
||||||
bool verified = false;
|
|
||||||
CCallsign cs;
|
|
||||||
|
|
||||||
// no simObject reference outside that block, because it will be deleted
|
|
||||||
{
|
|
||||||
CSimConnectObject &simObject = m_simConnectObjects[remoteAircraftIn.getCallsign()];
|
|
||||||
simObject.setConfirmedAdded(true); // terrain probe
|
|
||||||
simObject.resetTimestampToNow();
|
|
||||||
cs = simObject.getCallsign();
|
|
||||||
CLogMessage(this).info(u"Probe: '%1' '%2' confirmed, %3")
|
|
||||||
<< simObject.getCallsignAsString() << simObject.getAircraftModelString() << simObject.toQString();
|
|
||||||
|
|
||||||
// fails for probe
|
|
||||||
// SIMCONNECT_DATA_REQUEST_ID requestId = this->obtainRequestIdForSimObjTerrainProbe();
|
|
||||||
// verified = this->releaseAIControl(simObject, requestId); // release probe
|
|
||||||
verified = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!verified) // cppcheck-suppress knownConditionTrueFalse
|
|
||||||
{
|
|
||||||
CLogMessage(this).info(u"Disable probes: '%1' failed to relase control") << cs.asString();
|
|
||||||
m_useFsxTerrainProbe = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// trigger new adding from pending if any
|
|
||||||
if (!m_addPendingAircraft.isEmpty()) { this->addPendingAircraftAfterAdded(); }
|
|
||||||
}
|
|
||||||
|
|
||||||
void CSimulatorMsfs2024::timerBasedObjectAddOrRemove()
|
void CSimulatorMsfs2024::timerBasedObjectAddOrRemove()
|
||||||
{
|
{
|
||||||
this->addPendingAircraft(AddByTimer);
|
this->addPendingAircraft(AddByTimer);
|
||||||
@@ -1576,10 +1497,6 @@ namespace swift::simplugin::msfs2024common
|
|||||||
{
|
{
|
||||||
SWIFT_VERIFY_X(pendingSimObj.hasCallsign(), Q_FUNC_INFO, "missing callsign");
|
SWIFT_VERIFY_X(pendingSimObj.hasCallsign(), Q_FUNC_INFO, "missing callsign");
|
||||||
if (!pendingSimObj.hasCallsign()) { continue; }
|
if (!pendingSimObj.hasCallsign()) { continue; }
|
||||||
if (pendingSimObj.isTerrainProbe() || aircraftCallsignsInRange.contains(pendingSimObj.getCallsign()))
|
|
||||||
{
|
|
||||||
toBeAddedAircraft.push_back(pendingSimObj.getAircraft());
|
|
||||||
}
|
|
||||||
else { toBeRemovedCallsigns.push_back(pendingSimObj.getCallsign()); }
|
else { toBeRemovedCallsigns.push_back(pendingSimObj.getCallsign()); }
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1597,7 +1514,6 @@ namespace swift::simplugin::msfs2024common
|
|||||||
const QPointer<CSimulatorMsfs2024> myself(this);
|
const QPointer<CSimulatorMsfs2024> myself(this);
|
||||||
QTimer::singleShot(100, this, [=] {
|
QTimer::singleShot(100, this, [=] {
|
||||||
if (!myself) { return; }
|
if (!myself) { return; }
|
||||||
if (this->isShuttingDownDisconnectedOrNoAircraft(nextPendingAircraft.isTerrainProbe())) { return; }
|
|
||||||
this->physicallyAddRemoteAircraftImpl(nextPendingAircraft, mode, oldestSimObject);
|
this->physicallyAddRemoteAircraftImpl(nextPendingAircraft, mode, oldestSimObject);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -1780,12 +1696,12 @@ namespace swift::simplugin::msfs2024common
|
|||||||
CSimpleCommandParser::registerCommand({ ".drv sblog on|off", "SB offsets logging on|off" });
|
CSimpleCommandParser::registerCommand({ ".drv sblog on|off", "SB offsets logging on|off" });
|
||||||
}
|
}
|
||||||
|
|
||||||
CCallsign CSimulatorMsfs2024::getCallsignForPendingProbeRequests(DWORD requestId, bool remove)
|
// CCallsign CSimulatorMsfs2024::getCallsignForPendingProbeRequests(DWORD requestId, bool remove)
|
||||||
{
|
//{
|
||||||
const CCallsign cs = m_pendingProbeRequests.value(requestId);
|
// const CCallsign cs = m_pendingProbeRequests.value(requestId);
|
||||||
if (remove) { m_pendingProbeRequests.remove(requestId); }
|
// if (remove) { m_pendingProbeRequests.remove(requestId); }
|
||||||
return cs;
|
// return cs;
|
||||||
}
|
// }
|
||||||
|
|
||||||
const QString &CSimulatorMsfs2024::modeToString(CSimulatorMsfs2024::AircraftAddMode mode)
|
const QString &CSimulatorMsfs2024::modeToString(CSimulatorMsfs2024::AircraftAddMode mode)
|
||||||
{
|
{
|
||||||
@@ -1870,7 +1786,6 @@ namespace swift::simplugin::msfs2024common
|
|||||||
const CSimConnectObject &correspondingSimObject)
|
const CSimConnectObject &correspondingSimObject)
|
||||||
{
|
{
|
||||||
const CCallsign callsign(newRemoteAircraft.getCallsign());
|
const CCallsign callsign(newRemoteAircraft.getCallsign());
|
||||||
const bool probe = newRemoteAircraft.isTerrainProbe();
|
|
||||||
|
|
||||||
// entry checks
|
// entry checks
|
||||||
Q_ASSERT_X(CThreadUtils::isInThisThread(this), Q_FUNC_INFO, "thread");
|
Q_ASSERT_X(CThreadUtils::isInThisThread(this), Q_FUNC_INFO, "thread");
|
||||||
@@ -1996,7 +1911,8 @@ namespace swift::simplugin::msfs2024common
|
|||||||
const CSimConnectObject removedPendingObj = this->removeFromAddPendingAndAddAgainAircraft(callsign);
|
const CSimConnectObject removedPendingObj = this->removeFromAddPendingAndAddAgainAircraft(callsign);
|
||||||
|
|
||||||
// create AI after crosschecking it
|
// create AI after crosschecking it
|
||||||
if (!probe && !this->isAircraftInRangeOrTestMode(callsign))
|
// if (!probe && !this->isAircraftInRangeOrTestMode(callsign))
|
||||||
|
if (!this->isAircraftInRangeOrTestMode(callsign))
|
||||||
{
|
{
|
||||||
CLogMessage(this).info(u"Skipping adding of '%1' since it is no longer in range") << callsign.asString();
|
CLogMessage(this).info(u"Skipping adding of '%1' since it is no longer in range") << callsign.asString();
|
||||||
return false;
|
return false;
|
||||||
@@ -2007,10 +1923,8 @@ namespace swift::simplugin::msfs2024common
|
|||||||
this->getInterpolationSetupConsolidated(callsign, true);
|
this->getInterpolationSetupConsolidated(callsign, true);
|
||||||
const bool sendGround = setup.isSendingGndFlagToSimulator();
|
const bool sendGround = setup.isSendingGndFlagToSimulator();
|
||||||
|
|
||||||
// FSX/P3D adding
|
|
||||||
bool adding = false; // will be added flag
|
bool adding = false; // will be added flag
|
||||||
const SIMCONNECT_DATA_REQUEST_ID requestId =
|
const SIMCONNECT_DATA_REQUEST_ID requestId = this->obtainRequestIdForSimObjAircraft();
|
||||||
probe ? this->obtainRequestIdForSimObjTerrainProbe() : this->obtainRequestIdForSimObjAircraft();
|
|
||||||
|
|
||||||
// Initial situation, if possible from interpolation
|
// Initial situation, if possible from interpolation
|
||||||
CAircraftSituation initialSituation = newRemoteAircraft.getSituation(); // default
|
CAircraftSituation initialSituation = newRemoteAircraft.getSituation(); // default
|
||||||
@@ -2045,43 +1959,31 @@ namespace swift::simplugin::msfs2024common
|
|||||||
|
|
||||||
const QByteArray modelStringBa = toFsxChar(modelString).trimmed();
|
const QByteArray modelStringBa = toFsxChar(modelString).trimmed();
|
||||||
const QByteArray modelLiveryBa = toFsxChar(modelLiveryString).trimmed();
|
const QByteArray modelLiveryBa = toFsxChar(modelLiveryString).trimmed();
|
||||||
|
|
||||||
const QByteArray csBa = toFsxChar(callsign.toQString().left(12));
|
const QByteArray csBa = toFsxChar(callsign.toQString().left(12));
|
||||||
CSimConnectObject::SimObjectType type = CSimConnectObject::AircraftNonAtc;
|
CSimConnectObject::SimObjectType type = CSimConnectObject::AircraftNonAtc;
|
||||||
HRESULT hr = S_OK;
|
HRESULT hr = S_OK;
|
||||||
|
|
||||||
if (probe)
|
if (this->isAddingAsSimulatedObjectEnabled() && correspondingSimObject.hasCallsign() &&
|
||||||
|
correspondingSimObject.getAddingExceptions() > 0 &&
|
||||||
|
correspondingSimObject.getType() == CSimConnectObject::AircraftNonAtc)
|
||||||
|
{
|
||||||
|
CStatusMessage(this).warning(
|
||||||
|
u"Model '%1' for '%2' failed %1 time(s) before, using AICreateSimulatedObject now")
|
||||||
|
<< newRemoteAircraft.getModelString() << callsign.toQString();
|
||||||
|
|
||||||
|
hr = SimConnect_AICreateNonATCAircraft_EX1(m_hSimConnect, modelStringBa.constData(),
|
||||||
|
modelLiveryBa.constData(), csBa.constData(), initialPosition,
|
||||||
|
requestId);
|
||||||
|
|
||||||
|
type = CSimConnectObject::AircraftSimulatedObject;
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
hr = SimConnect_AICreateNonATCAircraft_EX1(m_hSimConnect, modelStringBa.constData(),
|
hr = SimConnect_AICreateNonATCAircraft_EX1(m_hSimConnect, modelStringBa.constData(),
|
||||||
modelLiveryBa.constData(), csBa.constData(), initialPosition,
|
modelLiveryBa.constData(), csBa.constData(), initialPosition,
|
||||||
requestId);
|
requestId);
|
||||||
|
|
||||||
type = CSimConnectObject::TerrainProbe;
|
type = CSimConnectObject::AircraftNonAtc;
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (this->isAddingAsSimulatedObjectEnabled() && correspondingSimObject.hasCallsign() &&
|
|
||||||
correspondingSimObject.getAddingExceptions() > 0 &&
|
|
||||||
correspondingSimObject.getType() == CSimConnectObject::AircraftNonAtc)
|
|
||||||
{
|
|
||||||
CStatusMessage(this).warning(
|
|
||||||
u"Model '%1' for '%2' failed %1 time(s) before, using AICreateSimulatedObject now")
|
|
||||||
<< newRemoteAircraft.getModelString() << callsign.toQString();
|
|
||||||
|
|
||||||
hr = SimConnect_AICreateNonATCAircraft_EX1(m_hSimConnect, modelStringBa.constData(),
|
|
||||||
modelLiveryBa.constData(), csBa.constData(), initialPosition,
|
|
||||||
requestId);
|
|
||||||
|
|
||||||
type = CSimConnectObject::AircraftSimulatedObject;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
hr = SimConnect_AICreateNonATCAircraft_EX1(m_hSimConnect, modelStringBa.constData(),
|
|
||||||
modelLiveryBa.constData(), csBa.constData(), initialPosition,
|
|
||||||
requestId);
|
|
||||||
|
|
||||||
type = CSimConnectObject::AircraftNonAtc;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!underflowStatus.isEmpty())
|
if (!underflowStatus.isEmpty())
|
||||||
@@ -2110,52 +2012,6 @@ namespace swift::simplugin::msfs2024common
|
|||||||
return adding;
|
return adding;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CSimulatorMsfs2024::physicallyAddAITerrainProbe(const ICoordinateGeodetic &coordinate, int number)
|
|
||||||
{
|
|
||||||
if (coordinate.isNull()) { return false; }
|
|
||||||
if (!this->isUsingFsxTerrainProbe()) { return false; }
|
|
||||||
Q_ASSERT_X(CThreadUtils::isInThisThread(this), Q_FUNC_INFO, "thread");
|
|
||||||
|
|
||||||
// static const QString modelString("OrcaWhale");
|
|
||||||
// static const QString modelString("Water Drop"); // not working on P3Dx86/FSX, no requests on that id
|
|
||||||
// possible static const QString modelString("A321ACA"); static const QString
|
|
||||||
// modelString("AI_Tracker_Object_0"); static const QString modelString("Piper Cub"); // P3Dv86 works as
|
|
||||||
// nonATC/SimulatedObject static const QString modelString("Discovery Spaceshuttle"); // P3Dx86 works as
|
|
||||||
// nonATC/SimulatedObject
|
|
||||||
static const QString modelString("swiftTerrainProbe0");
|
|
||||||
static const QString pseudoCallsign("PROBE%1"); // max 12 chars
|
|
||||||
static const CCountry ctry("SW", "SWIFT");
|
|
||||||
static const CAirlineIcaoCode swiftAirline("SWI", "swift probe", ctry, "SWIFT", false, false);
|
|
||||||
static const CLivery swiftLivery(CLivery::getStandardCode(swiftAirline), swiftAirline, "swift probe");
|
|
||||||
|
|
||||||
const CCallsign cs(pseudoCallsign.arg(number));
|
|
||||||
const CAircraftModel model(modelString, CAircraftModel::TypeTerrainProbe, QStringLiteral("swift terrain probe"),
|
|
||||||
CAircraftIcaoCode::unassignedIcao(), swiftLivery);
|
|
||||||
CAircraftSituation situation(cs, coordinate);
|
|
||||||
situation.setAltitude(terrainProbeAltitude());
|
|
||||||
situation.setZeroPBH();
|
|
||||||
const CSimulatedAircraft pseudoAircraft(cs, model, CUser("123456", "swift", cs), situation);
|
|
||||||
return this->physicallyAddRemoteAircraftImpl(pseudoAircraft, ExternalCall);
|
|
||||||
}
|
|
||||||
|
|
||||||
int CSimulatorMsfs2024::physicallyInitAITerrainProbes(const ICoordinateGeodetic &coordinate, int number)
|
|
||||||
{
|
|
||||||
if (number < 1) { return 0; }
|
|
||||||
if (m_initFsxTerrainProbes) { return m_addedProbes; }
|
|
||||||
m_initFsxTerrainProbes = true; // no multiple inits
|
|
||||||
this->triggerAutoTraceSendId();
|
|
||||||
|
|
||||||
int c = 0;
|
|
||||||
for (int n = 0; n < number; ++n)
|
|
||||||
{
|
|
||||||
if (this->physicallyAddAITerrainProbe(coordinate, n)) { c++; }
|
|
||||||
}
|
|
||||||
|
|
||||||
CLogMessage(this).info(u"Adding %1 FSX terrain probes") << number;
|
|
||||||
m_addedProbes = c;
|
|
||||||
return c;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CSimulatorMsfs2024::physicallyRemoveRemoteAircraft(const CCallsign &callsign)
|
bool CSimulatorMsfs2024::physicallyRemoveRemoteAircraft(const CCallsign &callsign)
|
||||||
{
|
{
|
||||||
// only remove from sim
|
// only remove from sim
|
||||||
@@ -2169,7 +2025,6 @@ namespace swift::simplugin::msfs2024common
|
|||||||
if (!m_simConnectObjects.contains(callsign)) { return false; } // already fully removed or not yet added
|
if (!m_simConnectObjects.contains(callsign)) { return false; } // already fully removed or not yet added
|
||||||
CSimConnectObject &simObject = m_simConnectObjects[callsign];
|
CSimConnectObject &simObject = m_simConnectObjects[callsign];
|
||||||
if (simObject.isPendingRemoved()) { return true; }
|
if (simObject.isPendingRemoved()) { return true; }
|
||||||
if (simObject.isTerrainProbe()) { return false; }
|
|
||||||
|
|
||||||
// check for pending objects
|
// check for pending objects
|
||||||
m_addPendingAircraft.remove(callsign); // just in case still in list of pending aircraft
|
m_addPendingAircraft.remove(callsign); // just in case still in list of pending aircraft
|
||||||
@@ -2543,8 +2398,7 @@ namespace swift::simplugin::msfs2024common
|
|||||||
bool CSimulatorMsfs2024::sendRemoteAircraftAtcDataToSimulator(const CSimConnectObject &simObject)
|
bool CSimulatorMsfs2024::sendRemoteAircraftAtcDataToSimulator(const CSimConnectObject &simObject)
|
||||||
{
|
{
|
||||||
if (!simObject.isReadyToSend()) { return false; }
|
if (!simObject.isReadyToSend()) { return false; }
|
||||||
if (simObject.isTerrainProbe()) { return false; }
|
if (simObject.getType() != CSimConnectObject::AircraftNonAtc) { return false; } // otherwise errors
|
||||||
// if (simObject.getType() != CSimConnectObject::AircraftNonAtc) { return false; } // otherwise errors
|
|
||||||
|
|
||||||
const DWORD objectId = simObject.getObjectId();
|
const DWORD objectId = simObject.getObjectId();
|
||||||
const bool traceId = this->isTracingSendId();
|
const bool traceId = this->isTracingSendId();
|
||||||
@@ -2813,23 +2667,6 @@ namespace swift::simplugin::msfs2024common
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CSimulatorMsfs2024::requestTerrainProbeData(const CSimConnectObject &simObject,
|
|
||||||
const CCallsign &aircraftCallsign)
|
|
||||||
{
|
|
||||||
static const QString w("Cannot request terrain probe data for id '%1'");
|
|
||||||
const SIMCONNECT_DATA_REQUEST_ID requestId =
|
|
||||||
simObject.getRequestId(CSimConnectDefinitions::SimObjectPositionData);
|
|
||||||
const DWORD objectId = simObject.getObjectId();
|
|
||||||
const HRESULT result = this->logAndTraceSendId(
|
|
||||||
SimConnect_RequestDataOnSimObject(m_hSimConnect, static_cast<SIMCONNECT_DATA_REQUEST_ID>(requestId),
|
|
||||||
CSimConnectDefinitions::DataRemoteAircraftGetPosition,
|
|
||||||
static_cast<SIMCONNECT_OBJECT_ID>(objectId), SIMCONNECT_PERIOD_ONCE),
|
|
||||||
simObject, w.arg(requestId), Q_FUNC_INFO, "SimConnect_RequestDataOnSimObject");
|
|
||||||
const bool ok = isOk(result);
|
|
||||||
if (ok) { m_pendingProbeRequests.insert(requestId, aircraftCallsign); }
|
|
||||||
return ok;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CSimulatorMsfs2024::requestLightsForSimObject(const CSimConnectObject &simObject)
|
bool CSimulatorMsfs2024::requestLightsForSimObject(const CSimConnectObject &simObject)
|
||||||
{
|
{
|
||||||
if (!this->isValidSimObjectNotPendingRemoved(simObject)) { return false; }
|
if (!this->isValidSimObjectNotPendingRemoved(simObject)) { return false; }
|
||||||
@@ -2908,33 +2745,16 @@ namespace swift::simplugin::msfs2024common
|
|||||||
m_requestIdSimObjAircraft = static_cast<SIMCONNECT_DATA_REQUEST_ID>(RequestSimObjAircraftStart);
|
m_requestIdSimObjAircraft = static_cast<SIMCONNECT_DATA_REQUEST_ID>(RequestSimObjAircraftStart);
|
||||||
m_dispatchErrors = 0;
|
m_dispatchErrors = 0;
|
||||||
m_receiveExceptionCount = 0;
|
m_receiveExceptionCount = 0;
|
||||||
m_addedProbes = 0;
|
|
||||||
m_initFsxTerrainProbes = false;
|
|
||||||
m_sendIdTraces.clear();
|
m_sendIdTraces.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSimulatorMsfs2024::clearAllRemoteAircraftData()
|
void CSimulatorMsfs2024::clearAllRemoteAircraftData()
|
||||||
{
|
{
|
||||||
const bool reinitProbe =
|
|
||||||
m_useFsxTerrainProbe && m_initFsxTerrainProbes; // re-init if enabled and was initialized
|
|
||||||
this->removeAllProbes();
|
|
||||||
|
|
||||||
// m_addAgainAircraftWhenRemoved cleared below
|
// m_addAgainAircraftWhenRemoved cleared below
|
||||||
CSimulatorFsCommon::clearAllRemoteAircraftData(); // also removes aircraft
|
CSimulatorFsCommon::clearAllRemoteAircraftData(); // also removes aircraft
|
||||||
m_simConnectObjects.clear();
|
m_simConnectObjects.clear();
|
||||||
m_addPendingAircraft.clear();
|
m_addPendingAircraft.clear();
|
||||||
m_simConnectObjectsPositionAndPartsTraces.clear();
|
m_simConnectObjectsPositionAndPartsTraces.clear();
|
||||||
|
|
||||||
if (reinitProbe)
|
|
||||||
{
|
|
||||||
// if we are still alive we re-init the probes
|
|
||||||
QPointer<CSimulatorMsfs2024> myself(this);
|
|
||||||
QTimer::singleShot(2000, this, [=] {
|
|
||||||
// Shutdown or unloaded
|
|
||||||
if (this->isShuttingDown() || !myself) { return; }
|
|
||||||
m_initFsxTerrainProbes = false; // probes will re-init
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSimulatorMsfs2024::onOwnModelChanged(const CAircraftModel &newModel)
|
void CSimulatorMsfs2024::onOwnModelChanged(const CAircraftModel &newModel)
|
||||||
@@ -3033,29 +2853,30 @@ namespace swift::simplugin::msfs2024common
|
|||||||
return d.arg(trace.sendId).arg(simObject.getObjectId()).arg(simObject.toQString(), trace.comment);
|
return d.arg(trace.sendId).arg(simObject.getObjectId()).arg(simObject.toQString(), trace.comment);
|
||||||
}
|
}
|
||||||
|
|
||||||
int CSimulatorMsfs2024::removeAllProbes()
|
// int CSimulatorMsfs2024::removeAllProbes()
|
||||||
{
|
//{
|
||||||
if (!m_hSimConnect) { return 0; } // already disconnected
|
// if (!m_hSimConnect) { return 0; } // already disconnected
|
||||||
const QList<CSimConnectObject> probes = m_simConnectObjects.getProbes();
|
// const QList<CSimConnectObject> probes = m_simConnectObjects.getProbes();
|
||||||
|
|
||||||
int c = 0;
|
// int c = 0;
|
||||||
for (const CSimConnectObject &probeSimObject : probes)
|
// for (const CSimConnectObject &probeSimObject : probes)
|
||||||
{
|
// {
|
||||||
if (!probeSimObject.isConfirmedAdded()) { continue; }
|
// if (!probeSimObject.isConfirmedAdded()) { continue; }
|
||||||
const SIMCONNECT_DATA_REQUEST_ID requestId =
|
// const SIMCONNECT_DATA_REQUEST_ID requestId =
|
||||||
probeSimObject.getRequestId(CSimConnectDefinitions::SimObjectRemove);
|
// probeSimObject.getRequestId(CSimConnectDefinitions::SimObjectRemove);
|
||||||
const HRESULT result = SimConnect_AIRemoveObject(
|
// const HRESULT result = SimConnect_AIRemoveObject(
|
||||||
m_hSimConnect, static_cast<SIMCONNECT_OBJECT_ID>(probeSimObject.getObjectId()), requestId);
|
// m_hSimConnect, static_cast<SIMCONNECT_OBJECT_ID>(probeSimObject.getObjectId()), requestId);
|
||||||
if (isOk(result)) { c++; }
|
// if (isOk(result)) { c++; }
|
||||||
else
|
// else
|
||||||
{
|
// {
|
||||||
CLogMessage(this).warning(u"Removing probe '%1' from simulator failed") << probeSimObject.getObjectId();
|
// CLogMessage(this).warning(u"Removing probe '%1' from simulator failed") <<
|
||||||
}
|
// probeSimObject.getObjectId();
|
||||||
}
|
// }
|
||||||
m_simConnectObjects.removeAllProbes();
|
// }
|
||||||
m_pendingProbeRequests.clear();
|
// m_simConnectObjects.removeAllProbes();
|
||||||
return c;
|
// m_pendingProbeRequests.clear();
|
||||||
}
|
// return c;
|
||||||
|
//}
|
||||||
|
|
||||||
CSimConnectObject CSimulatorMsfs2024::insertNewSimConnectObject(const CSimulatedAircraft &aircraft, DWORD requestId,
|
CSimConnectObject CSimulatorMsfs2024::insertNewSimConnectObject(const CSimulatedAircraft &aircraft, DWORD requestId,
|
||||||
CSimConnectObject::SimObjectType type,
|
CSimConnectObject::SimObjectType type,
|
||||||
@@ -3092,11 +2913,11 @@ namespace swift::simplugin::msfs2024common
|
|||||||
return simObject;
|
return simObject;
|
||||||
}
|
}
|
||||||
|
|
||||||
const CAltitude &CSimulatorMsfs2024::terrainProbeAltitude()
|
// const CAltitude &CSimulatorMsfs2024::terrainProbeAltitude()
|
||||||
{
|
//{
|
||||||
static const CAltitude alt(50000, CLengthUnit::ft());
|
// static const CAltitude alt(50000, CLengthUnit::ft());
|
||||||
return alt;
|
// return alt;
|
||||||
}
|
// }
|
||||||
|
|
||||||
QString CSimulatorMsfs2024::fsxCharToQString(const char *fsxChar, int size)
|
QString CSimulatorMsfs2024::fsxCharToQString(const char *fsxChar, int size)
|
||||||
{
|
{
|
||||||
@@ -3125,10 +2946,6 @@ namespace swift::simplugin::msfs2024common
|
|||||||
int end;
|
int end;
|
||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
case CSimConnectObject::TerrainProbe:
|
|
||||||
start = RequestSimObjTerrainProbeStart;
|
|
||||||
end = RequestSimObjTerrainProbeEnd;
|
|
||||||
break;
|
|
||||||
case CSimConnectObject::AircraftNonAtc:
|
case CSimConnectObject::AircraftNonAtc:
|
||||||
case CSimConnectObject::AircraftSimulatedObject:
|
case CSimConnectObject::AircraftSimulatedObject:
|
||||||
default:
|
default:
|
||||||
|
|||||||
@@ -105,9 +105,6 @@ namespace swift::simplugin::msfs2024common
|
|||||||
CSimConnectObject simObject; //!< CSimConnectObject at the time of the trace
|
CSimConnectObject simObject; //!< CSimConnectObject at the time of the trace
|
||||||
QString comment; //!< where sent
|
QString comment; //!< where sent
|
||||||
|
|
||||||
//! For probe
|
|
||||||
bool isForProbe() const { return simObject.getType() == CSimConnectObject::TerrainProbe; }
|
|
||||||
|
|
||||||
//! For aircraft
|
//! For aircraft
|
||||||
bool isForAircraft() const { return simObject.getType() == CSimConnectObject::AircraftNonAtc; }
|
bool isForAircraft() const { return simObject.getType() == CSimConnectObject::AircraftNonAtc; }
|
||||||
|
|
||||||
@@ -187,11 +184,11 @@ namespace swift::simplugin::msfs2024common
|
|||||||
const swift::misc::aviation::CAircraftParts &parts) override;
|
const swift::misc::aviation::CAircraftParts &parts) override;
|
||||||
//! @}
|
//! @}
|
||||||
|
|
||||||
//! \copydoc swift::misc::simulation::ISimulationEnvironmentProvider::requestElevation
|
////! \copydoc swift::misc::simulation::ISimulationEnvironmentProvider::requestElevation
|
||||||
//! \remark x86 FSX version, x64 version is overridden
|
////! \remark x86 FSX version, x64 version is overridden
|
||||||
//! \sa CSimulatorFsxCommon::is
|
////! \sa CSimulatorFsxCommon::is
|
||||||
virtual bool requestElevation(const swift::misc::geo::ICoordinateGeodetic &reference,
|
// virtual bool requestElevation(const swift::misc::geo::ICoordinateGeodetic &reference,
|
||||||
const swift::misc::aviation::CCallsign &aircraftCallsign) override;
|
// const swift::misc::aviation::CCallsign &aircraftCallsign) override;
|
||||||
|
|
||||||
//! saves the SimObjects received from the simulator a structure
|
//! saves the SimObjects received from the simulator a structure
|
||||||
void CacheSimObjectAndLiveries(const SIMCONNECT_RECV_ENUMERATE_SIMOBJECT_AND_LIVERY_LIST *msg);
|
void CacheSimObjectAndLiveries(const SIMCONNECT_RECV_ENUMERATE_SIMOBJECT_AND_LIVERY_LIST *msg);
|
||||||
@@ -214,13 +211,6 @@ namespace swift::simplugin::msfs2024common
|
|||||||
//! Set tracing on/off
|
//! Set tracing on/off
|
||||||
void setTractingSendId(bool trace);
|
void setTractingSendId(bool trace);
|
||||||
|
|
||||||
//! FSX Terrain probe
|
|
||||||
//! \remark must be off at P3D v4.2 drivers or later
|
|
||||||
bool isUsingFsxTerrainProbe() const { return m_useFsxTerrainProbe; }
|
|
||||||
|
|
||||||
//! FSX terrain probe
|
|
||||||
void setUsingFsxTerrainProbe(bool use) { m_useFsxTerrainProbe = use; }
|
|
||||||
|
|
||||||
//! Using the SB offsets?
|
//! Using the SB offsets?
|
||||||
bool isUsingSbOffsetValues() const { return m_useSbOffsets; }
|
bool isUsingSbOffsetValues() const { return m_useSbOffsets; }
|
||||||
|
|
||||||
@@ -243,17 +233,8 @@ namespace swift::simplugin::msfs2024common
|
|||||||
return requestId >= RequestSimObjAircraftStart && requestId <= RequestSimObjAircraftRangeEnd;
|
return requestId >= RequestSimObjAircraftStart && requestId <= RequestSimObjAircraftRangeEnd;
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Request for probe (elevation)?
|
|
||||||
static bool isRequestForSimObjTerrainProbe(DWORD requestId)
|
|
||||||
{
|
|
||||||
return requestId >= RequestSimObjTerrainProbeStart && requestId <= RequestSimObjTerrainProbeRangeEnd;
|
|
||||||
}
|
|
||||||
|
|
||||||
//! Request for any CSimConnectObject?
|
//! Request for any CSimConnectObject?
|
||||||
static bool isRequestForSimConnectObject(DWORD requestId)
|
static bool isRequestForSimConnectObject(DWORD requestId) { return isRequestForSimObjAircraft(requestId); }
|
||||||
{
|
|
||||||
return isRequestForSimObjAircraft(requestId) || isRequestForSimObjTerrainProbe(requestId);
|
|
||||||
}
|
|
||||||
|
|
||||||
//! Sub request type
|
//! Sub request type
|
||||||
static CSimConnectDefinitions::SimObjectRequest requestToSimObjectRequest(DWORD requestId);
|
static CSimConnectDefinitions::SimObjectRequest requestToSimObjectRequest(DWORD requestId);
|
||||||
@@ -309,9 +290,6 @@ namespace swift::simplugin::msfs2024common
|
|||||||
//! Get new request id, overflow safe
|
//! Get new request id, overflow safe
|
||||||
SIMCONNECT_DATA_REQUEST_ID obtainRequestIdForSimObjAircraft();
|
SIMCONNECT_DATA_REQUEST_ID obtainRequestIdForSimObjAircraft();
|
||||||
|
|
||||||
//! Get new request id, overflow safe
|
|
||||||
SIMCONNECT_DATA_REQUEST_ID obtainRequestIdForSimObjTerrainProbe();
|
|
||||||
|
|
||||||
//! Release AI control
|
//! Release AI control
|
||||||
//! \remark P3D version is overridden
|
//! \remark P3D version is overridden
|
||||||
virtual bool releaseAIControl(const CSimConnectObject &simObject, SIMCONNECT_DATA_REQUEST_ID requestId);
|
virtual bool releaseAIControl(const CSimConnectObject &simObject, SIMCONNECT_DATA_REQUEST_ID requestId);
|
||||||
@@ -388,10 +366,6 @@ namespace swift::simplugin::msfs2024common
|
|||||||
//!< overriden by specialized P3D function
|
//!< overriden by specialized P3D function
|
||||||
CSimConnectObjects m_simConnectObjects; //!< AI objects and their object and request ids
|
CSimConnectObjects m_simConnectObjects; //!< AI objects and their object and request ids
|
||||||
|
|
||||||
// probes
|
|
||||||
bool m_useFsxTerrainProbe = is32bit(); //!< Use FSX Terrain probe?
|
|
||||||
bool m_initFsxTerrainProbes = false; //!< initialized terrain probes
|
|
||||||
int m_addedProbes = 0; //!< added probes
|
|
||||||
QMap<DWORD, swift::misc::aviation::CCallsign>
|
QMap<DWORD, swift::misc::aviation::CCallsign>
|
||||||
m_pendingProbeRequests; //!< pending elevation requests: requestId/aircraft callsign
|
m_pendingProbeRequests; //!< pending elevation requests: requestId/aircraft callsign
|
||||||
|
|
||||||
@@ -421,14 +395,6 @@ namespace swift::simplugin::msfs2024common
|
|||||||
AircraftAddMode addMode,
|
AircraftAddMode addMode,
|
||||||
const CSimConnectObject &correspondingSimObject = {});
|
const CSimConnectObject &correspondingSimObject = {});
|
||||||
|
|
||||||
//! Add AI object for terrain probe
|
|
||||||
//! \remark experimental
|
|
||||||
bool physicallyAddAITerrainProbe(const swift::misc::geo::ICoordinateGeodetic &coordinate, int number);
|
|
||||||
|
|
||||||
//! Add number probes (inits the probe objects)
|
|
||||||
//! \remark experimental
|
|
||||||
int physicallyInitAITerrainProbes(const swift::misc::geo::ICoordinateGeodetic &coordinate, int number);
|
|
||||||
|
|
||||||
//! Remove aircraft no longer in provider
|
//! Remove aircraft no longer in provider
|
||||||
//! \remark kind of cleanup function, in an ideal scenario this should never need to cleanup something
|
//! \remark kind of cleanup function, in an ideal scenario this should never need to cleanup something
|
||||||
swift::misc::aviation::CCallsignSet physicallyRemoveAircraftNotInProvider();
|
swift::misc::aviation::CCallsignSet physicallyRemoveAircraftNotInProvider();
|
||||||
@@ -450,9 +416,6 @@ namespace swift::simplugin::msfs2024common
|
|||||||
//! Logging version of verifyFailedAircraftInfo
|
//! Logging version of verifyFailedAircraftInfo
|
||||||
bool logVerifyFailedAircraftInfo(const CSimConnectObject &simObject) const;
|
bool logVerifyFailedAircraftInfo(const CSimConnectObject &simObject) const;
|
||||||
|
|
||||||
//! Verify the probe
|
|
||||||
void verifyAddedTerrainProbe(const swift::misc::simulation::CSimulatedAircraft &remoteAircraftIn);
|
|
||||||
|
|
||||||
//! Add next aircraft based on timer
|
//! Add next aircraft based on timer
|
||||||
void timerBasedObjectAddOrRemove();
|
void timerBasedObjectAddOrRemove();
|
||||||
|
|
||||||
@@ -586,10 +549,6 @@ namespace swift::simplugin::msfs2024common
|
|||||||
bool requestPositionDataForSimObject(const CSimConnectObject &simObject,
|
bool requestPositionDataForSimObject(const CSimConnectObject &simObject,
|
||||||
SIMCONNECT_PERIOD period = SIMCONNECT_PERIOD_SECOND);
|
SIMCONNECT_PERIOD period = SIMCONNECT_PERIOD_SECOND);
|
||||||
|
|
||||||
//! Request data for the terrain probe
|
|
||||||
bool requestTerrainProbeData(const CSimConnectObject &simObject,
|
|
||||||
const swift::misc::aviation::CCallsign &aircraftCallsign);
|
|
||||||
|
|
||||||
//! Request lights for a CSimConnectObject
|
//! Request lights for a CSimConnectObject
|
||||||
bool requestLightsForSimObject(const CSimConnectObject &simObject);
|
bool requestLightsForSimObject(const CSimConnectObject &simObject);
|
||||||
|
|
||||||
@@ -655,13 +614,6 @@ namespace swift::simplugin::msfs2024common
|
|||||||
RequestSimObjAircraftStart - 1 +
|
RequestSimObjAircraftStart - 1 +
|
||||||
static_cast<int>(CSimConnectDefinitions::SimObjectEndMarker) * MaxSimObjAircraft;
|
static_cast<int>(CSimConnectDefinitions::SimObjectEndMarker) * MaxSimObjAircraft;
|
||||||
|
|
||||||
// -- range for probe data, each probe object will get its own request id and use the offset ranges
|
|
||||||
static constexpr int RequestSimObjTerrainProbeStart = RequestSimObjAircraftRangeEnd + 1;
|
|
||||||
static constexpr int RequestSimObjTerrainProbeEnd = RequestSimObjTerrainProbeStart - 1 + MaxSimObjProbes;
|
|
||||||
static constexpr int RequestSimObjTerrainProbeRangeEnd =
|
|
||||||
RequestSimObjTerrainProbeStart - 1 +
|
|
||||||
static_cast<int>(CSimConnectDefinitions::SimObjectEndMarker) * MaxSimObjProbes;
|
|
||||||
|
|
||||||
// times
|
// times
|
||||||
static constexpr int AddPendingAircraftIntervalMs = 20 * 1000;
|
static constexpr int AddPendingAircraftIntervalMs = 20 * 1000;
|
||||||
static constexpr int DispatchIntervalMs = 10; //!< how often with run the FSX event queue
|
static constexpr int DispatchIntervalMs = 10; //!< how often with run the FSX event queue
|
||||||
@@ -713,8 +665,6 @@ namespace swift::simplugin::msfs2024common
|
|||||||
CSimConnectObjects m_addPendingAircraft; //!< aircraft/probes awaiting to be added;
|
CSimConnectObjects m_addPendingAircraft; //!< aircraft/probes awaiting to be added;
|
||||||
SIMCONNECT_DATA_REQUEST_ID m_requestIdSimObjAircraft = static_cast<SIMCONNECT_DATA_REQUEST_ID>(
|
SIMCONNECT_DATA_REQUEST_ID m_requestIdSimObjAircraft = static_cast<SIMCONNECT_DATA_REQUEST_ID>(
|
||||||
RequestSimObjAircraftStart); //!< request id, use obtainRequestIdForSimObjAircraft to get id
|
RequestSimObjAircraftStart); //!< request id, use obtainRequestIdForSimObjAircraft to get id
|
||||||
SIMCONNECT_DATA_REQUEST_ID m_requestIdSimObjTerrainProbe = static_cast<SIMCONNECT_DATA_REQUEST_ID>(
|
|
||||||
RequestSimObjTerrainProbeStart); //!< request id, use obtainRequestIdForSimObjTerrainProbe to get id
|
|
||||||
QTimer m_simObjectTimer; //!< updating of SimObjects awaiting to be added
|
QTimer m_simObjectTimer; //!< updating of SimObjects awaiting to be added
|
||||||
|
|
||||||
// Last selected frequencies in simulator before setting 8.33 kHz spacing frequency
|
// Last selected frequencies in simulator before setting 8.33 kHz spacing frequency
|
||||||
@@ -754,10 +704,6 @@ namespace swift::simplugin::msfs2024common
|
|||||||
{
|
{
|
||||||
return MaxSimObjAircraft * static_cast<DWORD>(req);
|
return MaxSimObjAircraft * static_cast<DWORD>(req);
|
||||||
}
|
}
|
||||||
static DWORD offsetSimObjTerrainProbe(CSimConnectDefinitions::SimObjectRequest req)
|
|
||||||
{
|
|
||||||
return MaxSimObjProbes * static_cast<DWORD>(req);
|
|
||||||
}
|
|
||||||
//! @}
|
//! @}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -113,11 +113,6 @@ namespace swift::simplugin::msfs2024common
|
|||||||
Q_UNUSED(removed);
|
Q_UNUSED(removed);
|
||||||
CLogMessage(simulatorMsfs2024).warning(u"Adding probe failed: %1 %2")
|
CLogMessage(simulatorMsfs2024).warning(u"Adding probe failed: %1 %2")
|
||||||
<< simObject.getCallsign().asString() << simObject.getAircraftModelString();
|
<< simObject.getCallsign().asString() << simObject.getAircraftModelString();
|
||||||
if (simulatorMsfs2024->isUsingFsxTerrainProbe())
|
|
||||||
{
|
|
||||||
CLogMessage(simulatorMsfs2024).warning(u"Disabling terrain probe");
|
|
||||||
simulatorMsfs2024->setUsingFsxTerrainProbe(false);
|
|
||||||
}
|
|
||||||
logGenericExceptionInfo = false;
|
logGenericExceptionInfo = false;
|
||||||
} // aircraft
|
} // aircraft
|
||||||
} // valid
|
} // valid
|
||||||
@@ -366,37 +361,6 @@ namespace swift::simplugin::msfs2024common
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (CSimulatorMsfs2024::isRequestForSimObjTerrainProbe(requestId))
|
|
||||||
{
|
|
||||||
const CSimConnectObject probeObj = simulatorMsfs2024->getSimObjectForObjectId(objectId);
|
|
||||||
if (!probeObj.hasValidRequestAndObjectId()) { break; }
|
|
||||||
Q_ASSERT_X(probeObj.isTerrainProbe(), Q_FUNC_INFO, "No probe");
|
|
||||||
const CSimConnectDefinitions::SimObjectRequest subRequest =
|
|
||||||
CSimulatorMsfs2024::requestToSimObjectRequest(requestId);
|
|
||||||
|
|
||||||
if (subRequest == CSimConnectDefinitions::SimObjectPositionData)
|
|
||||||
{
|
|
||||||
static_assert(sizeof(DataDefinitionPosData) == 5 * sizeof(double),
|
|
||||||
"DataDefinitionRemoteAircraftSimData has an incorrect size.");
|
|
||||||
const DataDefinitionPosData *probeSimData =
|
|
||||||
reinterpret_cast<const DataDefinitionPosData *>(&pObjData->dwData);
|
|
||||||
// extra check, but ids should be the same
|
|
||||||
if (objectId == probeObj.getObjectId())
|
|
||||||
{
|
|
||||||
const CCallsign cs = simulatorMsfs2024->m_pendingProbeRequests.value(requestId);
|
|
||||||
if (cs.isEmpty()) { break; }
|
|
||||||
simulatorMsfs2024->updateProbeFromSimulator(cs, *probeSimData);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (CBuildConfig::isLocalDeveloperDebugBuild())
|
|
||||||
{
|
|
||||||
CLogMessage(simulatorMsfs2024).error(u"Unknown subrequest (probe): '%1' %2")
|
|
||||||
<< CSimConnectDefinitions::simObjectRequestToString(subRequest) << probeObj.toQString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} // probe
|
|
||||||
}
|
}
|
||||||
break; // default (SIMCONNECT_RECV_ID_SIMOBJECT_DATA)
|
break; // default (SIMCONNECT_RECV_ID_SIMOBJECT_DATA)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user