Merge pull request #1595 from LennyMcLennington/drm-flag

Add CMake option to enable stricter DRM
This commit is contained in:
Lenny McLennington 2023-08-10 11:31:46 +01:00 committed by GitHub
commit b995074440
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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 "" 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.") 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 #### Check the current Git commit and branch
include(GetGitRevisionDescription) include(GetGitRevisionDescription)
@ -151,6 +153,13 @@ message(STATUS "Git refspec: ${Launcher_GIT_REFSPEC}")
string(TIMESTAMP TODAY "%Y-%m-%d") string(TIMESTAMP TODAY "%Y-%m-%d")
set(Launcher_BUILD_TIMESTAMP "${TODAY}") 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 ################################ ################################ 3rd Party Libs ################################
# Find the required Qt parts # Find the required Qt parts

View File

@ -109,6 +109,14 @@ public:
MinecraftAccountPtr defaultAccount() const; MinecraftAccountPtr defaultAccount() const;
void setDefaultAccount(MinecraftAccountPtr profileId); void setDefaultAccount(MinecraftAccountPtr profileId);
bool anyAccountIsValid(); bool anyAccountIsValid();
bool drmCheck()
{
#ifdef LAUNCHER_STRICT_DRM
return anyAccountIsValid();
#else
return true;
#endif
}
bool isActive() const; bool isActive() const;

View File

@ -1700,8 +1700,7 @@ void MainWindow::finalizeInstance(InstancePtr inst)
{ {
view->updateGeometries(); view->updateGeometries();
setSelectedInstanceById(inst->id()); setSelectedInstanceById(inst->id());
if (APPLICATION->accounts()->anyAccountIsValid()) if (APPLICATION->accounts()->drmCheck()) {
{
ProgressDialog loadDialog(this); ProgressDialog loadDialog(this);
auto update = inst->createUpdateTask(Net::Mode::Online); auto update = inst->createUpdateTask(Net::Mode::Online);
connect(update.get(), &Task::failed, [this](QString reason) connect(update.get(), &Task::failed, [this](QString reason)
@ -1714,9 +1713,7 @@ void MainWindow::finalizeInstance(InstancePtr inst)
loadDialog.setSkipButton(true, tr("Abort")); loadDialog.setSkipButton(true, tr("Abort"));
loadDialog.execWithTask(update.get()); loadDialog.execWithTask(update.get());
} }
} } else {
else
{
CustomMessageBox::selectable( CustomMessageBox::selectable(
this, this,
tr("Error"), tr("Error"),

View File

@ -188,7 +188,7 @@ void AccountListPage::on_actionAddMicrosoft_triggered()
void AccountListPage::on_actionAddOffline_triggered() void AccountListPage::on_actionAddOffline_triggered()
{ {
if (!m_accounts->anyAccountIsValid()) { if (!m_accounts->drmCheck()) {
QMessageBox::warning( QMessageBox::warning(
this, this,
tr("Error"), tr("Error"),

View File

@ -422,8 +422,7 @@ void VersionPage::on_actionChange_version_triggered()
void VersionPage::on_actionDownload_All_triggered() void VersionPage::on_actionDownload_All_triggered()
{ {
if (!APPLICATION->accounts()->anyAccountIsValid()) if (!APPLICATION->accounts()->drmCheck()) {
{
CustomMessageBox::selectable( CustomMessageBox::selectable(
this, tr("Error"), this, tr("Error"),
tr("Cannot download Minecraft or update instances unless you have at least " tr("Cannot download Minecraft or update instances unless you have at least "