diff --git a/launcher/CMakeLists.txt b/launcher/CMakeLists.txt index c467957a8..4bb686106 100644 --- a/launcher/CMakeLists.txt +++ b/launcher/CMakeLists.txt @@ -271,9 +271,7 @@ set(MINECRAFT_SOURCES minecraft/GradleSpecifier.h minecraft/MinecraftInstance.cpp minecraft/MinecraftInstance.h - minecraft/LaunchContext.cpp - minecraft/LaunchContext.h - minecraft/LaunchProfile.cpp + minecraft/LaunchProfile.cpp minecraft/LaunchProfile.h minecraft/Component.cpp minecraft/Component.h diff --git a/launcher/SysInfo.cpp b/launcher/SysInfo.cpp index 010eb84c8..f3ff200fc 100644 --- a/launcher/SysInfo.cpp +++ b/launcher/SysInfo.cpp @@ -1,18 +1,13 @@ #include #include -#include "minecraft/LaunchContext.h" #ifdef Q_OS_MACOS #include #endif -#include #include -#include -#include "MessageLevel.h" #include #include #include #include "java/JavaUtils.h" -#include "FileSystem.h" #include "Commandline.h" #include "Application.h" @@ -67,103 +62,5 @@ QString useQTForArch(){ #endif return qtArch; } - -QString runCheckerForArch(LaunchContext launchContext){ - QString checkerJar = JavaUtils::getJavaCheckPath(); - - if (checkerJar.isEmpty()) - { - qDebug() << "Java checker library could not be found. Please check your installation."; - return useQTForArch(); - } - - QStringList args; - - QProcessPtr process = new QProcess(); - args.append({"-jar", checkerJar}); - process->setArguments(args); - process->setProgram(launchContext.getJavaPath().toString()); - process->setProcessChannelMode(QProcess::SeparateChannels); - process->setProcessEnvironment(CleanEnviroment()); - qDebug() << "Running java checker: " + launchContext.getJavaPath().toString() + args.join(" ");; - - process->start(); - if(!process->waitForFinished(15000)){ - // we've been waiting for 15 seconds! wtf! OR... it already finished. But HOW WOULD THAT HAPPEN? - process->kill(); // die. BUUURNNNN - // fallback to using polymc arch - return useQTForArch(); - } else { - // yay we can use the java arch - QString stdout_javaChecker; - QString stderr_javaChecker; - - // process stdout - QByteArray data = process->readAllStandardOutput(); - QString added = QString::fromLocal8Bit(data); - added.remove('\r'); - stdout_javaChecker += added; - - // process stderr - data = process->readAllStandardError(); - added = QString::fromLocal8Bit(data); - added.remove('\r'); - stderr_javaChecker += added; - - QMap results; -#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) - QStringList lines = stdout_javaChecker.split("\n", Qt::SkipEmptyParts); -#else - QStringList lines = stdout_javaChecker.split("\n", QString::SkipEmptyParts); -#endif - for(QString line : lines) - { - line = line.trimmed(); - // NOTE: workaround for GH-4125, where garbage is getting printed into stdout on bedrock linux - if (line.contains("/bedrock/strata")) { - continue; - } - -#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) - auto parts = line.split('=', Qt::SkipEmptyParts); -#else - auto parts = line.split('=', QString::SkipEmptyParts); -#endif - if(parts.size() != 2 || parts[0].isEmpty() || parts[1].isEmpty()) - { - continue; - } - else - { - results.insert(parts[0], parts[1]); - } - } - - if(!results.contains("os.arch") || !results.contains("java.version") || !results.contains("java.vendor")) - { - // wtf man why - // fallback to using polymc arch - return useQTForArch(); - } - - return results["os.arch"]; - } -} - -QString currentArch(LaunchContext launchContext) { - auto realJavaArchitecture = launchContext.getRealJavaArch().toString(); - if(realJavaArchitecture == ""){ - //BRO WHY NOW I HAVE TO USE A JAVA CHECKER >:( - qDebug() << "SysInfo: BRO I HAVE TO USE A JAVA CHECKER WHY IS JAVA ARCH BORKED"; - launchContext.setRealJavaArch(runCheckerForArch(launchContext)); - realJavaArchitecture = launchContext.getRealJavaArch().toString(); - } - //qDebug() << "SysInfo: realJavaArch = " << realJavaArchitecture; - if(realJavaArchitecture == "aarch64"){ - return "arm64"; - } else { - return realJavaArchitecture; - } -} } diff --git a/launcher/SysInfo.h b/launcher/SysInfo.h index 9107cacb8..3cb1c8de6 100644 --- a/launcher/SysInfo.h +++ b/launcher/SysInfo.h @@ -1,12 +1,6 @@ #include -#include "minecraft/LaunchContext.h" -#ifdef Q_OS_MACOS -#include -#endif namespace SysInfo { QString currentSystem(); -QString currentArch(LaunchContext launchContext); -QString runCheckerForArch(LaunchContext launchContext); QString useQTForArch(); } diff --git a/launcher/minecraft/LaunchContext.cpp b/launcher/minecraft/LaunchContext.cpp deleted file mode 100644 index ea6a549f0..000000000 --- a/launcher/minecraft/LaunchContext.cpp +++ /dev/null @@ -1,39 +0,0 @@ -// SPDX-License-Identifier: GPL-3.0-only -/* - * PolyMC - Minecraft Launcher - * Copyright (C) 2022 Toshit Chawda - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, version 3. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - */ - -#include "LaunchContext.h" - -LaunchContext::LaunchContext(SettingsObjectPtr instanceSettings){ - m_instanceSettings = instanceSettings; -} - -void LaunchContext::setRealJavaArch(QVariant realJavaArch) -{ - m_instanceSettings->set("JavaRealArchitecture", realJavaArch); -} - -QVariant LaunchContext::getRealJavaArch() -{ - return m_instanceSettings->get("JavaRealArchitecture"); -} - -QVariant LaunchContext::getJavaPath() -{ - return m_instanceSettings->get("JavaPath"); -} diff --git a/launcher/minecraft/LaunchContext.h b/launcher/minecraft/LaunchContext.h deleted file mode 100644 index 2c6e1307f..000000000 --- a/launcher/minecraft/LaunchContext.h +++ /dev/null @@ -1,34 +0,0 @@ -// SPDX-License-Identifier: GPL-3.0-only -/* - * PolyMC - Minecraft Launcher - * Copyright (C) 2022 Toshit Chawda - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, version 3. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - */ - -#include -#include "settings/SettingsObject.h" - -#pragma once - -class LaunchContext -{ - public: - LaunchContext(SettingsObjectPtr instanceSettings); - void setRealJavaArch(QVariant realJavaArch); - QVariant getRealJavaArch(); - QVariant getJavaPath(); - private: - SettingsObjectPtr m_instanceSettings; -};