mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-05 01:05:34 +08:00
Ref T197, simulator info
* CSimulatorInfo only initialized once and not over and over again in plugin info * getSimulatorInfo() no longer virtual, as we can access the member CSimulatorInfo directly * display exact simualtor in FSX/P3D driver * renamed to identifierToSimulator and fixed typo "Identifier"
This commit is contained in:
@@ -32,9 +32,9 @@ namespace BlackCore
|
||||
return status;
|
||||
}
|
||||
|
||||
CSimulatorInfo ISimulator::getSimulatorInfo() const
|
||||
const CSimulatorInfo &ISimulator::getSimulatorInfo() const
|
||||
{
|
||||
return CSimulatorInfo(this->getSimulatorPluginInfo().getSimulatorInfo());
|
||||
return this->getSimulatorPluginInfo().getSimulatorInfo();
|
||||
}
|
||||
|
||||
void ISimulator::registerHelp()
|
||||
|
||||
@@ -84,7 +84,7 @@ namespace BlackCore
|
||||
virtual const BlackMisc::Simulation::CSimulatorPluginInfo &getSimulatorPluginInfo() const = 0;
|
||||
|
||||
//! Get simulator info (default implementation)
|
||||
virtual BlackMisc::Simulation::CSimulatorInfo getSimulatorInfo() const;
|
||||
const BlackMisc::Simulation::CSimulatorInfo &getSimulatorInfo() const;
|
||||
|
||||
//! Get the setup (simulator environemnt)
|
||||
virtual const BlackMisc::Simulation::CSimulatorInternals &getSimulatorInternals() const = 0;
|
||||
|
||||
@@ -80,10 +80,10 @@ namespace BlackGui
|
||||
QStringList ids;
|
||||
|
||||
// have to match full canonical ids from swift-plugin-simulators.xml
|
||||
if (ui->cb_FS9->isChecked()) { ids << CSimulatorPluginInfo::fs9PluginIndentifier(); }
|
||||
if (ui->cb_FSX->isChecked()) { ids << CSimulatorPluginInfo::fsxPluginIndentifier(); }
|
||||
if (ui->cb_P3D->isChecked()) { ids << CSimulatorPluginInfo::p3dPluginIndentifier(); }
|
||||
if (ui->cb_XP->isChecked()) { ids << CSimulatorPluginInfo::xplanePluginIndentifier(); }
|
||||
if (ui->cb_FS9->isChecked()) { ids << CSimulatorPluginInfo::fs9PluginIdentifier(); }
|
||||
if (ui->cb_FSX->isChecked()) { ids << CSimulatorPluginInfo::fsxPluginIdentifier(); }
|
||||
if (ui->cb_P3D->isChecked()) { ids << CSimulatorPluginInfo::p3dPluginIdentifier(); }
|
||||
if (ui->cb_XP->isChecked()) { ids << CSimulatorPluginInfo::xplanePluginIdentifier(); }
|
||||
|
||||
return ids;
|
||||
}
|
||||
|
||||
@@ -33,13 +33,13 @@ namespace BlackMisc
|
||||
CSimulatorInfo::CSimulatorInfo()
|
||||
{ }
|
||||
|
||||
CSimulatorInfo::CSimulatorInfo(const QString &identifierString) : m_simulator(identifierToFlag(identifierString))
|
||||
CSimulatorInfo::CSimulatorInfo(const QString &identifierString) : m_simulator(identifierToSimulator(identifierString))
|
||||
{ }
|
||||
|
||||
CSimulatorInfo::CSimulatorInfo(const QStringList &simulators)
|
||||
{
|
||||
const QString identifier = simulators.join(' ');
|
||||
m_simulator = identifierToFlag(identifier);
|
||||
m_simulator = identifierToSimulator(identifier);
|
||||
}
|
||||
|
||||
CSimulatorInfo::CSimulatorInfo(Simulator simulator) : m_simulator(static_cast<int>(simulator))
|
||||
@@ -181,10 +181,10 @@ namespace BlackMisc
|
||||
static const QString e;
|
||||
if (!this->isSingleSimulator()) { return e; }
|
||||
const Simulator s = getSimulator();
|
||||
if (s.testFlag(FSX)) { return CSimulatorPluginInfo::fsxPluginIndentifier(); }
|
||||
if (s.testFlag(FS9)) { return CSimulatorPluginInfo::fs9PluginIndentifier(); }
|
||||
if (s.testFlag(P3D)) { return CSimulatorPluginInfo::p3dPluginIndentifier(); }
|
||||
if (s.testFlag(XPLANE)) { return CSimulatorPluginInfo::xplanePluginIndentifier(); }
|
||||
if (s.testFlag(FSX)) { return CSimulatorPluginInfo::fsxPluginIdentifier(); }
|
||||
if (s.testFlag(FS9)) { return CSimulatorPluginInfo::fs9PluginIdentifier(); }
|
||||
if (s.testFlag(P3D)) { return CSimulatorPluginInfo::p3dPluginIdentifier(); }
|
||||
if (s.testFlag(XPLANE)) { return CSimulatorPluginInfo::xplanePluginIdentifier(); }
|
||||
return e;
|
||||
}
|
||||
|
||||
@@ -197,9 +197,9 @@ namespace BlackMisc
|
||||
return s;
|
||||
}
|
||||
|
||||
CSimulatorInfo::Simulator CSimulatorInfo::identifierToFlag(const QString &identifier)
|
||||
CSimulatorInfo::Simulator CSimulatorInfo::identifierToSimulator(const QString &identifier)
|
||||
{
|
||||
QString i(identifier.toLower().trimmed().remove(' ').remove('-'));
|
||||
const QString i(identifier.toLower().trimmed().remove(' ').remove('-'));
|
||||
if (i.isEmpty()) { return None; }
|
||||
|
||||
Simulator s = None;
|
||||
|
||||
@@ -31,14 +31,16 @@ namespace BlackMisc
|
||||
namespace Simulation
|
||||
{
|
||||
//! Simple hardcoded info about the corresponding simulator.
|
||||
//!
|
||||
//! * in an ideal world this class would not exist, all would depend on flexible plugins \sa CSimulatorPluginInfo
|
||||
//! * in a real world the info is needed in a couple of places to specify the simulator
|
||||
//! ** when data from the swift datastore are read, the corresponding simulator is specified
|
||||
//! ** when model metadata are written to the swift datastore the DB simulator info needs to be provided
|
||||
//! ** when models are indexed from disk it does not know the corresponding driver
|
||||
//! ** also there is no strict dependency of some functions to the driver. I might not have the XP plugin installed,
|
||||
//! but need to handle XP data from the swift data store
|
||||
//! If someone manages to remove this hardocded simulator information and makes it entirely flexible
|
||||
//! but need to handle XP data from the swift datastore.
|
||||
//!
|
||||
//! If someone manages to remove this hardcoded simulator information and makes it entirely flexible
|
||||
//! based upon the plugin metadata feel free.
|
||||
class BLACKMISC_EXPORT CSimulatorInfo : public CValueObject<CSimulatorInfo>
|
||||
{
|
||||
@@ -163,7 +165,7 @@ namespace BlackMisc
|
||||
static Simulator boolToFlag(bool fsx, bool fs9, bool xp, bool p3d);
|
||||
|
||||
//! Identifer, as provided by plugin
|
||||
static Simulator identifierToFlag(const QString &identifier);
|
||||
static Simulator identifierToSimulator(const QString &identifier);
|
||||
|
||||
//! All simulators
|
||||
static const CSimulatorInfo &allSimulators();
|
||||
|
||||
@@ -19,8 +19,10 @@ namespace BlackMisc
|
||||
namespace Simulation
|
||||
{
|
||||
CSimulatorPluginInfo::CSimulatorPluginInfo(const QString &identifier, const QString &name, const QString &simulator, const QString &description, bool valid) :
|
||||
m_identifier(identifier), m_name(name), m_simulator(simulator), m_description(description), m_valid(valid)
|
||||
{ }
|
||||
m_identifier(identifier), m_name(name), m_simulator(simulator), m_description(description), m_info(simulator), m_valid(valid)
|
||||
{
|
||||
Q_ASSERT_X(m_info.isSingleSimulator(), Q_FUNC_INFO, "need single simulator");
|
||||
}
|
||||
|
||||
void CSimulatorPluginInfo::convertFromJson(const QJsonObject &json)
|
||||
{
|
||||
@@ -38,6 +40,12 @@ namespace BlackMisc
|
||||
{
|
||||
CValueObject::convertFromJson(json);
|
||||
}
|
||||
|
||||
// set info if it wasn't set already
|
||||
if (m_info.isNoSimulator() && !m_simulator.isEmpty())
|
||||
{
|
||||
m_info = CSimulatorInfo(m_simulator);
|
||||
}
|
||||
}
|
||||
|
||||
bool CSimulatorPluginInfo::isUnspecified() const
|
||||
@@ -45,14 +53,9 @@ namespace BlackMisc
|
||||
return m_identifier.isEmpty();
|
||||
}
|
||||
|
||||
CSimulatorInfo CSimulatorPluginInfo::getSimulatorInfo() const
|
||||
{
|
||||
return CSimulatorInfo(getSimulator());
|
||||
}
|
||||
|
||||
bool CSimulatorPluginInfo::isEmulatedPlugin() const
|
||||
{
|
||||
return this->getIdentifier() == emulatedPluginIndentifier();
|
||||
return this->getIdentifier() == emulatedPluginIdentifier();
|
||||
}
|
||||
|
||||
QString CSimulatorPluginInfo::convertToQString(bool i18n) const
|
||||
@@ -61,31 +64,31 @@ namespace BlackMisc
|
||||
return QString("%1 (%2)").arg(m_name, m_identifier);
|
||||
}
|
||||
|
||||
const QString &CSimulatorPluginInfo::fsxPluginIndentifier()
|
||||
const QString &CSimulatorPluginInfo::fsxPluginIdentifier()
|
||||
{
|
||||
static const QString s("org.swift-project.plugins.simulator.fsx");
|
||||
return s;
|
||||
}
|
||||
|
||||
const QString &CSimulatorPluginInfo::p3dPluginIndentifier()
|
||||
const QString &CSimulatorPluginInfo::p3dPluginIdentifier()
|
||||
{
|
||||
static const QString s("org.swift-project.plugins.simulator.p3d");
|
||||
return s;
|
||||
}
|
||||
|
||||
const QString &CSimulatorPluginInfo::fs9PluginIndentifier()
|
||||
const QString &CSimulatorPluginInfo::fs9PluginIdentifier()
|
||||
{
|
||||
static const QString s("org.swift-project.plugins.simulator.fs9");
|
||||
return s;
|
||||
}
|
||||
|
||||
const QString &CSimulatorPluginInfo::xplanePluginIndentifier()
|
||||
const QString &CSimulatorPluginInfo::xplanePluginIdentifier()
|
||||
{
|
||||
static const QString s("org.swift-project.plugins.simulator.xplane");
|
||||
return s;
|
||||
}
|
||||
|
||||
const QString &CSimulatorPluginInfo::emulatedPluginIndentifier()
|
||||
const QString &CSimulatorPluginInfo::emulatedPluginIdentifier()
|
||||
{
|
||||
static const QString s("org.swift-project.plugins.simulator.emulated");
|
||||
return s;
|
||||
@@ -95,11 +98,11 @@ namespace BlackMisc
|
||||
{
|
||||
static const QStringList identifiers(
|
||||
{
|
||||
fsxPluginIndentifier(),
|
||||
p3dPluginIndentifier(),
|
||||
xplanePluginIndentifier(),
|
||||
fs9PluginIndentifier(),
|
||||
emulatedPluginIndentifier()
|
||||
fsxPluginIdentifier(),
|
||||
p3dPluginIdentifier(),
|
||||
xplanePluginIdentifier(),
|
||||
fs9PluginIdentifier(),
|
||||
emulatedPluginIdentifier()
|
||||
});
|
||||
return identifiers;
|
||||
}
|
||||
@@ -109,14 +112,14 @@ namespace BlackMisc
|
||||
if (BlackConfig::CBuildConfig::isRunningOnUnixPlatform())
|
||||
{
|
||||
// On UNIX we likely run XP
|
||||
return QStringList { xplanePluginIndentifier() };
|
||||
return QStringList { xplanePluginIdentifier() };
|
||||
}
|
||||
|
||||
return QStringList
|
||||
{
|
||||
fsxPluginIndentifier(),
|
||||
p3dPluginIndentifier(),
|
||||
xplanePluginIndentifier()
|
||||
fsxPluginIdentifier(),
|
||||
p3dPluginIdentifier(),
|
||||
xplanePluginIdentifier()
|
||||
};
|
||||
}
|
||||
} // ns
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace BlackMisc
|
||||
namespace Simulation
|
||||
{
|
||||
//! Describing a simulator plugin
|
||||
class BLACKMISC_EXPORT CSimulatorPluginInfo : public BlackMisc::CValueObject<CSimulatorPluginInfo>
|
||||
class BLACKMISC_EXPORT CSimulatorPluginInfo : public CValueObject<CSimulatorPluginInfo>
|
||||
{
|
||||
public:
|
||||
//! Default constructor
|
||||
@@ -60,7 +60,7 @@ namespace BlackMisc
|
||||
const QString &getSimulator() const { return m_simulator; }
|
||||
|
||||
//! Simulator info object
|
||||
BlackMisc::Simulation::CSimulatorInfo getSimulatorInfo() const;
|
||||
const CSimulatorInfo &getSimulatorInfo() const { return m_info; }
|
||||
|
||||
//! Is this the emulated driver?
|
||||
bool isEmulatedPlugin() const;
|
||||
@@ -72,19 +72,19 @@ namespace BlackMisc
|
||||
QString convertToQString(bool i18n = false) const;
|
||||
|
||||
//! Plugin identifier (FSX)
|
||||
static const QString &fsxPluginIndentifier();
|
||||
static const QString &fsxPluginIdentifier();
|
||||
|
||||
//! Plugin identifier (P3D)
|
||||
static const QString &p3dPluginIndentifier();
|
||||
static const QString &p3dPluginIdentifier();
|
||||
|
||||
//! Plugin identifier (FS9)
|
||||
static const QString &fs9PluginIndentifier();
|
||||
static const QString &fs9PluginIdentifier();
|
||||
|
||||
//! Plugin identifier (XPlane)
|
||||
static const QString &xplanePluginIndentifier();
|
||||
static const QString &xplanePluginIdentifier();
|
||||
|
||||
//! Plugin identifier (emulated simulator plugin)
|
||||
static const QString &emulatedPluginIndentifier();
|
||||
static const QString &emulatedPluginIdentifier();
|
||||
|
||||
//! All valid identifiers
|
||||
static const QStringList &allIdentifiers();
|
||||
@@ -97,6 +97,7 @@ namespace BlackMisc
|
||||
QString m_name;
|
||||
QString m_simulator;
|
||||
QString m_description;
|
||||
CSimulatorInfo m_info;
|
||||
bool m_valid { false };
|
||||
|
||||
BLACK_METACLASS(
|
||||
@@ -105,6 +106,7 @@ namespace BlackMisc
|
||||
BLACK_METAMEMBER(name, 0, DisabledForComparison | DisabledForHashing),
|
||||
BLACK_METAMEMBER(simulator, 0, DisabledForComparison | DisabledForHashing),
|
||||
BLACK_METAMEMBER(description, 0, DisabledForComparison | DisabledForHashing),
|
||||
BLACK_METAMEMBER(info, 0, DisabledForComparison | DisabledForHashing),
|
||||
BLACK_METAMEMBER(valid, 0, DisabledForComparison | DisabledForHashing)
|
||||
);
|
||||
};
|
||||
|
||||
@@ -52,12 +52,6 @@ namespace BlackSimPlugin
|
||||
this->connectOwnSignals();
|
||||
}
|
||||
|
||||
CSimulatorInfo CSimulatorEmulated::getSimulatorInfo() const
|
||||
{
|
||||
const CSwiftPluginSettings s = m_settings.get();
|
||||
return s.getEmulatedSimulator();
|
||||
}
|
||||
|
||||
bool CSimulatorEmulated::isTimeSynchronized() const
|
||||
{
|
||||
return m_timeSyncronized;
|
||||
|
||||
@@ -45,9 +45,6 @@ namespace BlackSimPlugin
|
||||
BlackMisc::Weather::IWeatherGridProvider *weatherGridProvider,
|
||||
QObject *parent = nullptr);
|
||||
|
||||
//! \copydoc BlackCore::CSimulatorCommon::getSimulatorInfo
|
||||
virtual BlackMisc::Simulation::CSimulatorInfo getSimulatorInfo() const override;
|
||||
|
||||
// functions implemented
|
||||
virtual bool isTimeSynchronized() const override;
|
||||
virtual bool connectTo() override;
|
||||
|
||||
@@ -740,7 +740,7 @@ namespace BlackSimPlugin
|
||||
{
|
||||
const bool trace = parser.toBool(2);
|
||||
this->setTraceSendId(trace);
|
||||
CLogMessage(this, CLogCategory::cmdLine()).info("Tracing FSX/P3D driver sendIds is '%1'") << boolToOnOff(trace);
|
||||
CLogMessage(this, CLogCategory::cmdLine()).info("Tracing %1 driver sendIds is '%2'") << this->getSimulatorPluginInfo().getIdentifier() << boolToOnOff(trace);
|
||||
return true;
|
||||
}
|
||||
return CSimulatorFsCommon::parseDetails(parser);
|
||||
@@ -782,12 +782,12 @@ namespace BlackSimPlugin
|
||||
{
|
||||
// 2nd time, an error / avoid multiple messages
|
||||
// idea: if it happens once ignore
|
||||
CLogMessage(this).error("FSX/P3D: Dispatch error");
|
||||
CLogMessage(this).error("%1: Dispatch error") << this->getSimulatorPluginInfo().getIdentifier();
|
||||
}
|
||||
else if (m_dispatchErrors > 5)
|
||||
{
|
||||
// this normally happens during a FSX crash or shutdown
|
||||
CLogMessage(this).error("FSX/P3D: Multiple dispatch errors, disconnecting");
|
||||
CLogMessage(this).error("%1: Multiple dispatch errors, disconnecting") << this->getSimulatorPluginInfo().getIdentifier();
|
||||
this->disconnectFrom();
|
||||
}
|
||||
return;
|
||||
@@ -1709,14 +1709,13 @@ namespace BlackSimPlugin
|
||||
if (connectedSimName.isEmpty()) { return false; }
|
||||
if (pluginSim.p3d())
|
||||
{
|
||||
// P3D drivers only work with P3D
|
||||
// P3D drivers only works with P3D
|
||||
return connectedSimName.contains("lockheed") || connectedSimName.contains("martin") || connectedSimName.contains("p3d") || connectedSimName.contains("prepar");
|
||||
}
|
||||
else if (pluginSim.fsx())
|
||||
{
|
||||
// FSX drivers works with P3D and FSX
|
||||
return connectedSimName.contains("fsx") || connectedSimName.contains("microsoft") || connectedSimName.contains("simulator x") ||
|
||||
connectedSimName.contains("lockheed") || connectedSimName.contains("martin") || connectedSimName.contains("p3d") || connectedSimName.contains("prepar");
|
||||
// FSX drivers only works with FSX
|
||||
return connectedSimName.contains("fsx") || connectedSimName.contains("microsoft") || connectedSimName.contains("simulator x");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -1741,7 +1740,7 @@ namespace BlackSimPlugin
|
||||
simListener->m_simConnectVersion = QString("%1.%2.%3.%4").arg(event->dwSimConnectVersionMajor).arg(event->dwSimConnectVersionMinor).arg(event->dwSimConnectBuildMajor).arg(event->dwSimConnectBuildMinor);
|
||||
simListener->m_simulatorName = QString(event->szApplicationName);
|
||||
simListener->m_simulatorDetails = QString("Name: '%1' Version: %2 SimConnect: %3").arg(simListener->m_simulatorName, simListener->m_simulatorVersion, simListener->m_simConnectVersion);
|
||||
CLogMessage(static_cast<CSimulatorFsxCommonListener *>(nullptr)).info("Connect to FSX/P3D: '%1'") << simListener->backendInfo();
|
||||
CLogMessage(static_cast<CSimulatorFsxCommonListener *>(nullptr)).info("Connect to %1: '%2'") << simListener->getPluginInfo().getIdentifier() << simListener->backendInfo();
|
||||
break;
|
||||
}
|
||||
case SIMCONNECT_RECV_ID_EXCEPTION:
|
||||
|
||||
@@ -33,23 +33,23 @@ namespace BlackSimPlugin
|
||||
{
|
||||
void CALLBACK CSimulatorFsxCommon::SimConnectProc(SIMCONNECT_RECV *pData, DWORD cbData, void *pContext)
|
||||
{
|
||||
CSimulatorFsxCommon *simulatorFsx = static_cast<CSimulatorFsxCommon *>(pContext);
|
||||
CSimulatorFsxCommon *simulatorFsxP3D = static_cast<CSimulatorFsxCommon *>(pContext);
|
||||
switch (pData->dwID)
|
||||
{
|
||||
case SIMCONNECT_RECV_ID_OPEN:
|
||||
{
|
||||
SIMCONNECT_RECV_OPEN *event = (SIMCONNECT_RECV_OPEN *)pData;
|
||||
simulatorFsx->m_simulatorVersion = QString("%1.%2.%3.%4").arg(event->dwApplicationVersionMajor).arg(event->dwApplicationVersionMinor).arg(event->dwApplicationBuildMajor).arg(event->dwApplicationBuildMinor);
|
||||
simulatorFsx->m_simConnectVersion = QString("%1.%2.%3.%4").arg(event->dwSimConnectVersionMajor).arg(event->dwSimConnectVersionMinor).arg(event->dwSimConnectBuildMajor).arg(event->dwSimConnectBuildMinor);
|
||||
simulatorFsx->m_simulatorName = QString(event->szApplicationName);
|
||||
simulatorFsx->m_simulatorDetails = QString("Name: '%1' Version: %2 SimConnect: %3").arg(simulatorFsx->m_simulatorName, simulatorFsx->m_simulatorVersion, simulatorFsx->m_simConnectVersion);
|
||||
CLogMessage(static_cast<CSimulatorFsxCommon *>(nullptr)).info("Connect to FSX/P3D: '%1'") << simulatorFsx->m_simulatorDetails;
|
||||
simulatorFsx->setSimConnected();
|
||||
simulatorFsxP3D->m_simulatorVersion = QString("%1.%2.%3.%4").arg(event->dwApplicationVersionMajor).arg(event->dwApplicationVersionMinor).arg(event->dwApplicationBuildMajor).arg(event->dwApplicationBuildMinor);
|
||||
simulatorFsxP3D->m_simConnectVersion = QString("%1.%2.%3.%4").arg(event->dwSimConnectVersionMajor).arg(event->dwSimConnectVersionMinor).arg(event->dwSimConnectBuildMajor).arg(event->dwSimConnectBuildMinor);
|
||||
simulatorFsxP3D->m_simulatorName = QString(event->szApplicationName);
|
||||
simulatorFsxP3D->m_simulatorDetails = QString("Name: '%1' Version: %2 SimConnect: %3").arg(simulatorFsxP3D->m_simulatorName, simulatorFsxP3D->m_simulatorVersion, simulatorFsxP3D->m_simConnectVersion);
|
||||
CLogMessage(static_cast<CSimulatorFsxCommon *>(nullptr)).info("Connected to %1: '%2'") << simulatorFsxP3D->getSimulatorPluginInfo().getIdentifier() << simulatorFsxP3D->m_simulatorDetails;
|
||||
simulatorFsxP3D->setSimConnected();
|
||||
break;
|
||||
}
|
||||
case SIMCONNECT_RECV_ID_EXCEPTION:
|
||||
{
|
||||
if (!simulatorFsx->stillDisplayReceiveExceptions()) { break; }
|
||||
if (!simulatorFsxP3D->stillDisplayReceiveExceptions()) { break; }
|
||||
SIMCONNECT_RECV_EXCEPTION *exception = (SIMCONNECT_RECV_EXCEPTION *)pData;
|
||||
const DWORD exceptionId = exception->dwException;
|
||||
const DWORD sendId = exception->dwSendID;
|
||||
@@ -64,15 +64,15 @@ namespace BlackSimPlugin
|
||||
QString ex;
|
||||
ex.sprintf("Exception=%lu | SendID=%lu | Index=%lu | cbData=%lu", exceptionId, sendId, index, data);
|
||||
const QString exceptionString(CSimConnectUtilities::simConnectExceptionToString((SIMCONNECT_EXCEPTION)exception->dwException));
|
||||
const QString sendIdDetails = simulatorFsx->getSendIdTraceDetails(sendId);
|
||||
CLogMessage(simulatorFsx).warning("Caught simConnect exception: '%1' '%2' | send details: '%3'")
|
||||
const QString sendIdDetails = simulatorFsxP3D->getSendIdTraceDetails(sendId);
|
||||
CLogMessage(simulatorFsxP3D).warning("Caught simConnect exception: '%1' '%2' | send details: '%3'")
|
||||
<< exceptionString << ex
|
||||
<< (sendIdDetails.isEmpty() ? "N/A" : sendIdDetails);
|
||||
break;
|
||||
}
|
||||
case SIMCONNECT_RECV_ID_QUIT:
|
||||
{
|
||||
simulatorFsx->onSimExit();
|
||||
simulatorFsxP3D->onSimExit();
|
||||
break;
|
||||
}
|
||||
case SIMCONNECT_RECV_ID_EVENT:
|
||||
@@ -85,21 +85,21 @@ namespace BlackSimPlugin
|
||||
const bool running = event->dwData ? true : false;
|
||||
if (running)
|
||||
{
|
||||
simulatorFsx->onSimRunning();
|
||||
simulatorFsxP3D->onSimRunning();
|
||||
}
|
||||
else
|
||||
{
|
||||
simulatorFsx->onSimStopped();
|
||||
simulatorFsxP3D->onSimStopped();
|
||||
}
|
||||
break;
|
||||
}
|
||||
case SystemEventPause:
|
||||
{
|
||||
const bool p = event->dwData ? true : false;
|
||||
if (simulatorFsx->m_simPaused != p)
|
||||
if (simulatorFsxP3D->m_simPaused != p)
|
||||
{
|
||||
simulatorFsx->m_simPaused = p;
|
||||
simulatorFsx->emitSimulatorCombinedStatus();
|
||||
simulatorFsxP3D->m_simPaused = p;
|
||||
simulatorFsxP3D->emitSimulatorCombinedStatus();
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -120,14 +120,14 @@ namespace BlackSimPlugin
|
||||
|
||||
// such an object is not necessarily one of ours
|
||||
// for instance, I always see object "5" when I start the simulator
|
||||
if (!simulatorFsx->getSimConnectObjects().isKnownSimObjectId(objectId)) { break; }
|
||||
if (!simulatorFsxP3D->getSimConnectObjects().isKnownSimObjectId(objectId)) { break; }
|
||||
switch (event->uEventID)
|
||||
{
|
||||
case SystemEventObjectAdded:
|
||||
// added in SIMCONNECT_RECV_ID_ASSIGNED_OBJECT_ID
|
||||
break;
|
||||
case SystemEventObjectRemoved:
|
||||
simulatorFsx->simulatorReportedObjectRemoved(objectId);
|
||||
simulatorFsxP3D->simulatorReportedObjectRemoved(objectId);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@@ -141,7 +141,7 @@ namespace BlackSimPlugin
|
||||
{
|
||||
case SystemEventFrame:
|
||||
// doing interpolation
|
||||
simulatorFsx->onSimFrame();
|
||||
simulatorFsxP3D->onSimFrame();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@@ -153,16 +153,16 @@ namespace BlackSimPlugin
|
||||
const SIMCONNECT_RECV_ASSIGNED_OBJECT_ID *event = static_cast<SIMCONNECT_RECV_ASSIGNED_OBJECT_ID *>(pData);
|
||||
const DWORD requestId = event->dwRequestID;
|
||||
const DWORD objectId = event->dwObjectID;
|
||||
bool success = simulatorFsx->setSimConnectObjectId(requestId, objectId);
|
||||
bool success = simulatorFsxP3D->setSimConnectObjectId(requestId, objectId);
|
||||
if (!success) { break; } // not an request ID of ours
|
||||
|
||||
success = simulatorFsx->simulatorReportedObjectAdded(objectId); // trigger follow up actions
|
||||
success = simulatorFsxP3D->simulatorReportedObjectAdded(objectId); // trigger follow up actions
|
||||
if (!success)
|
||||
{
|
||||
const CSimulatedAircraft remoteAircraft(simulatorFsx->getSimConnectObjects().getSimObjectForObjectId(objectId).getAircraft());
|
||||
const CStatusMessage msg = CStatusMessage(simulatorFsx).error("Cannot add object %1, cs: '%2' model: '%3'") << objectId << remoteAircraft.getCallsignAsString() << remoteAircraft.getModelString();
|
||||
const CSimulatedAircraft remoteAircraft(simulatorFsxP3D->getSimConnectObjects().getSimObjectForObjectId(objectId).getAircraft());
|
||||
const CStatusMessage msg = CStatusMessage(simulatorFsxP3D).error("Cannot add object %1, cs: '%2' model: '%3'") << objectId << remoteAircraft.getCallsignAsString() << remoteAircraft.getModelString();
|
||||
CLogMessage::preformatted(msg);
|
||||
emit simulatorFsx->physicallyAddingRemoteModelFailed(remoteAircraft, msg);
|
||||
emit simulatorFsxP3D->physicallyAddingRemoteModelFailed(remoteAircraft, msg);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -181,7 +181,7 @@ namespace BlackSimPlugin
|
||||
{
|
||||
static_assert(sizeof(DataDefinitionOwnAircraft) == 30 * sizeof(double), "DataDefinitionOwnAircraft has an incorrect size.");
|
||||
const DataDefinitionOwnAircraft *ownAircaft = (DataDefinitionOwnAircraft *)&pObjData->dwData;
|
||||
simulatorFsx->updateOwnAircraftFromSimulator(*ownAircaft);
|
||||
simulatorFsxP3D->updateOwnAircraftFromSimulator(*ownAircaft);
|
||||
break;
|
||||
}
|
||||
case CSimConnectDefinitions::RequestOwnAircraftTitle:
|
||||
@@ -190,13 +190,13 @@ namespace BlackSimPlugin
|
||||
CAircraftModel model;
|
||||
model.setModelString(dataDefinitionModel->title);
|
||||
model.setModelType(CAircraftModel::TypeOwnSimulatorModel);
|
||||
simulatorFsx->reverseLookupAndUpdateOwnAircraftModel(model);
|
||||
simulatorFsxP3D->reverseLookupAndUpdateOwnAircraftModel(model);
|
||||
break;
|
||||
}
|
||||
case CSimConnectDefinitions::RequestSimEnvironment:
|
||||
{
|
||||
const DataDefinitionSimEnvironment *simEnv = (DataDefinitionSimEnvironment *) &pObjData->dwData;
|
||||
if (simulatorFsx->isTimeSynchronized())
|
||||
if (simulatorFsxP3D->isTimeSynchronized())
|
||||
{
|
||||
const int zh = simEnv->zuluTimeSeconds / 3600;
|
||||
const int zm = (simEnv->zuluTimeSeconds - (zh * 3600)) / 60;
|
||||
@@ -204,7 +204,7 @@ namespace BlackSimPlugin
|
||||
const int lh = simEnv->localTimeSeconds / 3600;
|
||||
const int lm = (simEnv->localTimeSeconds - (lh * 3600)) / 60;
|
||||
const CTime local(lh, lm);
|
||||
simulatorFsx->synchronizeTime(zulu, local);
|
||||
simulatorFsxP3D->synchronizeTime(zulu, local);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -214,19 +214,19 @@ namespace BlackSimPlugin
|
||||
if (CSimulatorFsxCommon::isRequestForSimData(requestId))
|
||||
{
|
||||
static_assert(sizeof(DataDefinitionRemoteAircraftSimData) == 5 * sizeof(double), "DataDefinitionRemoteAircraftSimData has an incorrect size.");
|
||||
const CSimConnectObject simObj = simulatorFsx->getSimConnectObjects().getSimObjectForObjectId(objectId);
|
||||
const CSimConnectObject simObj = simulatorFsxP3D->getSimConnectObjects().getSimObjectForObjectId(objectId);
|
||||
if (!simObj.hasValidRequestAndObjectId()) break;
|
||||
const DataDefinitionRemoteAircraftSimData *remoteAircraftSimData = (DataDefinitionRemoteAircraftSimData *)&pObjData->dwData;
|
||||
// extra check, but ids should be the same
|
||||
if (objectId == simObj.getObjectId())
|
||||
{
|
||||
simulatorFsx->updateRemoteAircraftFromSimulator(simObj, *remoteAircraftSimData);
|
||||
simulatorFsxP3D->updateRemoteAircraftFromSimulator(simObj, *remoteAircraftSimData);
|
||||
}
|
||||
}
|
||||
else if (CSimulatorFsxCommon::isRequestForLights(requestId))
|
||||
{
|
||||
static_assert(sizeof(DataDefinitionRemoteAircraftLights) == 8 * sizeof(double), "DataDefinitionRemoteAircraftLights has an incorrect size.");
|
||||
const CSimConnectObject simObj = simulatorFsx->getSimConnectObjects().getSimObjectForObjectId(objectId);
|
||||
const CSimConnectObject simObj = simulatorFsxP3D->getSimConnectObjects().getSimObjectForObjectId(objectId);
|
||||
if (!simObj.hasValidRequestAndObjectId()) break;
|
||||
const DataDefinitionRemoteAircraftLights *remoteAircraftLights = (DataDefinitionRemoteAircraftLights *)&pObjData->dwData;
|
||||
// extra check, but ids should be the same
|
||||
@@ -234,11 +234,11 @@ namespace BlackSimPlugin
|
||||
{
|
||||
const CCallsign callsign(simObj.getCallsign());
|
||||
const CAircraftLights lights = remoteAircraftLights->toLights(); // as in simulator
|
||||
simulatorFsx->setCurrentLights(callsign, lights);
|
||||
simulatorFsxP3D->setCurrentLights(callsign, lights);
|
||||
if (simObj.getLightsAsSent().isNull())
|
||||
{
|
||||
// allows to compare for toggle
|
||||
simulatorFsx->setLightsAsSent(callsign, lights);
|
||||
simulatorFsxP3D->setLightsAsSent(callsign, lights);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -251,7 +251,7 @@ namespace BlackSimPlugin
|
||||
case SIMCONNECT_RECV_ID_AIRPORT_LIST:
|
||||
{
|
||||
static const CLength maxDistance(200.0, CLengthUnit::NM());
|
||||
const CCoordinateGeodetic posAircraft(simulatorFsx->getOwnAircraftPosition());
|
||||
const CCoordinateGeodetic posAircraft(simulatorFsxP3D->getOwnAircraftPosition());
|
||||
const SIMCONNECT_RECV_AIRPORT_LIST *pAirportList = (SIMCONNECT_RECV_AIRPORT_LIST *) pData;
|
||||
for (unsigned i = 0; i < pAirportList->dwArraySize; ++i)
|
||||
{
|
||||
@@ -265,26 +265,26 @@ namespace BlackSimPlugin
|
||||
CAirport airport(CAirportIcaoCode(icao), pos);
|
||||
const CLength d = airport.calculcateAndUpdateRelativeDistanceAndBearing(posAircraft);
|
||||
if (d > maxDistance) { continue; }
|
||||
airport.updateMissingParts(simulatorFsx->getWebServiceAirport(icao));
|
||||
simulatorFsx->m_airportsInRangeFromSimulator.replaceOrAddByIcao(airport);
|
||||
airport.updateMissingParts(simulatorFsxP3D->getWebServiceAirport(icao));
|
||||
simulatorFsxP3D->m_airportsInRangeFromSimulator.replaceOrAddByIcao(airport);
|
||||
}
|
||||
|
||||
if (simulatorFsx->m_airportsInRangeFromSimulator.size() > simulatorFsx->maxAirportsInRange())
|
||||
if (simulatorFsxP3D->m_airportsInRangeFromSimulator.size() > simulatorFsxP3D->maxAirportsInRange())
|
||||
{
|
||||
simulatorFsx->m_airportsInRangeFromSimulator.sortByDistanceToOwnAircraft();
|
||||
simulatorFsx->m_airportsInRangeFromSimulator.truncate(simulatorFsx->maxAirportsInRange());
|
||||
simulatorFsxP3D->m_airportsInRangeFromSimulator.sortByDistanceToOwnAircraft();
|
||||
simulatorFsxP3D->m_airportsInRangeFromSimulator.truncate(simulatorFsxP3D->maxAirportsInRange());
|
||||
}
|
||||
break;
|
||||
}
|
||||
case SIMCONNECT_RECV_ID_CLIENT_DATA:
|
||||
{
|
||||
if (!simulatorFsx->m_useSbOffsets) { break; }
|
||||
if (!simulatorFsxP3D->m_useSbOffsets) { break; }
|
||||
const SIMCONNECT_RECV_CLIENT_DATA *clientData = (SIMCONNECT_RECV_CLIENT_DATA *)pData;
|
||||
if (simulatorFsx->m_useSbOffsets && clientData->dwRequestID == CSimConnectDefinitions::RequestSbData)
|
||||
if (simulatorFsxP3D->m_useSbOffsets && 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
|
||||
DataDefinitionClientAreaSb *sbData = (DataDefinitionClientAreaSb *) &clientData->dwData;
|
||||
simulatorFsx->updateOwnAircraftFromSimulator(*sbData);
|
||||
simulatorFsxP3D->updateOwnAircraftFromSimulator(*sbData);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user