Skip to content

Commit

Permalink
Dynamically grab frontier URL from the existing launcher
Browse files Browse the repository at this point in the history
Yet another thing we no longer have to worry about updating manually,
at least as often.

Fixes #8
  • Loading branch information
redstrate committed Jun 30, 2024
1 parent 8c956d9 commit b0b5b29
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 9 deletions.
2 changes: 1 addition & 1 deletion external/libphysis
Submodule libphysis updated 3 files
+1 −1 Cargo.lock
+14 −0 src/execlookup.rs
+2 −0 src/lib.rs
4 changes: 4 additions & 0 deletions launcher/include/profile.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,8 @@ class Profile : public QObject
[[nodiscard]] int numInstalledExpansions() const;
[[nodiscard]] QString expansionVersion(int index) const;

[[nodiscard]] QString frontierUrl() const;

[[nodiscard]] int dalamudAssetVersion() const;
void setDalamudAssetVersion(int version);

Expand Down Expand Up @@ -209,6 +211,8 @@ class Profile : public QObject
QString m_compatibilityToolVersion;
bool m_dalamudApplicable = false;

QString m_frontierUrl;

bool m_loggedIn = false;

LauncherCore &m_launcher;
Expand Down
18 changes: 10 additions & 8 deletions launcher/src/launchercore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -406,10 +406,11 @@ QCoro::Task<> LauncherCore::fetchNews()
QNetworkRequest headlineRequest(QUrl(QStringLiteral("%1&%2").arg(headlineUrl.toString(), QString::number(QDateTime::currentMSecsSinceEpoch()))));
headlineRequest.setRawHeader(QByteArrayLiteral("Accept"), QByteArrayLiteral("application/json, text/plain, */*"));
headlineRequest.setRawHeader(QByteArrayLiteral("Origin"), QByteArrayLiteral("https://launcher.finalfantasyxiv.com"));
headlineRequest.setRawHeader(QByteArrayLiteral("Referer"),
QStringLiteral("https://launcher.finalfantasyxiv.com/v600/index.html?rc_lang=%1&time=%2")
.arg(QStringLiteral("en-us"), QDateTime::currentDateTimeUtc().toString(QStringLiteral("yyyy-MM-dd-HH")))
.toUtf8());
headlineRequest.setRawHeader(
QByteArrayLiteral("Referer"),
QStringLiteral("%1/index.html?rc_lang=%2&time=%3")
.arg(currentProfile()->frontierUrl(), QStringLiteral("en-us"), QDateTime::currentDateTimeUtc().toString(QStringLiteral("yyyy-MM-dd-HH")))
.toUtf8());
Utility::printRequest(QStringLiteral("GET"), headlineRequest);

auto headlineReply = mgr()->get(headlineRequest);
Expand All @@ -424,10 +425,11 @@ QCoro::Task<> LauncherCore::fetchNews()
QNetworkRequest bannerRequest(QUrl(QStringLiteral("%1&_=%3").arg(bannerUrl.toString(), QString::number(QDateTime::currentMSecsSinceEpoch()))));
bannerRequest.setRawHeader(QByteArrayLiteral("Accept"), QByteArrayLiteral("application/json, text/plain, */*"));
bannerRequest.setRawHeader(QByteArrayLiteral("Origin"), QByteArrayLiteral("https://launcher.finalfantasyxiv.com"));
bannerRequest.setRawHeader(QByteArrayLiteral("Referer"),
QStringLiteral("https://launcher.finalfantasyxiv.com/v700/index.html?rc_lang=%1&time=%2")
.arg(QStringLiteral("en-us"), QDateTime::currentDateTimeUtc().toString(QStringLiteral("yyyy-MM-dd-HH")))
.toUtf8());
bannerRequest.setRawHeader(
QByteArrayLiteral("Referer"),
QStringLiteral("%1/v700/index.html?rc_lang=%2&time=%3")
.arg(currentProfile()->frontierUrl(), QStringLiteral("en-us"), QDateTime::currentDateTimeUtc().toString(QStringLiteral("yyyy-MM-dd-HH")))
.toUtf8());
Utility::printRequest(QStringLiteral("GET"), bannerRequest);

auto bannerReply = mgr()->get(bannerRequest);
Expand Down
14 changes: 14 additions & 0 deletions launcher/src/profile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,10 @@ void Profile::readGameVersion()
readGameData();
}

// Extract frontier url if possible
const QString launcherPath = QString(gamePath() + QStringLiteral("/boot/ffxivlauncher64.exe"));
m_frontierUrl = QString::fromUtf8(physis_extract_frontier_url(launcherPath.toStdString().c_str()));

Q_EMIT gameInstallChanged();
}

Expand Down Expand Up @@ -533,6 +537,16 @@ QString Profile::expansionVersion(const int index) const
return QString::fromLatin1(m_repositories.repositories[index + 1].version);
}

QString Profile::frontierUrl() const
{
if (m_frontierUrl.isEmpty()) {
// fallback url
return QStringLiteral("https://launcher.finalfantasyxiv.com/v600/");
} else {
return m_frontierUrl;
}
}

int Profile::dalamudAssetVersion() const
{
return m_dalamudAssetVersion;
Expand Down

0 comments on commit b0b5b29

Please sign in to comment.