Skip to content

Commit

Permalink
Improve Linux edition detection
Browse files Browse the repository at this point in the history
  • Loading branch information
oblivioncth committed Jun 30, 2024
1 parent fe74bc9 commit 89430b7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
6 changes: 3 additions & 3 deletions lib/include/fp/fp-install.h
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ class Install::VersionInfo
{
//-Class Enums---------------------------------------------------------------------------------------------------
public:
enum Edition {Ultimate, Infinity, Core};
enum Edition { Ultimate, Infinity, Linux, Core, Unknown };

//-Class Variables
private:
Expand All @@ -208,9 +208,9 @@ class Install::VersionInfo
static inline const QString VER_TXT_GRP_NICK = u"n"_s;
static inline const QRegularExpression VER_TXT_REGEX = QRegularExpression(
uR"([fF]lashpoint\s+(?<)"_s + VER_TXT_GRP_EDITIONA +
uR"(>[a-zA-Z]+)?\s*(?<)"_s + VER_TXT_GRP_VERSION +
uR"(>[a-zA-Z ]+)?\s*(?<)"_s + VER_TXT_GRP_VERSION +
uR"(>[0-9]+(?:\.[0-9]+)?)?\s*(?<)"_s + VER_TXT_GRP_EDITIONB +
uR"(>[a-zA-Z]+)?\s+-\s+(?<)"_s + VER_TXT_GRP_NICK +
uR"(>[a-zA-Z ]+)?\s+-\s+(?<)"_s + VER_TXT_GRP_NICK +
uR"(>.*))"_s
);

Expand Down
11 changes: 8 additions & 3 deletions lib/src/fp-install.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,10 @@ Install::Install(QString installPath, bool preloadPlaylists) :
mVersionInfo = std::make_shared<VersionInfo>(verTxtStr);

// Ensure expected datapack source exists on Infinity
if(!mVersionInfo->isNull() && mVersionInfo->edition() == VersionInfo::Infinity && (!mPreferences.gameDataSources || !mPreferences.gameDataSources->contains(MAIN_DATAPACK_SOURCE)))
bool onlineEdition = !mVersionInfo->isNull() && (mVersionInfo->edition() == VersionInfo::Infinity || mVersionInfo->edition() == VersionInfo::Linux);
bool canDownload = mPreferences.gameDataSources && mPreferences.gameDataSources->contains(MAIN_DATAPACK_SOURCE);
// Could use Toolkit::canDownloadDatapacks() here, but we need to check for the main datasource specifically since that's all we're setup to handle
if(onlineEdition && !canDownload)
{
mError = InstallError(InstallError::DatapackSourceMissing, MAIN_DATAPACK_SOURCE);
return;
Expand Down Expand Up @@ -257,7 +260,7 @@ QDir Install::platformLogosDirectory() const { return mPlatformLogosDirectory; }
//-Constructor------------------------------------------------------------------------------------------------
//Public:
Install::VersionInfo::VersionInfo(const QString& verTxtStr) :
mEdition(Edition::Core)
mEdition(Edition::Unknown)
{
QRegularExpressionMatch rem = VER_TXT_REGEX.match(verTxtStr);
if(!rem.hasMatch() ||
Expand All @@ -273,7 +276,9 @@ Install::VersionInfo::VersionInfo(const QString& verTxtStr) :
QString edStr = rem.hasCaptured(VER_TXT_GRP_EDITIONA) ? rem.captured(VER_TXT_GRP_EDITIONA) : rem.captured(VER_TXT_GRP_EDITIONB);
mEdition = edStr.contains(u"ultimate"_s, Qt::CaseInsensitive) ? Edition::Ultimate :
edStr.contains(u"infinity"_s, Qt::CaseInsensitive) ? Edition::Infinity :
Edition::Core;
edStr.contains(u"core"_s, Qt::CaseInsensitive) ? Edition::Core :
edStr.contains(u"linux"_s, Qt::CaseInsensitive) ? Edition::Linux :
Edition::Unknown;
mVersion = Qx::VersionNumber::fromString(rem.captured(VER_TXT_GRP_VERSION));
Q_ASSERT(!mVersion.isNull()); // Regex should fail before this
mNickname = rem.captured(VER_TXT_GRP_NICK);
Expand Down

0 comments on commit 89430b7

Please sign in to comment.