Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/core/aircraftmatcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1657,7 +1657,10 @@ namespace swift::core
if (modelsCleaned.isEmpty())
{
// error to force popup
CLogMessage(this).error(u"No models for matching ('%1'), swift without a model set will not work!")
// TODO TZ extend commend

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can TODO be removed?

CLogMessage(this).error(
u"No models for matching ('%1'), swift without a model set will not work! Note: If you are using "
u"MSFS2024 and starting the GUI for the first time, it may take some time for the model set to load.")
<< simulator.toQString();
}
else if (!duplicateModels.isEmpty())
Expand Down
27 changes: 19 additions & 8 deletions src/core/airspacemonitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,12 @@ namespace swift::core
if (!this->isConnectedAndNotShuttingDown()) { return; }
Q_ASSERT_X(!callsign.isEmpty(), Q_FUNC_INFO, "missing callsign");

CStatusMessageList reverseLookupMessages;
CCallsign::addLogDetailsToList(&reverseLookupMessages, callsign,
QStringLiteral("CAirspaceMonitor::sendReadyForModelMatching Flag: %1").arg(rf),
CAirspaceMonitor::getLogCategories());
// TODO remove

Comment on lines +550 to +555

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this be removed now?

// set flag and init ts
Readiness &readiness = this->addMatchingReadinessFlag(callsign, rf);

Expand Down Expand Up @@ -863,13 +869,18 @@ namespace swift::core
CAirspaceMonitor::getLogCategories());

const CClient client = this->getClientOrDefaultForCallsign(callsign);
this->addOrUpdateAircraftInRange(callsign, aircraftIcaoDesignator, airlineIcaoDesignator, livery,
client.getQueriedModelString(), CAircraftModel::TypeQueriedFromNetwork,
pReverseLookupMessages);
this->addReverseLookupMessages(callsign, reverseLookupMessages);
this->sendReadyForModelMatching(callsign, ReceivedIcaoCodes); // ICAO codes received
const CSimulatedAircraft aircraft = this->addOrUpdateAircraftInRange(
callsign, aircraftIcaoDesignator, airlineIcaoDesignator, livery, client.getQueriedModelString(),
CAircraftModel::TypeQueriedFromNetwork, pReverseLookupMessages);

emit this->requestedNewAircraft(callsign, aircraftIcaoDesignator, airlineIcaoDesignator, livery);
// we do not change manually assigned models
if (aircraft.getModel().getModelType() != CAircraftModel::TypeManuallySet)
Comment on lines +876 to +877

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why wasn't this previously required? Was it a bug or is this case only reached with MSFS24?

{
this->addReverseLookupMessages(callsign, reverseLookupMessages);
this->sendReadyForModelMatching(callsign, ReceivedIcaoCodes); // ICAO codes received

emit this->requestedNewAircraft(callsign, aircraftIcaoDesignator, airlineIcaoDesignator, livery);
}
}

CAircraftModel CAirspaceMonitor::reverseLookupModelWithFlightplanData(
Expand Down Expand Up @@ -1176,8 +1187,8 @@ namespace swift::core
const CSimulatedAircraft aircraft = this->getAircraftInRangeForCallsign(callsign);
if (aircraft.hasValidCallsign())
{
// only if we do not have a DB model yet
if (!aircraft.getModel().hasValidDbKey())
// we do not change manually assigned models (msfs2024)
if (!aircraft.getModel().hasValidDbKey() && aircraft.getModelType() != CAircraftModel::TypeManuallySet)
Comment on lines -1179 to +1191

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why wasn't this previously required? Was it a bug or is this case only reached with MSFS24?

{
CAircraftModel model = this->reverseLookupModelWithFlightplanData(callsign, aircraftIcao, airlineIcao,
livery, modelString, modelType, log);
Expand Down
2 changes: 1 addition & 1 deletion src/core/context/contextsimulatorimpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ namespace swift::core::context
{
Q_ASSERT_X(simulator.isSingleSimulator(), Q_FUNC_INFO, "Need single simulator");
if (isDebugEnabled()) { CLogMessage(this, CLogCategories::contextSlot()).debug() << Q_FUNC_INFO; }
if (this->isSimulatorAvailable()) { return; } // if a plugin is loaded, do ignore this
if (this->isSimulatorAvailable() && !simulator.isMSFS2024()) return; // if a plugin is loaded, do ignore this

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extend the comment why MSFS2024 is not skipped here.

m_modelSetSimulator.set(simulator);
const CAircraftModelList models = this->getModelSet(); // cache synced
m_aircraftMatcher.setModelSet(models, simulator, false);
Expand Down
4 changes: 4 additions & 0 deletions src/core/db/databaseutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ namespace swift::core::db
dbModelModified.updateMissingParts(model);
dbModelModified.setDistributorOrder(distributorOrder);
dbModelModified.setSimulator(dbModel.getSimulator()); // DB simulator settings have priority
dbModelModified.setModelLivery(model.getModelLivery()); // keep local livery settings msfs2024

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why couldn't we take the livery string data from the database? Why to keep the local settings?

return dbModelModified;
}

Expand All @@ -88,6 +89,7 @@ namespace swift::core::db
{
if (modified) { *modified = true; }
consolidatedModel.setLivery(dbLivery);
consolidatedModel.setModelLivery(model.getModelLivery()); // keep local livery settings msfs2024

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this call required? consolidatedModel is initialized with model and setLivery() does not seem to overwrite the MSFS model livery string.

}
}
if (!consolidatedModel.getAircraftIcaoCode().hasValidDbKey() && consolidatedModel.hasAircraftDesignator())
Expand All @@ -99,6 +101,7 @@ namespace swift::core::db
{
if (modified) { *modified = true; }
consolidatedModel.setAircraftIcaoCode(dbIcao);
consolidatedModel.setModelLivery(model.getModelLivery()); // keep local livery settings msfs2024

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this call required? consolidatedModel is initialized with model and setAircraftIcaoCode() does not seem to overwrite the MSFS model livery string.

}
}

Expand All @@ -108,6 +111,7 @@ namespace swift::core::db
{
if (modified) { *modified = true; }
consolidatedModel.setDistributor(dbDistributor);
consolidatedModel.setModelLivery(model.getModelLivery()); // keep local livery settings msfs2024

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this call required? consolidatedModel is initialized with model and setDistributor() does not seem to overwrite the MSFS model livery string.

}
consolidatedModel.updateLocalFileNames(model);
consolidatedModel.setDistributorOrder(distributorOrder);
Expand Down
5 changes: 3 additions & 2 deletions src/core/modelsetbuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,9 @@ namespace swift::core
}
else
{
// without any information we can not use them
modelSet = modelSet.findWithKnownAircraftDesignator();
if (!options.testFlag(ShowAllInstalledModels))
// without any information we can not use them
modelSet = modelSet.findWithKnownAircraftDesignator();
}
Comment on lines +52 to 55

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really want all installed models in a modelset, even with unknown aircraft designator?

Is there a use case for it with MSFS24 or was it just a general bug?


// Include only
Expand Down
3 changes: 2 additions & 1 deletion src/core/modelsetbuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ namespace swift::core
OnlyDbIcaoCodes = 1 << 2,
Incremental = 1 << 3,
SortByDistributors = 1 << 4,
ConsolidateWithDb = 1 << 5
ConsolidateWithDb = 1 << 5,
ShowAllInstalledModels = 1 << 6,
};
Q_DECLARE_FLAGS(Builder, BuilderFlag)

Expand Down
19 changes: 19 additions & 0 deletions src/gui/components/dbownmodelscomponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,22 @@ namespace swift::gui::components
ui->tvp_OwnAircraftModels->updateContainerMaybeAsync(this->getOwnModels());
}

// TODO TZ this is a stub for SimConnect loading

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this TODO be removed?

void CDbOwnModelsComponent::loadInstalledModelsSimConnect(const CSimulatorInfo &simulator,

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe rename to: showLogMessageSimConnectLoading or similar

IAircraftModelLoader::LoadMode mode,
const QStringList &modelDirectories)
{
Q_UNUSED(mode);
Q_UNUSED(modelDirectories);

using namespace std::chrono_literals;
const CStatusMessage msg = CLogMessage(this).info(u"Triiger loading models for %1 from SimConnect")

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const CStatusMessage msg = CLogMessage(this).info(u"Triiger loading models for %1 from SimConnect")
const CStatusMessage msg = CLogMessage(this).info(u"Trigger loading models for %1 from SimConnect")

<< simulator.toQString();
this->showOverlayHTMLMessage(msg, 2s);

return;
}

void CDbOwnModelsComponent::loadInstalledModels(const CSimulatorInfo &simulator,
IAircraftModelLoader::LoadMode mode,
const QStringList &modelDirectories)
Expand Down Expand Up @@ -512,6 +528,9 @@ namespace swift::gui::components
IAircraftModelLoader::LoadMode mode,
const QStringList &modelDirectories)
{
// TODO TZ add SimConnect loading

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this TODO be removed?

if (simulator.isMSFS2024()) this->loadInstalledModelsSimConnect(simulator, mode, modelDirectories);

this->loadInstalledModels(simulator, mode, modelDirectories);
}

Expand Down
9 changes: 8 additions & 1 deletion src/gui/components/dbownmodelscomponent.h
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,8 @@ namespace swift::gui
void ownModelsSimulatorChanged(const swift::misc::simulation::CSimulatorInfo &simulator);

private:
static constexpr std::chrono::milliseconds OverlayMsgTimeout { 5000 }; //!< how long overlay is displayed

QScopedPointer<Ui::CDbOwnModelsComponent> ui;
swift::misc::simulation::IAircraftModelLoader *m_modelLoader =
nullptr; //!< read own aircraft models, aka models on disk
Expand All @@ -167,7 +169,12 @@ namespace swift::gui
//! Request own models
void requestOwnModelsUpdate();

//! Load the models
//! Load the models via SimConnect

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this should stay a stub just to display message. Adjust the comment and describe what this function will do and that it does not actually load the models itself.

void loadInstalledModelsSimConnect(const swift::misc::simulation::CSimulatorInfo &simulator,
swift::misc::simulation::IAircraftModelLoader::LoadMode mode,
const QStringList &modelDirectories = {});

//! Load the models via disk
void loadInstalledModels(const swift::misc::simulation::CSimulatorInfo &simulator,
swift::misc::simulation::IAircraftModelLoader::LoadMode mode,
const QStringList &modelDirectories = {});
Expand Down
7 changes: 6 additions & 1 deletion src/gui/components/mappingcomponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,8 @@ namespace swift::gui::components
}
const CCallsign callsign(this->validateRenderedCallsign());
if (callsign.isEmpty()) { return; }

// Because of msfs2024, the model string contains the combination of title and livery.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code does not seem to be specific about MSFS2024. Remove it?

const QString modelString = ui->completer_ModelStrings->getModelString();
if (modelString.isEmpty())
{
Expand Down Expand Up @@ -375,6 +377,7 @@ namespace swift::gui::components
}

CAircraftModel model(models.front());
// found more than one model?
if (models.size() > 1)
{
if (models.containsModelString(modelString))
Expand All @@ -391,8 +394,10 @@ namespace swift::gui::components
model.setModelType(CAircraftModel::TypeManuallySet);
CLogMessage(this).info(u"Requesting changes for '%1'") << callsign.asString();

// enable in any case
// rendering-flag enable in any case
sGui->getIContextNetwork()->updateAircraftEnabled(aircraftFromBackend.getCallsign(), true);

// trigger model change
changed =
sGui->getIContextNetwork()->updateAircraftModel(aircraftFromBackend.getCallsign(), model, identifier());
}
Expand Down
Loading