Ref T171, driver formatting

This commit is contained in:
Klaus Basan
2017-10-09 17:37:20 +02:00
parent 1b9a79fe1b
commit 61a23d700b
13 changed files with 126 additions and 131 deletions

View File

@@ -186,7 +186,7 @@ namespace BlackSimPlugin
CInterpolationStatus status;
CInterpolationHints hints; // \fixme 201701 #865 KB if there is an elevation provider for FS9 add it here or set elevation
hints.setLoggingInterpolation(this->getInterpolationSetup().getLogCallsigns().contains(m_callsign));
const CAircraftSituation situation = this->m_interpolator.getInterpolatedSituation(-1, this->m_interpolationSetup, hints, status);
const CAircraftSituation situation = m_interpolator.getInterpolatedSituation(-1, m_interpolationSetup, hints, status);
// Test only for successful interpolation. FS9 requires constant positions
if (!status.didInterpolationSucceed()) { return; }

View File

@@ -25,7 +25,6 @@ namespace BlackSimPlugin
{
namespace Fs9
{
//! Class faking a FS9 multiplayer client connection
class CFs9Client : public CDirectPlayPeer
{
@@ -111,4 +110,4 @@ namespace BlackSimPlugin
Q_DECLARE_METATYPE(BlackSimPlugin::Fs9::CFs9Client::ClientStatus)
#endif // DIRECTPLAY_CLIENT_H
#endif // guard

View File

@@ -208,7 +208,7 @@ namespace BlackSimPlugin
int CSimulatorFs9::physicallyRemoveAllRemoteAircraft()
{
if (m_hashFs9Clients.isEmpty()) { return 0; }
QList<CCallsign> callsigns(this->m_hashFs9Clients.keys());
QList<CCallsign> callsigns(m_hashFs9Clients.keys());
int r = 0;
for (const CCallsign &cs : callsigns)
{
@@ -234,31 +234,31 @@ namespace BlackSimPlugin
const CTransponder newTransponder = ownAircraft.getTransponder();
bool changed = false;
if (newCom1.getFrequencyActive() != this->m_simCom1.getFrequencyActive())
if (newCom1.getFrequencyActive() != m_simCom1.getFrequencyActive())
{
changed = true;
}
if (newCom1.getFrequencyStandby() != this->m_simCom1.getFrequencyStandby())
if (newCom1.getFrequencyStandby() != m_simCom1.getFrequencyStandby())
{
changed = true;
}
if (newCom2.getFrequencyActive() != this->m_simCom2.getFrequencyActive())
if (newCom2.getFrequencyActive() != m_simCom2.getFrequencyActive())
{
changed = true;
}
if (newCom2.getFrequencyStandby() != this->m_simCom2.getFrequencyStandby())
if (newCom2.getFrequencyStandby() != m_simCom2.getFrequencyStandby())
{
changed = true;
}
if (newTransponder.getTransponderCode() != this->m_simTransponder.getTransponderCode())
if (newTransponder.getTransponderCode() != m_simTransponder.getTransponderCode())
{
changed = true;
}
if (newTransponder.getTransponderMode() != this->m_simTransponder.getTransponderMode())
if (newTransponder.getTransponderMode() != m_simTransponder.getTransponderMode())
{
changed = true;
}
@@ -275,7 +275,7 @@ namespace BlackSimPlugin
if (!this->isSimulating()) { return false; }
bool changed = false;
if (selcal != this->m_selcal)
if (selcal != m_selcal)
{
changed = true;
}

View File

@@ -43,16 +43,16 @@ namespace BlackSimPlugin
void CSimulatorFsCommon::initSimulatorInternals()
{
CSimulatorInternals s;
s.setSimulatorName(this->m_simulatorName);
s.setSimulatorVersion(this->m_simulatorVersion);
s.setValue("fscommon/fsuipc", boolToOnOff(this->m_useFsuipc));
if (this->m_fsuipc)
s.setSimulatorName(m_simulatorName);
s.setSimulatorVersion(m_simulatorVersion);
s.setValue("fscommon/fsuipc", boolToOnOff(m_useFsuipc));
if (m_fsuipc)
{
const QString v(this->m_fsuipc->getVersion());
const QString v(m_fsuipc->getVersion());
if (!v.isEmpty()) { s.setValue("fscommon/fsuipcversion", v); }
s.setValue("fscommon/fsuipcconnect", boolToYesNo(this->m_fsuipc->isConnected()));
s.setValue("fscommon/fsuipcconnect", boolToYesNo(m_fsuipc->isConnected()));
}
this->m_simulatorInternals = s;
m_simulatorInternals = s;
}
bool CSimulatorFsCommon::parseDetails(const CSimpleCommandParser &parser)
@@ -69,14 +69,14 @@ namespace BlackSimPlugin
void CSimulatorFsCommon::registerHelp()
{
if (BlackMisc::CSimpleCommandParser::registered("BlackSimPlugin::FsCommon::CSimulatorFsCommon")) { return; }
BlackMisc::CSimpleCommandParser::registerCommand({".drv", "alias: .driver .plugin"});
BlackMisc::CSimpleCommandParser::registerCommand({".drv fsuipc on|off", "FSUIPC on|off if applicable"});
if (CSimpleCommandParser::registered("BlackSimPlugin::FsCommon::CSimulatorFsCommon")) { return; }
CSimpleCommandParser::registerCommand({".drv", "alias: .driver .plugin"});
CSimpleCommandParser::registerCommand({".drv fsuipc on|off", "FSUIPC on|off if applicable"});
}
bool CSimulatorFsCommon::disconnectFrom()
{
if (this->m_fsuipc) { this->m_fsuipc->disconnect(); }
if (m_fsuipc) { m_fsuipc->disconnect(); }
// reset flags
m_simPaused = false;
@@ -109,10 +109,10 @@ namespace BlackSimPlugin
return m_syncTimeOffset;
}
bool CSimulatorFsCommon::setTimeSynchronization(bool enable, const BlackMisc::PhysicalQuantities::CTime &offset)
bool CSimulatorFsCommon::setTimeSynchronization(bool enable, const PhysicalQuantities::CTime &offset)
{
this->m_simTimeSynced = enable;
this->m_syncTimeOffset = offset;
m_simTimeSynced = enable;
m_syncTimeOffset = offset;
return true;
}
@@ -128,8 +128,8 @@ namespace BlackSimPlugin
bool CSimulatorFsCommon::changeRemoteAircraftModel(const CSimulatedAircraft &aircraft)
{
// remove upfront, and then enable / disable again
const auto callsign = aircraft.getCallsign();
if (!isPhysicallyRenderedAircraft(callsign)) { return false; }
const CCallsign callsign = aircraft.getCallsign();
if (!this->isPhysicallyRenderedAircraft(callsign)) { return false; }
this->physicallyRemoveRemoteAircraft(callsign);
return this->changeRemoteAircraftEnabled(aircraft);
}
@@ -152,7 +152,7 @@ namespace BlackSimPlugin
const CAirportList webServiceAirports = this->getWebServiceAirports();
if (!webServiceAirports.isEmpty())
{
this->m_airportsInRangeFromSimulator.updateMissingParts(webServiceAirports);
m_airportsInRangeFromSimulator.updateMissingParts(webServiceAirports);
}
CSimulatorCommon::ps_airportsRead();
}

View File

@@ -50,7 +50,7 @@ namespace BlackSimPlugin
bool CSimConnectObject::isPendingAdded() const
{
return !this->hasValidRequestAndObjectId() || !this->m_confirmedAdded;
return !this->hasValidRequestAndObjectId() || !m_confirmedAdded;
}
bool CSimConnectObject::isConfirmedAdded() const
@@ -79,13 +79,13 @@ namespace BlackSimPlugin
void CSimConnectObject::toggleInterpolatorMode()
{
Q_ASSERT(m_interpolator);
this->m_interpolator->toggleMode();
m_interpolator->toggleMode();
}
bool CSimConnectObject::setInterpolatorMode(CInterpolatorMulti::Mode mode)
{
Q_ASSERT(m_interpolator);
return this->m_interpolator->setMode(mode);
return m_interpolator->setMode(mode);
}
bool CSimConnectObjects::setSimConnectObjectIdForRequestId(DWORD requestId, DWORD objectId, bool resetSentParts)

View File

@@ -97,10 +97,10 @@ namespace BlackSimPlugin
DWORD getObjectId() const { return m_objectId; }
//! Valid request id?
bool hasValidRequestId() const { return this->m_validRequestId; }
bool hasValidRequestId() const { return m_validRequestId; }
//! Valid object id?
bool hasValidObjectId() const { return this->m_validObjectId; }
bool hasValidObjectId() const { return m_validObjectId; }
//! Object is requested, not yet added
bool isPendingAdded() const;

View File

@@ -89,7 +89,7 @@ namespace BlackSimPlugin
// reset state as expected for unconnected
return false;
}
if (m_useFsuipc) { this->m_fsuipc->connect(); } // FSUIPC too
if (m_useFsuipc) { m_fsuipc->connect(); } // FSUIPC too
// set structures and move on
initEvents();
@@ -135,7 +135,7 @@ namespace BlackSimPlugin
const CTransponder newTransponder = ownAircraft.getTransponder();
bool changed = false;
if (newCom1.getFrequencyActive() != this->m_simCom1.getFrequencyActive())
if (newCom1.getFrequencyActive() != m_simCom1.getFrequencyActive())
{
const CFrequency newFreq = newCom1.getFrequencyActive();
SimConnect_TransmitClientEvent(m_hSimConnect, 0, EventSetCom1Active,
@@ -143,7 +143,7 @@ namespace BlackSimPlugin
changed = true;
}
if (newCom1.getFrequencyStandby() != this->m_simCom1.getFrequencyStandby())
if (newCom1.getFrequencyStandby() != m_simCom1.getFrequencyStandby())
{
const CFrequency newFreq = newCom1.getFrequencyStandby();
SimConnect_TransmitClientEvent(m_hSimConnect, 0, EventSetCom1Standby,
@@ -151,14 +151,14 @@ namespace BlackSimPlugin
changed = true;
}
if (newCom2.getFrequencyActive() != this->m_simCom2.getFrequencyActive())
if (newCom2.getFrequencyActive() != m_simCom2.getFrequencyActive())
{
const CFrequency newFreq = newCom2.getFrequencyActive();
SimConnect_TransmitClientEvent(m_hSimConnect, 0, EventSetCom2Active,
CBcdConversions::comFrequencyToBcdHz(newFreq), SIMCONNECT_GROUP_PRIORITY_HIGHEST, SIMCONNECT_EVENT_FLAG_GROUPID_IS_PRIORITY);
changed = true;
}
if (newCom2.getFrequencyStandby() != this->m_simCom2.getFrequencyStandby())
if (newCom2.getFrequencyStandby() != m_simCom2.getFrequencyStandby())
{
const CFrequency newFreq = newCom2.getFrequencyStandby();
SimConnect_TransmitClientEvent(m_hSimConnect, 0, EventSetCom2Standby,
@@ -166,14 +166,14 @@ namespace BlackSimPlugin
changed = true;
}
if (newTransponder.getTransponderCode() != this->m_simTransponder.getTransponderCode())
if (newTransponder.getTransponderCode() != m_simTransponder.getTransponderCode())
{
SimConnect_TransmitClientEvent(m_hSimConnect, 0, EventSetTransponderCode,
CBcdConversions::transponderCodeToBcd(newTransponder), SIMCONNECT_GROUP_PRIORITY_HIGHEST, SIMCONNECT_EVENT_FLAG_GROUPID_IS_PRIORITY);
changed = true;
}
if (newTransponder.getTransponderMode() != this->m_simTransponder.getTransponderMode())
if (newTransponder.getTransponderMode() != m_simTransponder.getTransponderMode())
{
if (m_useSbOffsets)
{
@@ -233,15 +233,15 @@ namespace BlackSimPlugin
bool CSimulatorFsxCommon::isPhysicallyRenderedAircraft(const CCallsign &callsign) const
{
return this->m_simConnectObjects.contains(callsign);
return m_simConnectObjects.contains(callsign);
}
CCallsignSet CSimulatorFsxCommon::physicallyRenderedAircraft() const
{
CCallsignSet callsigns(this->m_simConnectObjects.keys());
CCallsignSet callsigns(m_simConnectObjects.keys());
callsigns.push_back(m_aircraftToAddAgainWhenRemoved.getCallsigns()); // not really rendered right now, but very soon
callsigns.push_back(m_addPendingAircraft.getCallsigns()); // not really rendered, but for the logic it should look like it is
return CCallsignSet(this->m_simConnectObjects.keys());
return CCallsignSet(m_simConnectObjects.keys());
}
bool CSimulatorFsxCommon::setInterpolatorMode(CInterpolatorMulti::Mode mode, const CCallsign &callsign)
@@ -416,12 +416,12 @@ namespace BlackSimPlugin
com1.setFrequencyActive(CFrequency(simulatorOwnAircraft.com1ActiveMHz, CFrequencyUnit::MHz()));
com1.setFrequencyStandby(CFrequency(simulatorOwnAircraft.com1StandbyMHz, CFrequencyUnit::MHz()));
const bool changedCom1 = myAircraft.getCom1System() != com1;
this->m_simCom1 = com1;
m_simCom1 = com1;
com2.setFrequencyActive(CFrequency(simulatorOwnAircraft.com2ActiveMHz, CFrequencyUnit::MHz()));
com2.setFrequencyStandby(CFrequency(simulatorOwnAircraft.com2StandbyMHz, CFrequencyUnit::MHz()));
const bool changedCom2 = myAircraft.getCom2System() != com2;
this->m_simCom2 = com2;
m_simCom2 = com2;
transponder.setTransponderCode(simulatorOwnAircraft.transponderCode);
const bool changedXpr = (myAircraft.getTransponderCode() != transponder.getTransponderCode());
@@ -502,7 +502,7 @@ namespace BlackSimPlugin
bool CSimulatorFsxCommon::simulatorReportedObjectAdded(DWORD objectId)
{
const CSimConnectObject simObject = this->m_simConnectObjects.getSimObjectForObjectId(objectId);
const CSimConnectObject simObject = m_simConnectObjects.getSimObjectForObjectId(objectId);
const CCallsign callsign(simObject.getCallsign());
if (!simObject.hasValidRequestAndObjectId() || callsign.isEmpty()) { return false; }
@@ -650,13 +650,13 @@ namespace BlackSimPlugin
void CSimulatorFsxCommon::removeAsPendingAndAddAgain(const CCallsign &callsign)
{
if (callsign.isEmpty()) { return; }
this->m_addPendingAircraft.removeByCallsign(callsign);
this->m_aircraftToAddAgainWhenRemoved.removeByCallsign(callsign);
m_addPendingAircraft.removeByCallsign(callsign);
m_aircraftToAddAgainWhenRemoved.removeByCallsign(callsign);
}
bool CSimulatorFsxCommon::simulatorReportedObjectRemoved(DWORD objectID)
{
const CSimConnectObject simObject = this->m_simConnectObjects.getSimObjectForObjectId(objectID);
const CSimConnectObject simObject = m_simConnectObjects.getSimObjectForObjectId(objectID);
if (!simObject.hasValidRequestAndObjectId()) { return false; } // object id from somewhere else
const CCallsign callsign(simObject.getCallsign());
Q_ASSERT_X(!callsign.isEmpty(), Q_FUNC_INFO, "missing callsign");
@@ -676,7 +676,7 @@ namespace BlackSimPlugin
// 3) Simulator not running (ie in stopped mode)
if (!simObject.getAircraftModelString().isEmpty())
{
this->m_addPendingAircraft.push_back(simObject.getAircraft());
m_addPendingAircraft.push_back(simObject.getAircraft());
CLogMessage(this).warning("Aircraft removed, '%1' '%2' object id '%3' out of reality bubble or other reason") << callsign.toQString() << simObject.getAircraftModelString() << objectID;
}
else
@@ -709,7 +709,7 @@ namespace BlackSimPlugin
bool CSimulatorFsxCommon::setSimConnectObjectId(DWORD requestId, DWORD objectId)
{
return this->m_simConnectObjects.setSimConnectObjectIdForRequestId(requestId, objectId, true);
return m_simConnectObjects.setSimConnectObjectIdForRequestId(requestId, objectId, true);
}
bool CSimulatorFsxCommon::setCurrentLights(const CCallsign &callsign, const CAircraftLights &lights)
@@ -1025,19 +1025,19 @@ namespace BlackSimPlugin
Q_ASSERT_X(CThreadUtils::isCurrentThreadObjectThread(this), Q_FUNC_INFO, "thread");
// nothing to do, reset request id and exit
if (this->isPaused() && this->m_pausedSimFreezesInterpolation) { return; } // no interpolation while paused
if (this->isPaused() && m_pausedSimFreezesInterpolation) { return; } // no interpolation while paused
const int remoteAircraftNo = this->getAircraftInRangeCount();
if (remoteAircraftNo < 1) { m_interpolationRequest = 0; return; }
// interpolate and send to simulator
this->m_interpolationRequest++;
const bool enableAircraftParts = this->m_interpolationRenderingSetup.isAircraftPartsEnabled();
m_interpolationRequest++;
const bool enableAircraftParts = m_interpolationRenderingSetup.isAircraftPartsEnabled();
const CCallsignSet aircraftWithParts = enableAircraftParts ? this->remoteAircraftSupportingParts() : CCallsignSet(); // optimization, fetch all parts supporting aircraft in one step (one lock)
// values used for position and parts
const qint64 currentTimestamp = QDateTime::currentMSecsSinceEpoch();
const QList<CSimConnectObject> simObjects(m_simConnectObjects.values());
const CCallsignSet callsignsToLog(this->m_interpolationRenderingSetup.getLogCallsigns());
const CCallsignSet callsignsToLog(m_interpolationRenderingSetup.getLogCallsigns());
// interpolation for all remote aircraft
for (const CSimConnectObject &simObj : simObjects)
@@ -1318,7 +1318,7 @@ namespace BlackSimPlugin
void CSimulatorFsxCommon::synchronizeTime(const CTime &zuluTimeSim, const CTime &localTimeSim)
{
if (!this->m_simTimeSynced) { return; }
if (!m_simTimeSynced) { return; }
if (!this->isConnected()) { return; }
if (m_syncDeferredCounter > 0)
{
@@ -1327,9 +1327,9 @@ namespace BlackSimPlugin
Q_UNUSED(localTimeSim);
QDateTime myDateTime = QDateTime::currentDateTimeUtc();
if (!this->m_syncTimeOffset.isZeroEpsilonConsidered())
if (!m_syncTimeOffset.isZeroEpsilonConsidered())
{
int offsetSeconds = this->m_syncTimeOffset.valueRounded(CTimeUnit::s(), 0);
int offsetSeconds = m_syncTimeOffset.valueRounded(CTimeUnit::s(), 0);
myDateTime = myDateTime.addSecs(offsetSeconds);
}
const QTime myTime = myDateTime.time();
@@ -1402,13 +1402,13 @@ namespace BlackSimPlugin
void CSimulatorFsxCommon::initSimulatorInternals()
{
CSimulatorFsCommon::initSimulatorInternals();
CSimulatorInternals s = this->m_simulatorInternals;
CSimulatorInternals s = m_simulatorInternals;
const QString fsxPath = CFsCommonUtil::fsxDirFromRegistry(); // can be empty for remote FSX
if (!fsxPath.isEmpty()) { s.setSimulatorInstallationDirectory(fsxPath); }
s.setValue("fsx/simConnectCfgFilename", CSimConnectUtilities::getLocalSimConnectCfgFilename());
s.setValue("fsx/simConnectVersion", this->m_simConnectVersion);
this->m_simulatorInternals = s;
s.setValue("fsx/simConnectVersion", m_simConnectVersion);
m_simulatorInternals = s;
}
void CSimulatorFsxCommon::reset()

View File

@@ -157,6 +157,7 @@ namespace BlackSimPlugin
const QString &modeToString(AircraftAddMode mode);
//! Dispatch SimConnect messages
//! \remark very frequently called
void dispatch();
//! Implementation of add remote aircraft, which also handles FSX specific adding one by one

View File

@@ -60,12 +60,9 @@ namespace BlackSimPlugin
ex.sprintf("Exception=%lu | SendID=%lu | Index=%lu | cbData=%lu", exceptionId, sendId, index, data);
switch (exceptionId)
{
case SIMCONNECT_EXCEPTION_OPERATION_INVALID_FOR_OBJECT_TYPE:
break;
case SIMCONNECT_EXCEPTION_UNRECOGNIZED_ID:
break;
default:
break;
case SIMCONNECT_EXCEPTION_OPERATION_INVALID_FOR_OBJECT_TYPE: break;
case SIMCONNECT_EXCEPTION_UNRECOGNIZED_ID: break;
default: break;
}
CLogMessage(simulatorFsx).warning("Caught FSX simConnect exception: %1 %2") << exStr << ex;
break;
@@ -293,10 +290,8 @@ namespace BlackSimPlugin
SIMCONNECT_RECV_EVENT_FILENAME *event = static_cast<SIMCONNECT_RECV_EVENT_FILENAME *>(pData);
switch (event->uEventID)
{
case SystemEventFlightLoaded:
break;
default:
break;
case SystemEventFlightLoaded: break;
default: break;
}
break;
}