From 0538e332dc45cc51c155313b2715d0585f0caf09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivo=20Elezovi=C4=87?= Date: Thu, 9 May 2024 22:05:14 +0200 Subject: [PATCH] Support for new style of rawVersion notation. --- GameVersion.cpp | 5 +++++ tests/GameVersionTests.cpp | 8 ++++++++ tests/TestFiles/launcher-settings-1.37.json | 13 +++++++++++++ 3 files changed, 26 insertions(+) create mode 100644 tests/TestFiles/launcher-settings-1.37.json diff --git a/GameVersion.cpp b/GameVersion.cpp index be23a429..09410480 100644 --- a/GameVersion.cpp +++ b/GameVersion.cpp @@ -430,6 +430,11 @@ std::optional GameVersion::extractVersionByStringFromLauncher(const line = line.substr(0, pos); + if (!line.empty() && line[0] == 'v') + { + line = line.substr(1, line.length()); + } + try { return GameVersion(line); diff --git a/tests/GameVersionTests.cpp b/tests/GameVersionTests.cpp index ae25c006..71430372 100644 --- a/tests/GameVersionTests.cpp +++ b/tests/GameVersionTests.cpp @@ -432,6 +432,14 @@ TEST(GameVersion_Tests, extractVersionFromLauncherExtractsGameVersion) EXPECT_EQ(GameVersion("1.31.5"), *version); } +TEST(GameVersion_Tests, extractVVersionFromLauncherExtractsGameVersion) +{ + // They started adding v in front of a version, eg. v1.37.0.0 + const auto version = GameVersion::extractVersionFromLauncher("launcher-settings-1.37.json"); + + EXPECT_EQ(GameVersion("1.37.0"), *version); +} + TEST(GameVersion_Tests, extractVersionFromLauncherReturnsNulloptForMissingFile) { const auto version = GameVersion::extractVersionFromLauncher("launcher-settings.json2"); diff --git a/tests/TestFiles/launcher-settings-1.37.json b/tests/TestFiles/launcher-settings-1.37.json new file mode 100644 index 00000000..6823f422 --- /dev/null +++ b/tests/TestFiles/launcher-settings-1.37.json @@ -0,0 +1,13 @@ +{ + "gameId": "eu4", + "displayName": "Europa Universalis IV", + "version": "EU4 v1.37.0.0 Inca (3d19)", + "rawVersion": "v1.37.0.0", + "distPlatform": "steam", + "gameDataPath": "%USER_DOCUMENTS%/Paradox Interactive/Europa Universalis IV", + "ingameSettingsLayoutPath": "settings-layout.json", + "themeFile": "launcher-assets/theme-settings.json", + "browserDlcUrl": "https://www.paradoxplaza.com/games/?prefn1=pdx-brand&prefn2=pdx-type&prefv1=EU4%7CEuropa%20Universalis&prefv2=dlc", + "exePath": "./eu4.exe", + "exeArgs": [ "-enabletelemetry", "-gdpr-compliant" ] +}