Ref T632, more detailled entry check for adding a remote aircraft (finds empty callsign)

This commit is contained in:
Klaus Basan
2019-04-23 18:08:12 +02:00
parent 8fe23b780f
commit 275006dad4
2 changed files with 33 additions and 2 deletions

View File

@@ -81,9 +81,16 @@ namespace BlackCore
bool ISimulator::logicallyAddRemoteAircraft(const CSimulatedAircraft &remoteAircraft)
{
Q_ASSERT_X(remoteAircraft.hasModelString(), Q_FUNC_INFO, "Missing model string");
Q_ASSERT_X(remoteAircraft.hasCallsign(), Q_FUNC_INFO, "Missing callsign");
if (!this->validateModelOfAircraft(remoteAircraft))
{
const CCallsign cs = remoteAircraft.getCallsign();
CLogMessage(this).warning(u"Invalid aircraft detected, which will be disabled: '%1' '%2'") << cs << remoteAircraft.getModelString();
this->updateAircraftEnabled(cs, false);
this->updateAircraftRendered(cs, false);
return false;
}
// no invalid model should ever reach this place here
const bool renderingRestricted = this->getInterpolationSetupGlobal().isRenderingRestricted();
if (this->showDebugLogMessage()) { this->debugLogMessage(Q_FUNC_INFO, QStringLiteral("Restricted: %1 cs: '%2' enabled: %3").arg(boolToYesNo(renderingRestricted), remoteAircraft.getCallsignAsString(), boolToYesNo(remoteAircraft.isEnabled()))); }
if (!remoteAircraft.isEnabled()) { return false; }
@@ -1072,6 +1079,27 @@ namespace BlackCore
return CCentralMultiSimulatorModelSetCachesProvider::modelCachesInstance().getCachedModels(simulator);
}
bool ISimulator::validateModelOfAircraft(const CSimulatedAircraft &aircraft) const
{
const CAircraftModel model = aircraft.getModel();
if (!aircraft.hasCallsign())
{
CLogMessage(this).warning(u"Missing callsign for '%1'") << aircraft.getModelString();
return false;
}
if (!model.hasModelString())
{
CLogMessage(this).warning(u"No model string for callsign '%1'") << aircraft.getCallsign();
return false;
}
if (model.isCallsignEmpty())
{
CLogMessage(this).warning(u"No callsign for model of aircraft '%1'") << aircraft.getCallsign();
return false;
}
return true;
}
QString ISimulator::latestLoggedDataFormatted(const CCallsign &cs) const
{
const SituationLog s = m_interpolationLogger.getLastSituationLog(cs);

View File

@@ -538,6 +538,9 @@ namespace BlackCore
//! Get the model set
BlackMisc::Simulation::CAircraftModelList getModelSet() const;
//! Validate if model has callsign and such
bool validateModelOfAircraft(const BlackMisc::Simulation::CSimulatedAircraft &aircraft) const;
//! Lookup against DB data
static BlackMisc::Simulation::CAircraftModel reverseLookupModel(const BlackMisc::Simulation::CAircraftModel &model);