From 5afca07f1e105fd7f4558d407056a3039928618b Mon Sep 17 00:00:00 2001 From: Joshua Goins Date: Thu, 27 Jan 2022 09:25:23 -0500 Subject: [PATCH] Make Watchdog an optional feature --- CMakeLists.txt | 36 ++++++++++++++++++++++++++---------- src/launchercore.cpp | 8 ++++++++ src/settingswindow.cpp | 7 +++++-- src/squarelauncher.cpp | 7 +++++++ 4 files changed, 46 insertions(+), 12 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 081f263..1725960 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,6 +8,14 @@ set(CMAKE_CXX_STANDARD 17) find_package(Qt5 COMPONENTS Core Widgets Network CONFIG REQUIRED) +option(ENABLE_WATCHDOG "Build with Tesseract support (needed for Watchdog)" OFF) + +if(ENABLE_WATCHDOG) + find_package(PkgConfig REQUIRED) + pkg_search_module(TESSERACT REQUIRED tesseract) + pkg_search_module(LEPTONICA REQUIRED lept) +endif() + add_subdirectory(external) set(SRC @@ -21,21 +29,23 @@ set(SRC src/assetupdater.cpp src/assetupdater.h src/launcherwindow.cpp - src/launcherwindow.h - src/watchdog.h - src/watchdog.cpp) + src/launcherwindow.h) set(LIBRARIES Qt5::Core Qt5::Widgets Qt5::Network qt5keychain QuaZip) -if(UNIX) - set(SRC ${SRC} - src/gameparser.h - src/gameparser.cpp) +if(ENABLE_WATCHDOG) + set(LIBRARIES ${LIBRARIES} ${TESSERACT_LIBRARIES} ${LEPTONICA_LIBRARIES}) + set(SRC ${SRC} + src/watchdog.h + src/watchdog.cpp + src/gameparser.h + src/gameparser.cpp) +endif() + +if(UNIX) set(LIBRARIES ${LIBRARIES} - tesseract - lept X11 Xcomposite Xrender) @@ -51,6 +61,12 @@ target_include_directories(xivlauncher PRIVATE ${CMAKE_BINARY_DIR}/_deps/qtkeychain-build ${CMAKE_BINARY_DIR}/_deps/quazip-src) +if(ENABLE_WATCHDOG) + target_include_directories(xivlauncher PRIVATE ${TESSERACT_INCLUDE_DIRS} ${LEPTONICA_INCLUDE_DIRS}) + + target_compile_definitions(xivlauncher PRIVATE ENABLE_WATCHDOG) +endif() + install(TARGETS xivlauncher DESTINATION "${INSTALL_BIN_PATH}" ) @@ -67,4 +83,4 @@ if(WIN32) POST_BUILD COMMAND "${WINDEPLOYQT_ENV_SETUP}" && "${WINDEPLOYQT_EXECUTABLE}" \"$\" ) -endif() \ No newline at end of file +endif() diff --git a/src/launchercore.cpp b/src/launchercore.cpp index ca16a6e..4282ffd 100755 --- a/src/launchercore.cpp +++ b/src/launchercore.cpp @@ -34,7 +34,10 @@ #include "settingswindow.h" #include "blowfish.h" #include "assetupdater.h" + +#ifdef ENABLE_WATCHDOG #include "watchdog.h" +#endif void LauncherCore::setSSL(QNetworkRequest& request) { QSslConfiguration config; @@ -370,7 +373,10 @@ LauncherCore::LauncherCore() : settings(QSettings::IniFormat, QSettings::UserSco squareLauncher = new SquareLauncher(*this); squareBoot = new SquareBoot(*this, *squareLauncher); assetUpdater = new AssetUpdater(*this); + +#ifdef ENABLE_WATCHDOG watchdog = new Watchdog(*this); +#endif readInitialInformation(); @@ -382,7 +388,9 @@ LauncherCore::LauncherCore() : settings(QSettings::IniFormat, QSettings::UserSco } LauncherCore::~LauncherCore() noexcept { +#ifdef ENABLE_WATCHDOG delete watchdog; +#endif } ProfileSettings LauncherCore::getProfile(int index) const { diff --git a/src/settingswindow.cpp b/src/settingswindow.cpp index 46f6de6..3c08ba7 100644 --- a/src/settingswindow.cpp +++ b/src/settingswindow.cpp @@ -91,7 +91,7 @@ SettingsWindow::SettingsWindow(LauncherWindow& window, LauncherCore& core, QWidg }); gameBoxLayout->addWidget(gameDirectoryButton); -#if defined(Q_OS_LINUX) +#ifdef ENABLE_WATCHDOG enableWatchdog = new QCheckBox("Enable Watchdog (X11 only)"); gameBoxLayout->addWidget(enableWatchdog); @@ -354,6 +354,9 @@ void SettingsWindow::reloadControls() { useEsync->setChecked(profile.useEsync); useGamescope->setChecked(profile.useGamescope); useGamemode->setChecked(profile.useGamemode); +#endif + +#ifdef ENABLE_WATCHDOG enableWatchdog->setChecked(profile.enableWatchdog); #endif @@ -385,4 +388,4 @@ void SettingsWindow::openPath(const QString path) { #else QDesktopServices::openUrl("file://" + path); #endif -} \ No newline at end of file +} diff --git a/src/squarelauncher.cpp b/src/squarelauncher.cpp index 50ca845..9f4d389 100644 --- a/src/squarelauncher.cpp +++ b/src/squarelauncher.cpp @@ -9,7 +9,10 @@ #include #include "launchercore.h" + +#ifdef ENABLE_WATCHDOG #include "watchdog.h" +#endif SquareLauncher::SquareLauncher(LauncherCore& window) : window(window) { @@ -124,11 +127,15 @@ void SquareLauncher::registerSession(const LoginInformation& info) { if(reply->rawHeaderList().contains("X-Patch-Unique-Id")) { auth.SID = reply->rawHeader("X-Patch-Unique-Id"); +#ifdef ENABLE_WATCHDOG if(info.settings->enableWatchdog) { window.watchdog->launchGame(*info.settings, auth); } else { window.launchGame(*info.settings, auth); } +#else + window.launchGame(*info.settings, auth); +#endif } else { auto messageBox = new QMessageBox(QMessageBox::Icon::Critical, "Failed to Login", "Failed the anti-tamper check. Please restore your game to the original state or update the game."); window.addUpdateButtons(*info.settings, *messageBox);