diff --git a/CMakeLists.txt b/CMakeLists.txt index 05175405..bbac1d87 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -138,6 +138,8 @@ set(Launcher_MSA_CLIENT_ID "6b329578-bfec-42a3-b503-303ab3f2ac96" CACHE STRING " set(Launcher_CURSEFORGE_API_KEY "" CACHE STRING "API key for the CurseForge platform") set(Launcher_CURSEFORGE_API_KEY_API_URL "https://cf.polymc.org/api" CACHE STRING "URL to fetch the Curseforge API key from.") +# Enable artificial DRM beyond what is forced by Mojang +set(Launcher_STRICT_DRM OFF CACHE BOOL "Enables artificial DRM, beyond what is done by Mojang, that prevents you from using offline mode or custom yggdrasil without having a valid Minecraft account added first. This shouldn't need to be enabled unless you're distributing the software on some repo that would require you to enable it.") #### Check the current Git commit and branch include(GetGitRevisionDescription) @@ -151,6 +153,13 @@ message(STATUS "Git refspec: ${Launcher_GIT_REFSPEC}") string(TIMESTAMP TODAY "%Y-%m-%d") set(Launcher_BUILD_TIMESTAMP "${TODAY}") +############################ Macro Definitions ############################# + +if (Launcher_STRICT_DRM) + message("Strict DRM is enabled.") + set(Launcher_APP_BINARY_DEFS ${Launcher_APP_BINARY_DEFS} LAUNCHER_STRICT_DRM) +endif() + ################################ 3rd Party Libs ################################ # Find the required Qt parts diff --git a/launcher/minecraft/auth/AccountList.h b/launcher/minecraft/auth/AccountList.h index 8136a92e..59e8a320 100644 --- a/launcher/minecraft/auth/AccountList.h +++ b/launcher/minecraft/auth/AccountList.h @@ -109,6 +109,14 @@ public: MinecraftAccountPtr defaultAccount() const; void setDefaultAccount(MinecraftAccountPtr profileId); bool anyAccountIsValid(); + bool drmCheck() + { +#ifdef LAUNCHER_STRICT_DRM + return anyAccountIsValid(); +#else + return true; +#endif + } bool isActive() const; diff --git a/launcher/ui/MainWindow.cpp b/launcher/ui/MainWindow.cpp index e5664b15..ec635370 100644 --- a/launcher/ui/MainWindow.cpp +++ b/launcher/ui/MainWindow.cpp @@ -1700,8 +1700,7 @@ void MainWindow::finalizeInstance(InstancePtr inst) { view->updateGeometries(); setSelectedInstanceById(inst->id()); - if (APPLICATION->accounts()->anyAccountIsValid()) - { + if (APPLICATION->accounts()->drmCheck()) { ProgressDialog loadDialog(this); auto update = inst->createUpdateTask(Net::Mode::Online); connect(update.get(), &Task::failed, [this](QString reason) @@ -1714,9 +1713,7 @@ void MainWindow::finalizeInstance(InstancePtr inst) loadDialog.setSkipButton(true, tr("Abort")); loadDialog.execWithTask(update.get()); } - } - else - { + } else { CustomMessageBox::selectable( this, tr("Error"), diff --git a/launcher/ui/pages/global/AccountListPage.cpp b/launcher/ui/pages/global/AccountListPage.cpp index a4f4dfb9..8359bb62 100644 --- a/launcher/ui/pages/global/AccountListPage.cpp +++ b/launcher/ui/pages/global/AccountListPage.cpp @@ -188,7 +188,7 @@ void AccountListPage::on_actionAddMicrosoft_triggered() void AccountListPage::on_actionAddOffline_triggered() { - if (!m_accounts->anyAccountIsValid()) { + if (!m_accounts->drmCheck()) { QMessageBox::warning( this, tr("Error"), diff --git a/launcher/ui/pages/instance/VersionPage.cpp b/launcher/ui/pages/instance/VersionPage.cpp index a021c633..772d6759 100644 --- a/launcher/ui/pages/instance/VersionPage.cpp +++ b/launcher/ui/pages/instance/VersionPage.cpp @@ -422,8 +422,7 @@ void VersionPage::on_actionChange_version_triggered() void VersionPage::on_actionDownload_All_triggered() { - if (!APPLICATION->accounts()->anyAccountIsValid()) - { + if (!APPLICATION->accounts()->drmCheck()) { CustomMessageBox::selectable( this, tr("Error"), tr("Cannot download Minecraft or update instances unless you have at least "