diff --git a/src/plugins/simulator/xplane/simulatorxplane.cpp b/src/plugins/simulator/xplane/simulatorxplane.cpp index 9e55dd741..cfb039873 100644 --- a/src/plugins/simulator/xplane/simulatorxplane.cpp +++ b/src/plugins/simulator/xplane/simulatorxplane.cpp @@ -1216,9 +1216,9 @@ namespace BlackSimPlugin QString swiftVersion = BlackConfig::CBuildConfig::getVersionString(); QString xswiftbusVersion = service.getVersionNumber(); - if (! swiftVersion.contains(xswiftbusVersion)) + if (swiftVersion != xswiftbusVersion) { - CLogMessage(this).error(u"You are using an incorrect version of XSwiftBus. Make sure to install %1 into X-Plane plugins!") << xswiftbusVersion; + CLogMessage(this).error(u"You are using an incorrect version of XSwiftBus. The version of XSwiftBus must match the version of swift being %1.") << swiftVersion; return; } diff --git a/src/xswiftbus/service.cpp b/src/xswiftbus/service.cpp index 795381454..78578fc50 100644 --- a/src/xswiftbus/service.cpp +++ b/src/xswiftbus/service.cpp @@ -35,6 +35,21 @@ namespace XSwiftBus emitAircraftModelChanged(path, filename, getAircraftLivery(), getAircraftIcaoCode(), acfProperties.modelString, acfProperties.modelName, getAircraftDescription()); } + std::string CService::getVersionNumber() const + { + std::string version(XSWIFTBUS_VERSION); + const std::string lastCommitTs(GIT_COMMIT_TS); + + const long long lctsll = std::stoll(lastCommitTs); // at least 64bit + // now we have to converto int + // max 2147483647 (2^31 - 1) + // 1MMddHHmm (years since 2010) + const long long yearOffset = 201000000000; + const int lctsInt = static_cast(lctsll - yearOffset); + version = version + "." + std::to_string(lctsInt); + return version; + } + void CService::addTextMessage(const std::string &text, double red, double green, double blue) { if (text.empty()) { return; } diff --git a/src/xswiftbus/service.h b/src/xswiftbus/service.h index dd5f17331..bd1f5d47f 100644 --- a/src/xswiftbus/service.h +++ b/src/xswiftbus/service.h @@ -61,7 +61,7 @@ namespace XSwiftBus void onAircraftModelChanged(); //! Returns the XSwiftBus version number - std::string getVersionNumber() const { return XSWIFTBUS_VERSION; } + std::string getVersionNumber() const; //! Add a text message to the on-screen display, with RGB components in the range [0,1] void addTextMessage(const std::string &text, double red, double green, double blue); diff --git a/src/xswiftbus/xswiftbus.pro b/src/xswiftbus/xswiftbus.pro index 2a1f4d1fc..a94aeec3f 100644 --- a/src/xswiftbus/xswiftbus.pro +++ b/src/xswiftbus/xswiftbus.pro @@ -72,7 +72,19 @@ DEFINES += XPLM210=1 DEFINES += XPMP_CLIENT_NAME=\\\"xswiftbus\\\" DEFINES += XPMP_CLIENT_LONGNAME=\\\"xswiftbus\\\" +win32: GIT_BIN = $$system($$(SYSTEMROOT)\system32\where git 2> nul) +else: GIT_BIN = $$system(which git 2> /dev/null) + +isEmpty(GIT_BIN) { + GIT_HEAD_SHA1="" + GIT_COMMIT_TS="0" +} else { + GIT_HEAD_SHA1=$$system(git rev-parse --short HEAD) + GIT_COMMIT_TS=$$system(git log -1 --date=format:'%Y%m%d%H%M' --pretty=format:%cd) +} + DEFINES += XSWIFTBUS_VERSION=\\\"$$swiftConfig(version.full)\\\" +DEFINES += GIT_COMMIT_TS=\\\"$$GIT_COMMIT_TS\\\" # X-Plane plugins must follow a prescribed filename and directory structure. TARGET_EXT = .xpl