diff --git a/src/blackcore/vatsim/networkvatlib.cpp b/src/blackcore/vatsim/networkvatlib.cpp index a8673afd2..eb147f633 100644 --- a/src/blackcore/vatsim/networkvatlib.cpp +++ b/src/blackcore/vatsim/networkvatlib.cpp @@ -1249,9 +1249,20 @@ namespace BlackCore // Ref T297, const qint64 diff = qAbs(markerTs - oldTs); - const qint64 offsetTime = (oldTs > 0 && diff > 0 && diff < CFsdSetup::c_interimPositionTimeOffsetMsec) ? - CFsdSetup::c_interimPositionTimeOffsetMsec : - CFsdSetup::c_positionTimeOffsetMsec; + qint64 offsetTime = CFsdSetup::c_positionTimeOffsetMsec; + static const qint64 thresholdMs = qRound(CFsdSetup::c_positionTimeOffsetMsec * 0.4); + if (oldTs > 0 && diff > 0) + { + if (diff < CFsdSetup::c_interimPositionTimeOffsetMsec) + { + offsetTime = CFsdSetup::c_interimPositionTimeOffsetMsec; + } + else if (diff < thresholdMs) + { + offsetTime = qRound(diff * 1.1); + } + } + m_lastOffsetTime[callsign] = offsetTime; return offsetTime; } diff --git a/src/blackmisc/network/fsdsetup.h b/src/blackmisc/network/fsdsetup.h index 1ebebe19d..8efd916ae 100644 --- a/src/blackmisc/network/fsdsetup.h +++ b/src/blackmisc/network/fsdsetup.h @@ -56,10 +56,10 @@ namespace BlackMisc Q_DECLARE_FLAGS(SendReceiveDetails, SendReceiveDetailsFlag) //! Offset times basically telling when to expect the next value from network plus some reserve - //! \remark copies of CNetworkVatlib::c_updatePostionIntervalMsec / c_updateInterimPostionIntervalMsec + //! \remark related to CNetworkVatlib::c_updatePostionIntervalMsec / c_updateInterimPostionIntervalMsec //! @{ - static qint64 constexpr c_positionTimeOffsetMsec = 6000; //!< offset time for received position updates Ref T297 - static qint64 constexpr c_interimPositionTimeOffsetMsec = 2000; //!< offset time for received interim position updates Ref T297 + static constexpr qint64 c_positionTimeOffsetMsec = 6000; //!< offset time for received position updates Ref T297 + static constexpr qint64 c_interimPositionTimeOffsetMsec = 1500; //!< offset time for received interim position updates Ref T297 //! @} //! Default constructor. diff --git a/src/blackmisc/simulation/remoteaircraftprovider.cpp b/src/blackmisc/simulation/remoteaircraftprovider.cpp index 3b60c81a8..a0b930d8f 100644 --- a/src/blackmisc/simulation/remoteaircraftprovider.cpp +++ b/src/blackmisc/simulation/remoteaircraftprovider.cpp @@ -289,6 +289,7 @@ namespace BlackMisc } else { + // newSituationsList.push_frontKeepLatestFirstIgnoreOverlapping(situationCorrected, true, IRemoteAircraftProvider::MaxSituationsPerCallsign); newSituationsList.push_frontKeepLatestFirstAdjustOffset(situationCorrected, true, IRemoteAircraftProvider::MaxSituationsPerCallsign); newSituationsList.setAdjustedSortHint(CAircraftSituationList::AdjustedTimestampLatestFirst); newSituationsList.transferElevationForward(); // transfer elevations, will do nothing if elevations already exist diff --git a/src/plugins/simulator/fsxcommon/fsxsettingscomponent.cpp b/src/plugins/simulator/fsxcommon/fsxsettingscomponent.cpp index 6babf7f17..2c38c4b24 100644 --- a/src/plugins/simulator/fsxcommon/fsxsettingscomponent.cpp +++ b/src/plugins/simulator/fsxcommon/fsxsettingscomponent.cpp @@ -13,12 +13,17 @@ #include "blackgui/overlaymessagesframe.h" #include "blackgui/guiapplication.h" #include "blackcore/context/contextsimulator.h" +#include "blackconfig/buildconfig.h" + +#include +#include using namespace BlackCore; using namespace BlackCore::Context; using namespace BlackGui; using namespace BlackMisc; using namespace BlackMisc::Simulation; +using namespace BlackConfig; namespace BlackSimPlugin { @@ -36,15 +41,20 @@ namespace BlackSimPlugin connect(ui->cb_UseFsuipc, &QCheckBox::released, this, &CFsxSettingsComponent::onFsuipcChanged); connect(ui->cb_SBOffsets, &QCheckBox::released, this, &CFsxSettingsComponent::onSBOffsetsChanged); connect(ui->pb_CopyTerrainProbe, &QPushButton::released, this, &CFsxSettingsComponent::copyTerrainProbe); + connect(ui->pb_Refresh, &QPushButton::released, this, &CFsxSettingsComponent::refresh); - const CSimulatorFsxCommon *fsx = this->getFsxSimulator(); - if (fsx) + if (sGui && sGui->getIContextSimulator()) { - ui->cb_TraceSimConnectCalls->setChecked(fsx->isTracingSendId()); - ui->cb_EnableTerrainProbe->setChecked(fsx->isUsingFsxTerrainProbe()); - ui->cb_SBOffsets->setChecked(fsx->isUsingSbOffsetValues()); - ui->cb_UseFsuipc->setChecked(fsx->isFsuipcConnected()); + connect(sGui->getIContextSimulator(), &IContextSimulator::simulatorStatusChanged, this, &CFsxSettingsComponent::onSimulatorStatusChanged, Qt::QueuedConnection); + connect(sGui->getIContextSimulator(), &IContextSimulator::simulatorPluginChanged, this, &CFsxSettingsComponent::onSimulatorPluginChanged, Qt::QueuedConnection); } + + QPointer myself(this); + QTimer::singleShot(2000, this, [ = ] + { + if (!sGui || !myself || sGui->isShuttingDown()) { return; } + this->refresh(); + }); } CFsxSettingsComponent::~CFsxSettingsComponent() @@ -52,36 +62,52 @@ namespace BlackSimPlugin CSimulatorInfo CFsxSettingsComponent::getSimulator() const { - const CSimulatorFsxCommon *fsx = this->getFsxSimulator(); - return fsx ? fsx->getSimulatorInfo() : m_simulator; + const CSimulatorFsxCommon *fsxOrP3D = this->getFsxOrP3DSimulator(); + return fsxOrP3D ? fsxOrP3D->getSimulatorInfo() : m_simulator; + } + + void CFsxSettingsComponent::refresh() + { + const CSimulatorFsxCommon *fsxOrP3D = this->getFsxOrP3DSimulator(); + if (fsxOrP3D) + { + ui->cb_TraceSimConnectCalls->setChecked(fsxOrP3D->isTracingSendId()); + ui->cb_EnableTerrainProbe->setChecked(fsxOrP3D->isUsingFsxTerrainProbe()); + ui->cb_SBOffsets->setChecked(fsxOrP3D->isUsingSbOffsetValues()); + ui->cb_UseFsuipc->setChecked(fsxOrP3D->isFsuipcConnected()); + } + + const bool terrainProbe = CBuildConfig::isRunningOnWindowsNtPlatform() && (CBuildConfig::buildWordSize() == 32); + ui->cb_EnableTerrainProbe->setEnabled(terrainProbe); + ui->pb_CopyTerrainProbe->setVisible(terrainProbe); } void CFsxSettingsComponent::onSimConnectTraceChanged() { - CSimulatorFsxCommon *fsx = this->getFsxSimulator(); - if (!fsx) { return; } - fsx->setTractingSendId(ui->cb_TraceSimConnectCalls->isChecked()); + CSimulatorFsxCommon *fsxOrP3D = this->getFsxOrP3DSimulator(); + if (!fsxOrP3D) { return; } + fsxOrP3D->setTractingSendId(ui->cb_TraceSimConnectCalls->isChecked()); } void CFsxSettingsComponent::onEnableTerrainProbeChanged() { - CSimulatorFsxCommon *fsx = this->getFsxSimulator(); - if (!fsx) { return; } - fsx->setUsingFsxTerrainProbe(ui->cb_EnableTerrainProbe->isChecked()); + CSimulatorFsxCommon *fsxOrP3D = this->getFsxOrP3DSimulator(); + if (!fsxOrP3D) { return; } + fsxOrP3D->setUsingFsxTerrainProbe(ui->cb_EnableTerrainProbe->isChecked()); } void CFsxSettingsComponent::onFsuipcChanged() { - CSimulatorFsxCommon *fsx = this->getFsxSimulator(); - if (!fsx) { return; } - fsx->useFsuipc(ui->cb_UseFsuipc->isChecked()); + CSimulatorFsxCommon *fsxOrP3D = this->getFsxOrP3DSimulator(); + if (!fsxOrP3D) { return; } + fsxOrP3D->useFsuipc(ui->cb_UseFsuipc->isChecked()); } void CFsxSettingsComponent::onSBOffsetsChanged() { - CSimulatorFsxCommon *fsx = this->getFsxSimulator(); - if (!fsx) { return; } - fsx->setUsingSbOffsetValues(ui->cb_SBOffsets->isChecked()); + CSimulatorFsxCommon *fsxOrP3D = this->getFsxOrP3DSimulator(); + if (!fsxOrP3D) { return; } + fsxOrP3D->setUsingSbOffsetValues(ui->cb_SBOffsets->isChecked()); } void CFsxSettingsComponent::copyTerrainProbe() @@ -94,7 +120,19 @@ namespace BlackSimPlugin if (m_mf) { m_mf->showOverlayMessages(msgs); } } - CSimulatorFsxCommon *CFsxSettingsComponent::getFsxSimulator() const + void CFsxSettingsComponent::onSimulatorStatusChanged(int status) + { + Q_UNUSED(status); + this->refresh(); + } + + void CFsxSettingsComponent::onSimulatorPluginChanged(const CSimulatorPluginInfo &info) + { + Q_UNUSED(info); + this->refresh(); + } + + CSimulatorFsxCommon *CFsxSettingsComponent::getFsxOrP3DSimulator() const { if (!sGui || !sGui->getISimulator() || sGui->isShuttingDown()) { return nullptr; } ISimulator *simulator = sGui->getISimulator(); diff --git a/src/plugins/simulator/fsxcommon/fsxsettingscomponent.h b/src/plugins/simulator/fsxcommon/fsxsettingscomponent.h index a5f69b051..078c189f5 100644 --- a/src/plugins/simulator/fsxcommon/fsxsettingscomponent.h +++ b/src/plugins/simulator/fsxcommon/fsxsettingscomponent.h @@ -13,6 +13,7 @@ #define BLACKSIMPLUGIN_FSXCOMMON_FSXSETTINGSCOMPONENT_H #include "blackmisc/simulation/simulatorinfo.h" +#include "blackmisc/simulation/simulatorplugininfo.h" #include #include @@ -42,6 +43,9 @@ namespace BlackSimPlugin //! Represented simulator BlackMisc::Simulation::CSimulatorInfo getSimulator() const; + //! Update the values + void refresh(); + private: //! Trace checkbox changed void onSimConnectTraceChanged(); @@ -58,8 +62,14 @@ namespace BlackSimPlugin //! Copy the terrain probe void copyTerrainProbe(); + //! Status has been changed + void onSimulatorStatusChanged(int status); + + //! Plugin changed + void onSimulatorPluginChanged(const BlackMisc::Simulation::CSimulatorPluginInfo &info); + //! Access the concrete implementation - CSimulatorFsxCommon *getFsxSimulator() const; + CSimulatorFsxCommon *getFsxOrP3DSimulator() const; BlackMisc::Simulation::CSimulatorInfo m_simulator { "FSX" }; BlackGui::COverlayMessagesFrame *m_mf = nullptr; diff --git a/src/plugins/simulator/fsxcommon/fsxsettingscomponent.ui b/src/plugins/simulator/fsxcommon/fsxsettingscomponent.ui index e19d43838..abc7573cc 100644 --- a/src/plugins/simulator/fsxcommon/fsxsettingscomponent.ui +++ b/src/plugins/simulator/fsxcommon/fsxsettingscomponent.ui @@ -6,14 +6,47 @@ 0 0 - 180 - 121 + 254 + 147 FSX/P3D settings + + + + + + + copy terrain probe + + + + + + + refresh + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + @@ -41,14 +74,17 @@ - Enable SB SimConnect offsets + Enable SB SimConnect offsets. Those are needed to detect "Ident" and "Standby" from your transponder (supported by some vendors as PMDG). + + + true - Use the terrain probe + Use the terrain probe (32bit only) @@ -59,13 +95,6 @@ - - - - - - - @@ -73,10 +102,10 @@ - - + + - copy terrain probe + @@ -87,7 +116,6 @@ cb_UseFsuipc cb_SBOffsets cb_EnableTerrainProbe - pb_CopyTerrainProbe diff --git a/src/plugins/simulator/fsxcommon/simconnectdatadefinition.h b/src/plugins/simulator/fsxcommon/simconnectdatadefinition.h index bdca4629e..be6e0bf55 100644 --- a/src/plugins/simulator/fsxcommon/simconnectdatadefinition.h +++ b/src/plugins/simulator/fsxcommon/simconnectdatadefinition.h @@ -164,9 +164,11 @@ namespace BlackSimPlugin }; //! The whole SB data area + //! \remark vPilot SB area https://forums.vatsim.net/viewtopic.php?p=519580 + //! \remark SB offsets http://www.squawkbox.ca/doc/sdk/fsuipc.php struct DataDefinitionClientAreaSb { - byte data[128] {}; //!< 128 bytes of data, offsets http://www.squawkbox.ca/doc/sdk/fsuipc.php + byte data[128] {}; //!< 128 bytes of data, offsets //! Standby = 1, else 0 byte getTransponderMode() const { return data[17]; } diff --git a/src/plugins/simulator/fsxcommon/simulatorfsxcommon.h b/src/plugins/simulator/fsxcommon/simulatorfsxcommon.h index 89ad9ed3d..cfc1da4ba 100644 --- a/src/plugins/simulator/fsxcommon/simulatorfsxcommon.h +++ b/src/plugins/simulator/fsxcommon/simulatorfsxcommon.h @@ -27,6 +27,7 @@ #include "blackmisc/statusmessage.h" #include "blackmisc/network/client.h" #include "blackmisc/pixmap.h" +#include "blackconfig/buildconfig.h" #include #include @@ -272,15 +273,20 @@ namespace BlackSimPlugin //! Register help static void registerHelp(); + //! Word size @{ + static bool is32bit() { return (BlackConfig::CBuildConfig::buildWordSize() == 32); } + static bool is64bit() { return (BlackConfig::CBuildConfig::buildWordSize() == 64); } + //! @} + static constexpr qint64 AutoTraceOffsetMs = 10 * 1000; //!< how long do we trace? HANDLE m_hSimConnect = nullptr; //!< handle to SimConnect object DispatchProc m_dispatchProc = &CSimulatorFsxCommon::SimConnectProc; //!< called function for dispatch, can be overriden by specialized P3D function CSimConnectObjects m_simConnectObjects; //!< AI objects and their object and request ids // probes - bool m_useFsxTerrainProbe = true; //!< Use FSX Terrain probe? - bool m_initFsxTerrainProbes = false; //!< initialized terrain probes - int m_addedProbes = 0; //!< added probes + bool m_useFsxTerrainProbe = is32bit(); //!< Use FSX Terrain probe? + bool m_initFsxTerrainProbes = false; //!< initialized terrain probes + int m_addedProbes = 0; //!< added probes QMap m_pendingProbeRequests; //!< pending elevation requests: requestId/aircraft callsign private: diff --git a/src/plugins/simulator/fsxcommon/simulatorfsxconfigwindow.ui b/src/plugins/simulator/fsxcommon/simulatorfsxconfigwindow.ui index 2b2f9be0f..d37345190 100644 --- a/src/plugins/simulator/fsxcommon/simulatorfsxconfigwindow.ui +++ b/src/plugins/simulator/fsxcommon/simulatorfsxconfigwindow.ui @@ -2,6 +2,14 @@ CSimulatorFsxConfigWindow + + + 0 + 0 + 450 + 525 + + 450 diff --git a/src/plugins/simulator/fsxcommon/simulatorfsxsimconnectproc.cpp b/src/plugins/simulator/fsxcommon/simulatorfsxsimconnectproc.cpp index cd4da9731..3b6d30fd4 100644 --- a/src/plugins/simulator/fsxcommon/simulatorfsxsimconnectproc.cpp +++ b/src/plugins/simulator/fsxcommon/simulatorfsxsimconnectproc.cpp @@ -382,7 +382,7 @@ namespace BlackSimPlugin { if (!simulatorFsxP3D->m_useSbOffsets) { break; } const SIMCONNECT_RECV_CLIENT_DATA *clientData = static_cast(pData); - if (simulatorFsxP3D->m_useSbOffsets && clientData->dwRequestID == CSimConnectDefinitions::RequestSbData) + if (clientData->dwRequestID == CSimConnectDefinitions::RequestSbData) { //! \fixme FSUIPC vs SimConnect why is offset 19 ident 2/0? In FSUIPC it is 0/1, according to documentation it is 0/1 but I receive 2/0 here. Whoever knows, add comment or fix if wrong const DataDefinitionClientAreaSb *sbData = reinterpret_cast(&clientData->dwData);