Misc. style issues interpolation/model adding

This commit is contained in:
Klaus Basan
2018-11-17 23:03:30 +01:00
parent c8ba6946bd
commit cb422d72cf
9 changed files with 32 additions and 37 deletions

View File

@@ -229,7 +229,7 @@ namespace BlackCore
break;
}
BLACK_FALLTHROUGH;
case CAircraftMatcherSetup::PickFirst:
case CAircraftMatcherSetup::PickFirst: // fallthru intentionally
default:
usedStrategy = CAircraftMatcherSetup::PickFirst; // re-assigned if fall-through
matchedModel = candidates.front();

View File

@@ -233,7 +233,7 @@ namespace BlackCore
void ISimulator::reset()
{
this->clearAllRemoteAircraftData();
this->clearAllRemoteAircraftData(); // reset
}
bool ISimulator::isUpdateAllRemoteAircraft(qint64 currentTimestamp) const
@@ -489,7 +489,7 @@ namespace BlackCore
{
this->physicallyRemoveAllRemoteAircraft();
const CStatusMessageList msgs = this->debugVerifyStateAfterAllAircraftRemoved();
this->clearAllRemoteAircraftData();
this->clearAllRemoteAircraftData(); // "dot command"
if (!msgs.isEmpty()) { emit this->driverMessages(msgs); }
const CSimulatedAircraftList aircraft = this->getAircraftInRange();
for (const CSimulatedAircraft &a : aircraft)
@@ -734,7 +734,7 @@ namespace BlackCore
const int r = this->physicallyRemoveMultipleRemoteAircraft(callsigns);
// leave no trash
this->clearAllRemoteAircraftData();
this->clearAllRemoteAircraftData(); // remove all aircraft
return r;
}

View File

@@ -927,28 +927,19 @@ namespace BlackMisc
if (!aircraftIcao.isLoadedFromDb())
{
if (idAircraftIcao >= 0)
{
aircraftIcao.setDbKey(idAircraftIcao);
}
if (idAircraftIcao >= 0) { aircraftIcao.setDbKey(idAircraftIcao); }
}
if (!livery.isLoadedFromDb())
{
const int idLivery = json.value(prefix % QStringLiteral("idlivery")).toInt(-1);
if (idLivery >= 0)
{
livery.setDbKey(idLivery);
}
if (idLivery >= 0) { livery.setDbKey(idLivery); }
}
if (!distributor.isLoadedFromDb())
{
const QString idDistributor = json.value(prefix % QStringLiteral("iddistributor")).toString();
if (!idDistributor.isEmpty())
{
distributor.setDbKey(idDistributor);
}
if (!idDistributor.isEmpty()) { distributor.setDbKey(idDistributor); }
}
if (!cachedAircraftIcao && aircraftIcao.isLoadedFromDb()) { aircraftIcaos[aircraftIcao.getDbKey()] = aircraftIcao; }

View File

@@ -217,7 +217,7 @@ namespace BlackMisc
CAircraftCfgEntriesList CAircraftCfgParser::performParsingOfSingleFile(const QString &fileName, bool &ok, CStatusMessageList &msgs)
{
// due to the filter we expect only "aircraft.cfg" here
// due to the filter we expect only "aircraft.cfg" files here
// remark: in a 1st version I have used QSettings to parse to file as ini file
// unfortunately some files are malformed which could end up in wrong data

View File

@@ -118,7 +118,7 @@ namespace BlackMisc
// oldest last, null ignored
if (!latest.isNull()) { situations.push_back(latest); }
if (!newer.isNull()) { situations.push_back(newer); }
if (!newer.isNull()) { situations.push_back(newer); }
if (!oldest.isNull()) { situations.push_back(oldest); }
const bool sorted = situations.isSortedAdjustedLatestFirstWithoutNullPositions();

View File

@@ -142,13 +142,14 @@ namespace BlackMisc
if (m_currentSituations.isEmpty()) { return false; }
// and use the real values if available
// m_s[0] .. oldest -> m_[2] .. latest
const CAircraftSituation latest = m_currentSituations.front();
if (latest.isNewerThanAdjusted(m_s[1])) { m_s[2] = latest; }
const qint64 currentAdjusted = m_s[1].getAdjustedMSecsSinceEpoch();
const CAircraftSituation older = m_currentSituations.findObjectBeforeAdjustedOrDefault(currentAdjusted);
if (!older.isNull()) { m_s[0] = older; }
const qint64 latestAdjusted = m_s[2].getAdjustedMSecsSinceEpoch();
const qint64 olderAdjusted = m_s[0].getAdjustedMSecsSinceEpoch();
const qint64 olderAdjusted = m_s[0].getAdjustedMSecsSinceEpoch();
// not having a new situation itself is quite normal,
// only if it persits it is critical.

View File

@@ -674,7 +674,7 @@ namespace BlackSimPlugin
}
// slower updates
if (m_ownAircraftUpdate % 10 == 0)
if (m_ownAircraftUpdateCycles % 10 == 0)
{
if (m_isWeatherActivated)
{
@@ -694,7 +694,7 @@ namespace BlackSimPlugin
// 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);
this->physicallyInitAITerrainProbes(position, 2); // init probe
}
// SB4 offsets
@@ -702,7 +702,7 @@ namespace BlackSimPlugin
m_simulatorInternals.setValue(QStringLiteral("fsx/sb4packets"), m_useSbOffsets ? QString::number(m_sbDataReceived) : QStringLiteral("disabled"));
}
m_ownAircraftUpdate++; // with 50updates/sec long enough even for 32bit
m_ownAircraftUpdateCycles++; // with 50updates/sec long enough even for 32bit
}
void CSimulatorFsxCommon::triggerUpdateRemoteAircraftFromSimulator(const CSimConnectObject &simObject, const DataDefinitionPosData &remoteAircraftData)
@@ -827,9 +827,9 @@ namespace BlackSimPlugin
const QPointer<CSimulatorFsxCommon> myself(this);
QTimer::singleShot(1000, this, [ = ]
{
// also triggers new add if required
if (!myself) { return; }
if (this->isShuttingDownOrDisconnected()) { return; }
// verify aircraft and also triggers new add if required
// do not do this in the event loop, so we do this deferred
if (!myself || this->isShuttingDownOrDisconnected()) { return; }
this->verifyAddedRemoteAircraft(verifyAircraft);
});
return true;
@@ -922,7 +922,7 @@ namespace BlackSimPlugin
emit this->physicallyAddingRemoteModelFailed(CSimulatedAircraft(), false, msg);
}
// trigger new adding from pending if any
// trigger adding pending aircraft if there are any
if (!m_addPendingAircraft.isEmpty())
{
this->addPendingAircraftAfterAdded();
@@ -1020,7 +1020,7 @@ namespace BlackSimPlugin
// no simObject reference outside that block, because it will be deleted
{
CSimConnectObject &simObject = m_simConnectObjects[remoteAircraftIn.getCallsign()];
simObject.setConfirmedAdded(true);
simObject.setConfirmedAdded(true); // terrain probe
simObject.resetTimestampToNow();
cs = simObject.getCallsign();
CLogMessage(this).info("Probe: '%1' '%2' confirmed, %3") << simObject.getCallsignAsString() << simObject.getAircraftModelString() << simObject.toQString();
@@ -1052,7 +1052,7 @@ namespace BlackSimPlugin
void CSimulatorFsxCommon::addPendingAircraftAfterAdded()
{
this->addPendingAircraft(AddAfterAdded);
this->addPendingAircraft(AddAfterAdded); // addPendingAircraft is already "non blocking"
}
void CSimulatorFsxCommon::addPendingAircraft(AircraftAddMode mode)
@@ -2003,8 +2003,8 @@ namespace BlackSimPlugin
{
// MSFS has inverted pitch and bank angles
SIMCONNECT_DATA_PBH pbh;
pbh.Pitch = -situation.getPitch().value(CAngleUnit::deg());
pbh.Bank = -situation.getBank().value(CAngleUnit::deg());
pbh.Pitch = -situation.getPitch().value(CAngleUnit::deg());
pbh.Bank = -situation.getBank().value(CAngleUnit::deg());
pbh.Heading = situation.getHeading().value(CAngleUnit::deg());
return pbh;
}
@@ -2213,7 +2213,7 @@ namespace BlackSimPlugin
m_sbDataReceived = 0;
m_syncTimeDeferredCounter = 0;
m_skipCockpitUpdateCycles = 0;
m_ownAircraftUpdate = 0;
m_ownAircraftUpdateCycles = 0;
m_requestIdSimObjAircraft = static_cast<SIMCONNECT_DATA_REQUEST_ID>(RequestSimObjAircraftStart);
m_dispatchErrors = 0;
m_receiveExceptionCount = 0;

View File

@@ -564,7 +564,7 @@ namespace BlackSimPlugin
int m_sbDataReceived = 0; //!< SB4 area data received
int m_syncTimeDeferredCounter = 0; //!< Set when synchronized, used to wait some time
int m_skipCockpitUpdateCycles = 0; //!< skip some update cycles to allow changes in simulator cockpit to be set
int m_ownAircraftUpdate = 0; //!< own aircraft update
int m_ownAircraftUpdateCycles = 0; //!< own aircraft update
// tracing dispatch performance
int m_dispatchErrors = 0; //!< number of dispatched failed, \sa dispatch

View File

@@ -48,10 +48,10 @@ namespace BlackSimPlugin
case SIMCONNECT_RECV_ID_OPEN:
{
SIMCONNECT_RECV_OPEN *event = static_cast<SIMCONNECT_RECV_OPEN *>(pData);
const QString simConnectVersion = QString("%1.%2.%3.%4").arg(event->dwSimConnectVersionMajor).arg(event->dwSimConnectVersionMinor).arg(event->dwSimConnectBuildMajor).arg(event->dwSimConnectBuildMinor);
const QString version = QString("%1.%2.%3.%4").arg(event->dwApplicationVersionMajor).arg(event->dwApplicationVersionMinor).arg(event->dwApplicationBuildMajor).arg(event->dwApplicationBuildMinor);
const QString name = CSimulatorFsxCommon::fsxCharToQString(event->szApplicationName);
const QString details = QString("Name: '%1' Version: %2 SimConnect: %3").arg(name, version, simConnectVersion);
const QString simConnectVersion = QStringLiteral("%1.%2.%3.%4").arg(event->dwSimConnectVersionMajor).arg(event->dwSimConnectVersionMinor).arg(event->dwSimConnectBuildMajor).arg(event->dwSimConnectBuildMinor);
const QString version = QStringLiteral("%1.%2.%3.%4").arg(event->dwApplicationVersionMajor).arg(event->dwApplicationVersionMinor).arg(event->dwApplicationBuildMajor).arg(event->dwApplicationBuildMinor);
const QString name = CSimulatorFsxCommon::fsxCharToQString(event->szApplicationName);
const QString details = QStringLiteral("Name: '%1' Version: %2 SimConnect: %3").arg(name, version, simConnectVersion);
simulatorFsxP3D->setSimulatorDetails(name, details, version);
simulatorFsxP3D->m_simConnectVersion = simConnectVersion;
CLogMessage(simulatorFsxP3D).info("Connected to %1: '%2'") << simulatorFsxP3D->getSimulatorPluginInfo().getIdentifier() << details;
@@ -179,7 +179,10 @@ namespace BlackSimPlugin
case SystemEventObjectRemoved:
simulatorFsxP3D->simulatorReportedObjectRemoved(objectId);
break;
case SystemEventObjectAdded: // added in SIMCONNECT_RECV_ID_ASSIGNED_OBJECT_ID
case SystemEventObjectAdded:
// added in SIMCONNECT_RECV_ID_ASSIGNED_OBJECT_ID
// this event here is normally received before SIMCONNECT_RECV_ID_ASSIGNED_OBJECT_ID
break;
default:
break;
}