1
Fork 0
mirror of https://github.com/redstrate/Astra.git synced 2025-05-13 21:07:46 +00:00

Simplify game installation

We don't actually need the official installer at all, the patch servers
can begin with an empty folder!
This commit is contained in:
Joshua Goins 2025-05-07 19:21:49 -04:00
parent 3118513d89
commit f5111be745
3 changed files with 17 additions and 69 deletions

View file

@ -27,19 +27,6 @@ add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/libphysis/logger EXCLUDE_FROM_ALL)
target_include_directories(physis INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/libphysis/target/public)
target_compile_definitions(physis INTERFACE ENABLE_GAME_INSTALL)
# We should use the CMake module everywhere once distros update their packages
if (WIN32)
# FIXME: unshield should include zlib in their upstream cmake
find_package(ZLIB REQUIRED)
find_package(unshield REQUIRED)
target_link_libraries(physis INTERFACE unshield::libunshield)
else()
find_package(PkgConfig REQUIRED)
pkg_check_modules(UNSHIELD REQUIRED IMPORTED_TARGET libunshield)
target_link_directories(physis INTERFACE ${UNSHIELD_LIBRARY_DIRS})
target_link_libraries(physis INTERFACE ${UNSHIELD_LIBRARIES})
endif()
set(KDSingleApplication_QT6 ON)
set(KDSingleApplication_STATIC ON)
add_subdirectory(kdsingleapplication EXCLUDE_FROM_ALL)

View file

@ -3,11 +3,7 @@
#include "gameinstaller.h"
#include <KLocalizedString>
#include <QFile>
#include <QNetworkReply>
#include <QStandardPaths>
#include <physis.hpp>
#include "astra_log.h"
#include "launchercore.h"
@ -15,9 +11,6 @@
#include "profileconfig.h"
#include "utility.h"
const auto installerUrl = QStringLiteral("https://download.finalfantasyxiv.com/inst/ffxivsetup.exe");
const QByteArray installerSha256 = QByteArray::fromHex("cf70bfaaf4f429794358ef84acbcbdc4193bee109fa1b6aea81bd4de038e500e");
GameInstaller::GameInstaller(LauncherCore &launcher, Profile &profile, QObject *parent)
: QObject(parent)
, m_launcher(launcher)
@ -33,50 +26,30 @@ GameInstaller::GameInstaller(LauncherCore &launcher, Profile &profile, const QSt
void GameInstaller::start()
{
if (m_localInstallerPath.isEmpty()) {
const auto request = QNetworkRequest(QUrl(installerUrl));
Utility::printRequest(QStringLiteral("GET"), request);
auto reply = m_launcher.mgr()->get(request);
QObject::connect(reply, &QNetworkReply::finished, [this, reply] {
if (reply->error() != QNetworkReply::NetworkError::NoError) {
Q_EMIT error(reply->errorString());
return;
}
const QDir dataDir = QStandardPaths::writableLocation(QStandardPaths::TempLocation);
const QByteArray data = reply->readAll();
QCryptographicHash hash(QCryptographicHash::Sha256);
hash.addData(data);
if (hash.result() != installerSha256) {
Q_EMIT error(i18n("The installer failed the integrity check!"));
return;
}
QFile file(dataDir.absoluteFilePath(QStringLiteral("ffxivsetup.exe")));
file.open(QIODevice::WriteOnly);
file.write(data);
file.close();
m_localInstallerPath = file.fileName();
installGame();
});
} else {
installGame();
}
installGame();
}
void GameInstaller::installGame()
{
const QDir installDirectory = m_profile.config()->gamePath();
const std::string installDirectoryStd = installDirectory.absolutePath().toStdString();
const std::string fileNameStd = m_localInstallerPath.toStdString();
const QDir bootDir = installDirectory.absoluteFilePath(QStringLiteral("boot"));
if (!bootDir.exists()) {
QDir().mkpath(bootDir.path());
}
physis_install_game(fileNameStd.c_str(), installDirectoryStd.c_str());
const QDir gameDir = installDirectory.absoluteFilePath(QStringLiteral("game"));
if (!gameDir.exists()) {
QDir().mkpath(gameDir.path());
}
QFile bootVerFile(bootDir.absoluteFilePath(QStringLiteral("ffxivboot.ver")));
bootVerFile.open(QIODevice::WriteOnly);
bootVerFile.write(QByteArrayLiteral("2012.01.01.0000.0000"));
QFile gameVerFile(gameDir.absoluteFilePath(QStringLiteral("ffxivgame.ver")));
gameVerFile.open(QIODevice::WriteOnly);
gameVerFile.write(QByteArrayLiteral("2012.01.01.0000.0000"));
m_profile.readGameVersion();

View file

@ -48,18 +48,6 @@ modules:
branch: master
cleanup:
- /lib/debug
- name: unshield
cleanup:
- /bin
- /include
- /lib/pkgconfig
buildsystem: cmake-ninja
config-opts:
- -DCMAKE_BUILD_TYPE=RelWithDebInfo
sources:
- type: git
url: https://github.com/twogood/unshield.git
branch: main
- name: libsecret
cleanup:
- /bin