Add CMake option to enable stricter DRM

This commit is contained in:
Lenny McLennington 2023-05-07 08:16:29 +01:00
parent 2358e6faa2
commit 19673a7d59
No known key found for this signature in database
GPG Key ID: F0467078ECA45FCB
5 changed files with 21 additions and 8 deletions

View File

@ -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

View File

@ -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;

View File

@ -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"),

View File

@ -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"),

View File

@ -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 "