Skip to content

Commit

Permalink
Addedd support for MSFS 2024
Browse files Browse the repository at this point in the history
Now loading airports using SimConnect
albar965/littlenavmap#1198
  • Loading branch information
albar965 committed Dec 25, 2024
1 parent 58beb22 commit 6e5ea1d
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 9 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
*.cache/
*.d
*.db
*.dll
*.exe
*.lib
*.o
Expand Down
2 changes: 1 addition & 1 deletion config/navdatareader.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ IncludeFilenames=
# bvcf.bgl CENTER type airspace boundaries.
# BNXWorld* Geopolitical and airspace boundaries.
# Exclude DEM, bridges and other scenery per default
ExcludeFilenames=brx*,obx*,cvx*,dem*,wsx*
ExcludeFilenames=brx*.bgl,obx*.bgl,cvx*.bgl,dem*.bgl,wsx*.bgl,traffic*.bgl,AIRACCycle.bgl

# Filter files by path relative from scenery.cfg minus the scenery directory
# Example: Addon Scenery/JetwayExclude/*,Scenery/0501/*,Scenery/0601/*
Expand Down
2 changes: 1 addition & 1 deletion config/navdatareader_1801.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ IncludeFilenames=
# bvcf.bgl CENTER type airspace boundaries.
# BNXWorld* Geopolitical and airspace boundaries.
# Exclude DEM, bridges and other scenery per default
ExcludeFilenames=brx*,obx*,cvx*,dem*,wsx*
ExcludeFilenames=brx*.bgl,obx*.bgl,cvx*.bgl,dem*.bgl,wsx*.bgl,traffic*.bgl,AIRACCycle.bgl

# Filter files by path relative from scenery.cfg minus the scenery directory
# Example: Addon Scenery/JetwayExclude/*,Scenery/0501/*,Scenery/0601/*
Expand Down
22 changes: 18 additions & 4 deletions navdatareader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include "logging/logginghandler.h"
#include "logging/loggingutil.h"
#include "settings/settings.h"
#include "win/activationcontext.h"

#include <QCommandLineParser>
#include <QSettings>
Expand All @@ -32,6 +33,12 @@ using atools::sql::SqlDatabase;
using atools::fs::NavDatabaseErrors;
using atools::fs::FsPaths;

#if defined(WINARCH64)
const QLatin1String SIMCONNECT_LOADER_DLL_NAME("SimConnect_msfs_2024.dll");
#else
const QLatin1String SIMCONNECT_LOADER_DLL_NAME;
#endif

void NavdataReader::run()
{
// Fill NavDatabaseOptions from command line
Expand Down Expand Up @@ -70,9 +77,14 @@ void NavdataReader::run()
// FKs don't work currently
db.open(DATABASE_PRAGMAS);

atools::win::ActivationContext context;
context.loadLibrary(SIMCONNECT_LOADER_DLL_NAME);

atools::fs::NavDatabaseErrors errors;
atools::fs::NavDatabase nd(&opts, &db, &errors, GIT_REVISION_NAVDATAREADER);
resultFlags = nd.compileDatabase();
atools::fs::NavDatabase navDatabase(&opts, &db, &errors, GIT_REVISION_NAVDATAREADER);
navDatabase.setActivationContext(&context, SIMCONNECT_LOADER_DLL_NAME);

resultFlags = navDatabase.compileDatabase();
db.close();

if(errors.getTotalErrors() > 0)
Expand Down Expand Up @@ -111,7 +123,7 @@ void NavdataReader::parseArgs()

QCommandLineOption fstypeOpt({"f", "flight-simulator"},
QObject::tr("Required option. Flight simulator type <simulator> or other data source. "
"Either FSX, FSXSE, P3DV2, P3DV3, P3DV4, P3DV5, P3DV6, XP11, XP12, MSFS or DFD."),
"Either FSX, FSXSE, P3DV2, P3DV3, P3DV4, P3DV5, P3DV6, XP11, XP12, MSFS, MSFS24 or DFD."),
QObject::tr("simulator"));
parser.addOption(fstypeOpt);

Expand Down Expand Up @@ -209,7 +221,7 @@ void NavdataReader::parseArgs()
}

// Scenery.cfg only FSX and P3D ===================================================
if(!FsPaths::isAnyXplane(type) && type != FsPaths::DFD && type != FsPaths::MSFS)
if(!FsPaths::isAnyXplane(type) && type != FsPaths::DFD && type != FsPaths::MSFS && type != FsPaths::MSFS_2024)
{
QString sceneryFile = parser.value(sceneryOpt);
if(sceneryFile.isEmpty())
Expand All @@ -225,6 +237,8 @@ void NavdataReader::parseArgs()
opts.setMsfsCommunityPath(FsPaths::getMsfsCommunityPath(opts.getBasepath()));
opts.setMsfsOfficialPath(FsPaths::getMsfsOfficialPath(opts.getBasepath()));
}
else if(type == FsPaths::MSFS_2024)
opts.setMsfs24StreamedPackagesPath(FsPaths::getMsfs24StreamedPackagesPath());

// Configuration file ===================================================
configFile = parser.value(cfgOpt);
Expand Down
18 changes: 17 additions & 1 deletion navdatareader.pro
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ TARGET_NAME=Navdatareader
ATOOLS_INC_PATH=$$(ATOOLS_INC_PATH)
ATOOLS_LIB_PATH=$$(ATOOLS_LIB_PATH)
ATOOLS_NO_CRASHHANDLER=$$(ATOOLS_NO_CRASHHANDLER)
SIMCONNECT_PATH_WIN64_MSFS_2024=$$(ATOOLS_SIMCONNECT_PATH_WIN64_MSFS_2024)

GIT_PATH=$$(ATOOLS_GIT_PATH)
DEPLOY_BASE=$$(DEPLOY_BASE)
Expand Down Expand Up @@ -92,9 +93,20 @@ unix:!macx {
}

win32 {
# MSFS
WINARCH = win64
!isEmpty(SIMCONNECT_PATH_WIN64_MSFS_2024) {
DEFINES += SIMCONNECT_BUILD_WIN64 WINARCH64
INCLUDEPATH += $$SIMCONNECT_PATH_WIN64_MSFS_2024"\include"
LIBS += $$SIMCONNECT_PATH_WIN64_MSFS_2024"\lib\SimConnect.lib"
}

WINDEPLOY_FLAGS = --compiler-runtime
CONFIG(debug, debug|release) : WINDEPLOY_FLAGS += --debug
# CONFIG(release, debug|release) : WINDEPLOY_FLAGS += --release

DEFINES += _USE_MATH_DEFINES

LIBS += -L$$ATOOLS_LIB_PATH -latools -lz
}

macx {
Expand Down Expand Up @@ -159,6 +171,7 @@ message(GIT_PATH: $$GIT_PATH)
message(ATOOLS_INC_PATH: $$ATOOLS_INC_PATH)
message(ATOOLS_LIB_PATH: $$ATOOLS_LIB_PATH)
message(ATOOLS_NO_CRASHHANDLER: $$ATOOLS_NO_CRASHHANDLER)
message(SIMCONNECT_PATH_WIN64_MSFS_2024: $$SIMCONNECT_PATH_WIN64_MSFS_2024)
message(DEPLOY_BASE: $$DEPLOY_BASE)
message(DEFINES: $$DEFINES)
message(INCLUDEPATH: $$INCLUDEPATH)
Expand Down Expand Up @@ -249,6 +262,9 @@ win32 {
deploy.commands += xcopy /F $$p($$PWD/CHANGELOG.txt) $$p($$DEPLOY_BASE/$$TARGET_NAME) &&
deploy.commands += xcopy /F $$p($$PWD/README.txt) $$p($$DEPLOY_BASE/$$TARGET_NAME) &&
deploy.commands += xcopy /F $$p($$PWD/LICENSE.txt) $$p($$DEPLOY_BASE/$$TARGET_NAME) &&
exists($$SIMCONNECT_PATH_WIN64_MSFS_2024/lib/SimConnect.dll) {
deploy.commands += copy /Y $$p($$SIMCONNECT_PATH_WIN64_MSFS_2024/lib/SimConnect.dll) $$p($$DEPLOY_BASE/$$TARGET_NAME/SimConnect_msfs_2024.dll) &&
}
deploy.commands += xcopy /F $$p($$[QT_INSTALL_BINS]/libgcc*.dll) $$p($$DEPLOY_BASE/$$TARGET_NAME) &&
deploy.commands += xcopy /F $$p($$[QT_INSTALL_BINS]/libstdc*.dll) $$p($$DEPLOY_BASE/$$TARGET_NAME) &&
deploy.commands += xcopy /F $$p($$[QT_INSTALL_BINS]/libwinpthread*.dll) $$p($$DEPLOY_BASE/$$TARGET_NAME) &&
Expand Down
2 changes: 1 addition & 1 deletion resources/config/navdatareader.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ IncludeFilenames=
# bvcf.bgl CENTER type airspace boundaries.
# BNXWorld* Geopolitical and airspace boundaries.
# Exclude DEM, bridges and other scenery per default
ExcludeFilenames=brx*,obx*,cvx*,dem*,wsx*
ExcludeFilenames=brx*.bgl,obx*.bgl,cvx*.bgl,dem*.bgl,wsx*.bgl,traffic*.bgl,AIRACCycle.bgl

# Filter files by path relative from scenery.cfg minus the scenery directory
# Example: Addon Scenery/JetwayExclude/*,Scenery/0501/*,Scenery/0601/*
Expand Down

0 comments on commit 6e5ea1d

Please sign in to comment.