diff options
| -rw-r--r-- | CMakeLists.txt | 21 | ||||
| -rw-r--r-- | MultiMC.cpp | 31 | ||||
| -rw-r--r-- | MultiMC.h | 4 | ||||
| -rw-r--r-- | WinBacktrace.cpp | 77 | ||||
| -rw-r--r-- | WinBacktrace.h | 44 | ||||
| -rw-r--r-- | logic/BaseInstance.cpp | 183 | ||||
| -rw-r--r-- | logic/BaseInstance.h | 37 | ||||
| -rw-r--r-- | logic/BaseInstance_p.h | 36 | ||||
| -rw-r--r-- | logic/InstanceFactory.cpp | 3 | ||||
| -rw-r--r-- | logic/InstanceLauncher.cpp | 94 | ||||
| -rw-r--r-- | logic/InstanceLauncher.h | 44 | ||||
| -rw-r--r-- | logic/JarUtils.cpp | 161 | ||||
| -rw-r--r-- | logic/JarUtils.h | 18 | ||||
| -rw-r--r-- | logic/LegacyInstance.cpp | 109 | ||||
| -rw-r--r-- | logic/LegacyInstance.h | 30 | ||||
| -rw-r--r-- | logic/LegacyInstance_p.h | 32 | ||||
| -rw-r--r-- | logic/LegacyUpdate.cpp | 160 | ||||
| -rw-r--r-- | logic/LegacyUpdate.h | 9 | ||||
| -rw-r--r-- | logic/ModList.h | 5 | ||||
| -rw-r--r-- | logic/OneSixFTBInstance.cpp | 1 | ||||
| -rw-r--r-- | logic/OneSixInstance.cpp | 97 | ||||
| -rw-r--r-- | logic/OneSixInstance.h | 23 | ||||
| -rw-r--r-- | logic/OneSixInstance_p.h | 33 | ||||
| -rw-r--r-- | logic/OneSixUpdate.cpp | 121 | ||||
| -rw-r--r-- | logic/OneSixUpdate.h | 4 | ||||
| -rw-r--r-- | logic/URNResolver.cpp | 98 | ||||
| -rw-r--r-- | logic/URNResolver.h | 18 | ||||
| -rw-r--r-- | logic/minecraft/VersionFile.cpp | 1 |
28 files changed, 444 insertions, 1050 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index a741c81b..145a519a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -380,26 +380,19 @@ SET(MULTIMC_SOURCES logic/InstanceFactory.cpp logic/BaseInstance.h logic/BaseInstance.cpp - logic/BaseInstance_p.h logic/Mod.h logic/Mod.cpp logic/ModList.h logic/ModList.cpp - + # sets and maps for deciding based on versions logic/VersionFilterData.h logic/VersionFilterData.cpp # Instance launch - logic/InstanceLauncher.h - logic/InstanceLauncher.cpp logic/MinecraftProcess.h logic/MinecraftProcess.cpp - # URN parser/resolver - logic/URNResolver.cpp - logic/URNResolver.h - # Annoying nag screen logic logic/NagUtils.h logic/NagUtils.cpp @@ -407,7 +400,7 @@ SET(MULTIMC_SOURCES # Player skin utilities logic/SkinUtils.h logic/SkinUtils.cpp - + # misc model filter logic/EnabledItemFilter.h logic/EnabledItemFilter.cpp @@ -476,7 +469,6 @@ SET(MULTIMC_SOURCES # legacy instances logic/LegacyInstance.h logic/LegacyInstance.cpp - logic/LegacyInstance_p.h logic/LegacyUpdate.h logic/LegacyUpdate.cpp @@ -485,7 +477,10 @@ SET(MULTIMC_SOURCES logic/OneSixUpdate.cpp logic/OneSixInstance.h logic/OneSixInstance.cpp - logic/OneSixInstance_p.h + + # Common utils for instances + logic/JarUtils.h + logic/JarUtils.cpp # OneSix version json infrastructure logic/minecraft/GradleSpecifier.h @@ -597,7 +592,7 @@ SET(MULTIMC_SOURCES logic/tools/JProfiler.cpp logic/tools/JVisualVM.h logic/tools/JVisualVM.cpp - + # Forge and all things forge related logic/forge/ForgeVersion.h logic/forge/ForgeVersion.cpp @@ -612,7 +607,7 @@ SET(MULTIMC_SOURCES logic/forge/LegacyForge.cpp logic/forge/ForgeInstaller.h logic/forge/ForgeInstaller.cpp - + # Liteloader and related things logic/liteloader/LiteLoaderInstaller.h logic/liteloader/LiteLoaderInstaller.cpp diff --git a/MultiMC.cpp b/MultiMC.cpp index 9798bfb7..f07fe765 100644 --- a/MultiMC.cpp +++ b/MultiMC.cpp @@ -25,7 +25,6 @@ #include "logic/status/StatusChecker.h" -#include "logic/InstanceLauncher.h" #include "logic/net/HttpMetaCache.h" #include "logic/net/URLConstants.h" @@ -38,8 +37,6 @@ #include "logic/tools/JVisualVM.h" #include "logic/tools/MCEditTool.h" -#include "logic/URNResolver.h" - #include "pathutils.h" #include "cmdutils.h" #include "logic/settings/INISettingsObject.h" @@ -83,13 +80,6 @@ MultiMC::MultiMC(int &argc, char **argv, bool test_mode) : QApplication(argc, ar parser.addShortOpt("dir", 'd'); parser.addDocumentation("dir", "use the supplied directory as MultiMC root instead of " "the binary location (use '.' for current)"); - // WARNING: disabled until further notice - /* - // --launch - parser.addOption("launch"); - parser.addShortOpt("launch", 'l'); - parser.addDocumentation("launch", "tries to launch the given instance", "<inst>"); -*/ // parse the arguments try @@ -266,18 +256,6 @@ MultiMC::MultiMC(int &argc, char **argv, bool test_mode) : QApplication(argc, ar tool->registerSettings(m_settings); } - // launch instance, if that's what should be done - // WARNING: disabled until further notice - /* - if (!args["launch"].isNull()) - { - if (InstanceLauncher(args["launch"].toString()).launch()) - m_status = MultiMC::Succeeded; - else - m_status = MultiMC::Failed; - return; - } -*/ connect(this, SIGNAL(aboutToQuit()), SLOT(onExit())); m_status = MultiMC::Initialized; } @@ -704,15 +682,6 @@ std::shared_ptr<JavaVersionList> MultiMC::javalist() return m_javalist; } -std::shared_ptr<URNResolver> MultiMC::resolver() -{ - if (!m_resolver) - { - m_resolver.reset(new URNResolver()); - } - return m_resolver; -} - void MultiMC::installUpdates(const QString updateFilesDir, UpdateFlags flags) { // if we are going to update on exit, save the params now @@ -23,7 +23,6 @@ class NewsChecker; class StatusChecker; class BaseProfilerFactory; class BaseDetachedToolFactory; -class URNResolver; class TranslationDownloader; #if defined(MMC) @@ -118,8 +117,6 @@ public: std::shared_ptr<JavaVersionList> javalist(); - std::shared_ptr<URNResolver> resolver(); - QMap<QString, std::shared_ptr<BaseProfilerFactory>> profilers() { return m_profilers; @@ -206,7 +203,6 @@ private: std::shared_ptr<LiteLoaderVersionList> m_liteloaderlist; std::shared_ptr<MinecraftVersionList> m_minecraftlist; std::shared_ptr<JavaVersionList> m_javalist; - std::shared_ptr<URNResolver> m_resolver; std::shared_ptr<TranslationDownloader> m_translationChecker; QMap<QString, std::shared_ptr<BaseProfilerFactory>> m_profilers; diff --git a/WinBacktrace.cpp b/WinBacktrace.cpp deleted file mode 100644 index 2acffbe5..00000000 --- a/WinBacktrace.cpp +++ /dev/null @@ -1,77 +0,0 @@ -/* Copyright 2013-2014 MultiMC Contributors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// CAUTION: -// This file contains all manner of hackery and insanity. -// I will not be responsible for any loss of sanity due to reading this code. -// Here be dragons! - -#include "WinBacktrace.h" - -#include <windows.h> - -#ifndef __i386__ -#error WinBacktrace is only supported on x86 architectures. -#endif - -// We need to do some crazy shit to walk through the stack. -// Windows unwinds the stack when an exception is thrown, so we -// need to examine the EXCEPTION_POINTERS's CONTEXT. -size_t getBacktrace(StackFrame *stack, size_t size, CONTEXT ctx) -{ - // Written using information and a bit of pseudocode from - // http://www.eptacom.net/pubblicazioni/pub_eng/except.html - // This is probably one of the most horrifying things I've ever written. - - // This tracks whether the current EBP is valid. - // When an invalid EBP is encountered, we stop walking the stack. - bool validEBP = true; - DWORD ebp = ctx.Ebp; // The current EBP (Extended Base Pointer) - DWORD eip = ctx.Eip; - int i; - for (i = 0; i < size; i++) - { - if (ebp & 3) - validEBP = false; - // FIXME: This function is obsolete, according to MSDN. - else if (IsBadReadPtr((void*) ebp, 8)) - validEBP = false; - - if (!validEBP) break; - - // Find the caller. - // On the first iteration, the caller is whatever EIP points to. - // On successive iterations, the caller is the byte after EBP. - BYTE* caller = !i ? (BYTE*)eip : *((BYTE**) ebp + 1); - // The first ebp is the EBP from the CONTEXT. - // On successive iterations, the EBP is the DWORD that the previous EBP points to. - ebp = !i ? ebp : *(DWORD*)ebp; - - // Find the caller's module. - // We'll use VirtualQuery to get information about the caller's address. - MEMORY_BASIC_INFORMATION mbi; - VirtualQuery(caller, &mbi, sizeof(mbi)); - - // We can get the instance handle from the allocation base. - HINSTANCE hInst = (HINSTANCE)mbi.AllocationBase; - - // If the handle is 0, then the EBP is invalid. - if (hInst == 0) validEBP = false; - // Otherwise, dump info about the caller. - else stack[i].address = (void*)caller; - } - - return i; -} diff --git a/WinBacktrace.h b/WinBacktrace.h deleted file mode 100644 index a959c5be..00000000 --- a/WinBacktrace.h +++ /dev/null @@ -1,44 +0,0 @@ -/* Copyright 2013-2014 MultiMC Contributors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#pragma once - -#include <windows.h> - -#ifndef SF_STR_LEN -// The max length of all strings in the StackFrame struct. -// Because it must be stack allocated, this must be known at compile time. -// Stuff longer than this will be truncated. -// Defaults to 4096 (4kB) -#define SF_STR_LEN 4096 -#endif - -// Data structure for holding information about a stack frame. -// There's some more hackery in here so it can be allocated on the stack. -struct StackFrame -{ - // The address of this stack frame. - void* address; - - // The name of the function at this address. - char funcName[SF_STR_LEN]; -}; - -// This function walks through the given CONTEXT structure, extracting a -// backtrace from it. -// The backtrace will be put into the array given by the `stack` argument -// with a maximum length of `size`. -// This function returns the size of the backtrace retrieved. -size_t getBacktrace(StackFrame* stack, size_t size, CONTEXT ctx); diff --git a/logic/BaseInstance.cpp b/logic/BaseInstance.cpp index 1dc5b671..b23dde73 100644 --- a/logic/BaseInstance.cpp +++ b/logic/BaseInstance.cpp @@ -15,7 +15,6 @@ #include "MultiMC.h" #include "BaseInstance.h" -#include "BaseInstance_p.h" #include <QFileInfo> #include <QDir> @@ -31,61 +30,50 @@ #include "logic/icons/IconList.h" #include "logic/InstanceList.h" -BaseInstance::BaseInstance(BaseInstancePrivate *d_in, const QString &rootDir, - SettingsObject *settings_obj, QObject *parent) - : QObject(parent), inst_d(d_in) +BaseInstance::BaseInstance(const QString &rootDir, SettingsObject *settings, QObject *parent) + : QObject(parent) { - I_D(BaseInstance); - d->m_settings = std::shared_ptr<SettingsObject>(settings_obj); - d->m_rootDir = rootDir; - settings().registerSetting("name", "Unnamed Instance"); - settings().registerSetting("iconKey", "default"); + m_settings = std::shared_ptr<SettingsObject>(settings); + m_rootDir = rootDir; + + m_settings->registerSetting("name", "Unnamed Instance"); + m_settings->registerSetting("iconKey", "default"); connect(MMC->icons().get(), SIGNAL(iconUpdated(QString)), SLOT(iconUpdated(QString))); - settings().registerSetting("notes", ""); - settings().registerSetting("lastLaunchTime", 0); - - /* - * custom base jar has no default. it is determined in code... see the accessor methods for - *it - * - * for instances that DO NOT have the CustomBaseJar setting (legacy instances), - * [.]minecraft/bin/mcbackup.jar is the default base jar - */ - settings().registerSetting("UseCustomBaseJar", true); - settings().registerSetting("CustomBaseJar", ""); + m_settings->registerSetting("notes", ""); + m_settings->registerSetting("lastLaunchTime", 0); auto globalSettings = MMC->settings(); // Java Settings - settings().registerSetting("OverrideJava", false); - settings().registerSetting("OverrideJavaLocation", false); - settings().registerSetting("OverrideJavaArgs", false); - settings().registerOverride(globalSettings->getSetting("JavaPath")); - settings().registerOverride(globalSettings->getSetting("JvmArgs")); + m_settings->registerSetting("OverrideJava", false); + m_settings->registerSetting("OverrideJavaLocation", false); + m_settings->registerSetting("OverrideJavaArgs", false); + m_settings->registerOverride(globalSettings->getSetting("JavaPath")); + m_settings->registerOverride(globalSettings->getSetting("JvmArgs")); // Custom Commands - settings().registerSetting({"OverrideCommands","OverrideLaunchCmd"}, false); - settings().registerOverride(globalSettings->getSetting("PreLaunchCommand")); - settings().registerOverride(globalSettings->getSetting("PostExitCommand")); + m_settings->registerSetting({"OverrideCommands","OverrideLaunchCmd"}, false); + m_settings->registerOverride(globalSettings->getSetting("PreLaunchCommand")); + m_settings->registerOverride(globalSettings->getSetting("PostExitCommand")); // Window Size - settings().registerSetting("OverrideWindow", false); - settings().registerOverride(globalSettings->getSetting("LaunchMaximized")); - settings().registerOverride(globalSettings->getSetting("MinecraftWinWidth")); - settings().registerOverride(globalSettings->getSetting("MinecraftWinHeight")); + m_settings->registerSetting("OverrideWindow", false); + m_settings->registerOverride(globalSettings->getSetting("LaunchMaximized")); + m_settings->registerOverride(globalSettings->getSetting("MinecraftWinWidth")); + m_settings->registerOverride(globalSettings->getSetting("MinecraftWinHeight")); // Memory - settings().registerSetting("OverrideMemory", false); - settings().registerOverride(globalSettings->getSetting("MinMemAlloc")); - settings().registerOverride(globalSettings->getSetting("MaxMemAlloc")); - settings().registerOverride(globalSettings->getSetting("PermGen")); + m_settings->registerSetting("OverrideMemory", false); + m_settings->registerOverride(globalSettings->getSetting("MinMemAlloc")); + m_settings->registerOverride(globalSettings->getSetting("MaxMemAlloc")); + m_settings->registerOverride(globalSettings->getSetting("PermGen")); // Console - settings().registerSetting("OverrideConsole", false); - settings().registerOverride(globalSettings->getSetting("ShowConsole")); - settings().registerOverride(globalSettings->getSetting("AutoCloseConsole")); - settings().registerOverride(globalSettings->getSetting("LogPrePostOutput")); + m_settings->registerSetting("OverrideConsole", false); + m_settings->registerOverride(globalSettings->getSetting("ShowConsole")); + m_settings->registerOverride(globalSettings->getSetting("AutoCloseConsole")); + m_settings->registerOverride(globalSettings->getSetting("LogPrePostOutput")); } void BaseInstance::iconUpdated(QString key) @@ -109,26 +97,22 @@ QString BaseInstance::id() const bool BaseInstance::isRunning() const { - I_D(BaseInstance); - return d->m_isRunning; + return m_isRunning; } -void BaseInstance::setRunning(bool running) const +void BaseInstance::setRunning(bool running) { - I_D(BaseInstance); - d->m_isRunning = running; + m_isRunning = running; } QString BaseInstance::instanceType() const { - I_D(BaseInstance); - return d->m_settings->get("InstanceType").toString(); + return m_settings->get("InstanceType").toString(); } QString BaseInstance::instanceRoot() const { - I_D(BaseInstance); - return d->m_rootDir; + return m_rootDir; } QString BaseInstance::minecraftRoot() const @@ -159,36 +143,34 @@ std::shared_ptr<BaseVersionList> BaseInstance::versionList() const SettingsObject &BaseInstance::settings() const { - I_D(BaseInstance); - return *d->m_settings; + return *m_settings; } BaseInstance::InstanceFlags BaseInstance::flags() const { - I_D(const BaseInstance); - return d->m_flags; + return m_flags; } + void BaseInstance::setFlags(const InstanceFlags &flags) { - I_D(BaseInstance); - if (flags != d->m_flags) + if (flags != m_flags) { - d->m_flags = flags; + m_flags = flags; emit flagsChanged(); emit propertiesChanged(this); } } + void BaseInstance::setFlag(const BaseInstance::InstanceFlag flag) { - I_D(BaseInstance); - d->m_flags |= flag; + m_flags |= flag; emit flagsChanged(); emit propertiesChanged(this); } + void BaseInstance::unsetFlag(const BaseInstance::InstanceFlag flag) { - I_D(BaseInstance); - d->m_flags &= ~flag; + m_flags &= ~flag; emit flagsChanged(); emit propertiesChanged(this); } @@ -200,69 +182,23 @@ bool BaseInstance::canLaunch() const bool BaseInstance::reload() { - return settings().reload(); -} - -QString BaseInstance::baseJar() const -{ - I_D(BaseInstance); - bool customJar = d->m_settings->get("UseCustomBaseJar").toBool(); - if (customJar) - { - return customBaseJar(); - } - else - return defaultBaseJar(); -} - -QString BaseInstance::customBaseJar() const -{ - I_D(BaseInstance); - QString value = d->m_settings->get("CustomBaseJar").toString(); - if (value.isNull() || value.isEmpty()) - { - return defaultCustomBaseJar(); - } - return value; -} - -void BaseInstance::setCustomBaseJar(QString val) -{ - I_D(BaseInstance); - if (val.isNull() || val.isEmpty() || val == defaultCustomBaseJar()) - d->m_settings->reset("CustomBaseJar"); - else - d->m_settings->set("CustomBaseJar", val); -} - -void BaseInstance::setShouldUseCustomBaseJar(bool val) -{ - I_D(BaseInstance); - d->m_settings->set("UseCustomBaseJar", val); -} - -bool BaseInstance::shouldUseCustomBaseJar() const -{ - I_D(BaseInstance); - return d->m_settings->get("UseCustomBaseJar").toBool(); + return m_settings->reload(); } qint64 BaseInstance::lastLaunch() const { - I_D(BaseInstance); - return d->m_settings->get("lastLaunchTime").value<qint64>(); + return m_settings->get("lastLaunchTime").value<qint64>(); } + void BaseInstance::setLastLaunch(qint64 val) { - I_D(BaseInstance); - d->m_settings->set("lastLaunchTime", val); + m_settings->set("lastLaunchTime", val); emit propertiesChanged(this); } void BaseInstance::setGroupInitial(QString val) { - I_D(BaseInstance); - d->m_group = val; + m_group = val; emit propertiesChanged(this); } @@ -274,44 +210,39 @@ void BaseInstance::setGroupPost(QString val) QString BaseInstance::group() const { - I_D(BaseInstance); - return d->m_group; + return m_group; } void BaseInstance::setNotes(QString val) { - I_D(BaseInstance); - d->m_settings->set("notes", val); + m_settings->set("notes", val); } + QString BaseInstance::notes() const { - I_D(BaseInstance); - return d->m_settings->get("notes").toString(); + return m_settings->get("notes").toString(); } void BaseInstance::setIconKey(QString val) { - I_D(BaseInstance); - d->m_settings->set("iconKey", val); + m_settings->set("iconKey", val); emit propertiesChanged(this); } + QString BaseInstance::iconKey() const { - I_D(BaseInstance); - return d->m_settings->get("iconKey").toString(); + return m_settings->get("iconKey").toString(); } void BaseInstance::setName(QString val) { - I_D(BaseInstance); - d->m_settings->set("name", val); + m_settings->set("name", val); emit propertiesChanged(this); } QString BaseInstance::name() const { - I_D(BaseInstance); - return d->m_settings->get("name").toString(); + return m_settings->get("name").toString(); } QString BaseInstance::windowTitle() const diff --git a/logic/BaseInstance.h b/logic/BaseInstance.h index c8517298..a0ac3c57 100644 --- a/logic/BaseInstance.h +++ b/logic/BaseInstance.h @@ -51,8 +51,7 @@ class BaseInstance : public QObject Q_OBJECT protected: /// no-touchy! - BaseInstance(BaseInstancePrivate *d, const QString &rootDir, SettingsObject *settings, - QObject *parent = 0); + BaseInstance(const QString &rootDir, SettingsObject *settings, QObject *parent = 0); public: /// virtual destructor to make sure the destruction is COMPLETE @@ -69,8 +68,8 @@ public: /// be unique. virtual QString id() const; - virtual void setRunning(bool running) const; - virtual bool isRunning() const; + void setRunning(bool running); + bool isRunning() const; /// get the type of this instance QString instanceType() const; @@ -127,30 +126,10 @@ public: { return nullptr; } - + /// Traits. Normally inside the version, depends on instance implementation. virtual QSet <QString> traits() = 0; - /// Get the curent base jar of this instance. By default, it's the - /// versions/$version/$version.jar - QString baseJar() const; - - /// the default base jar of this instance - virtual QString defaultBaseJar() const = 0; - /// the default custom base jar of this instance - virtual QString defaultCustomBaseJar() const = 0; - - /*! - * Whether or not custom base jar is used - */ - bool shouldUseCustomBaseJar() const; - void setShouldUseCustomBaseJar(bool val); - /*! - * The value of the custom base jar - */ - QString customBaseJar() const; - void setCustomBaseJar(QString val); - /** * Gets the time that the instance was last launched. * Stored in milliseconds since epoch. @@ -202,7 +181,7 @@ public: VersionBrokenFlag = 0x01, UpdateAvailable = 0x02 }; - Q_DECLARE_FLAGS(InstanceFlags, InstanceFlag) + Q_DECLARE_FLAGS(InstanceFlags, InstanceFlag); InstanceFlags flags() const; void setFlags(const InstanceFlags &flags); void setFlag(const InstanceFlag flag); @@ -232,7 +211,11 @@ protected slots: void iconUpdated(QString key); protected: - std::shared_ptr<BaseInstancePrivate> inst_d; + QString m_rootDir; + QString m_group; + std::shared_ptr<SettingsObject> m_settings; + InstanceFlags m_flags; + bool m_isRunning = false; }; Q_DECLARE_METATYPE(std::shared_ptr<BaseInstance>) diff --git a/logic/BaseInstance_p.h b/logic/BaseInstance_p.h deleted file mode 100644 index 2958e4e8..00000000 --- a/logic/BaseInstance_p.h +++ /dev/null @@ -1,36 +0,0 @@ -/* Copyright 2013-2014 MultiMC Contributors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#pragma once - -#include <QString> -#include <QSet> - -#include "logic/settings/SettingsObject.h" - -#include "BaseInstance.h" - -#define I_D(Class) Class##Private *const d = (Class##Private * const)inst_d.get() - -class BaseInstancePrivate -{ -public: - virtual ~BaseInstancePrivate(){}; - QString m_rootDir; - QString m_group; - std::shared_ptr<SettingsObject> m_settings; - BaseInstance::InstanceFlags m_flags; - bool m_isRunning = false; -}; diff --git a/logic/InstanceFactory.cpp b/logic/InstanceFactory.cpp index 640c02f3..832b8387 100644 --- a/logic/InstanceFactory.cpp +++ b/logic/InstanceFactory.cpp @@ -100,7 +100,6 @@ InstanceFactory::InstCreateError InstanceFactory::createInstance(InstancePtr &in m_settings->set("InstanceType", "OneSix"); inst.reset(new OneSixInstance(instDir, m_settings)); inst->setIntendedVersionId(version->descriptor()); - inst->setShouldUseCustomBaseJar(false); } else if (type == FTBInstance) { @@ -109,14 +108,12 @@ InstanceFactory::InstCreateError InstanceFactory::createInstance(InstancePtr &in m_settings->set("InstanceType", "LegacyFTB"); inst.reset(new LegacyFTBInstance(instDir, m_settings)); inst->setIntendedVersionId(version->descriptor()); - inst->setShouldUseCustomBaseJar(false); } else { m_settings->set("InstanceType", "OneSixFTB"); inst.reset(new OneSixFTBInstance(instDir, m_settings)); inst->setIntendedVersionId(version->descriptor()); - inst->setShouldUseCustomBaseJar(false); } } else diff --git a/logic/InstanceLauncher.cpp b/logic/InstanceLauncher.cpp deleted file mode 100644 index 4e47c592..00000000 --- a/logic/InstanceLauncher.cpp +++ /dev/null @@ -1,94 +0,0 @@ -/* Copyright 2013-2014 MultiMC Contributors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include <iostream> - -#include "InstanceLauncher.h" -#include "MultiMC.h" - -#include "gui/ConsoleWindow.h" -#include "gui/dialogs/ProgressDialog.h" - -#include "logic/MinecraftProcess.h" -#include "logic/InstanceList.h" - -InstanceLauncher::InstanceLauncher(QString instId) : QObject(), instId(instId) -{ -} - -void InstanceLauncher::onTerminated() -{ - std::cout << "Minecraft exited" << std::endl; - MMC->quit(); -} - -void InstanceLauncher::onLoginComplete() -{ - // TODO: Fix this. - /* - LoginTask *task = (LoginTask *)QObject::sender(); - auto result = task->getResult(); - auto instance = MMC->instances()->getInstanceById(instId); - proc = instance->prepareForLaunch(result); - if (!proc) - { - // FIXME: report error - return; - } - console = new ConsoleWindow(proc); - connect(console, SIGNAL(isClosing()), this, SLOT(onTerminated())); - - proc->setLogin(result.username, result.session_id); - proc->launch(); - */ -} - -void InstanceLauncher::doLogin(const QString &errorMsg) -{ - // FIXME: Use new account system here... - /* - LoginDialog *loginDlg = new LoginDialog(nullptr, errorMsg); - loginDlg->exec(); - if (loginDlg->result() == QDialog::Accepted) - { - PasswordLogin uInfo{loginDlg->getUsername(), loginDlg->getPassword()}; - - ProgressDialog *tDialog = new ProgressDialog(nullptr); - LoginTask *loginTask = new LoginTask(uInfo, tDialog); - connect(loginTask, SIGNAL(succeeded()), SLOT(onLoginComplete()), Qt::QueuedConnection); - connect(loginTask, SIGNAL(failed(QString)), SLOT(doLogin(QString)), - Qt::QueuedConnection); - tDialog->exec(loginTask); - } - */ - // onLoginComplete(LoginResponse("Offline","Offline", 1)); -} - -int InstanceLauncher::launch() -{ - std::cout << "Launching Instance '" << qPrintable(instId) << "'" << std::endl; - auto instance = MMC->instances()->getInstanceById(instId); - if (!instance) - { - std::cout << "Could not find instance requested. note that you have to specify the ID, " - "not the NAME" << std::endl; - return 1; - } - - std::cout << "Logging in..." << std::endl; - doLogin(""); - - return MMC->exec(); -} diff --git a/logic/InstanceLauncher.h b/logic/InstanceLauncher.h deleted file mode 100644 index 07f86b99..00000000 --- a/logic/InstanceLauncher.h +++ /dev/null @@ -1,44 +0,0 @@ -/* Copyright 2013-2014 MultiMC Contributors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#pragma once - -#include <QObject> - -class MinecraftProcess; -class ConsoleWindow; - -// Commandline instance launcher -class InstanceLauncher : public QObject -{ - Q_OBJECT - -private: - QString instId; - MinecraftProcess *proc; - ConsoleWindow *console; - -public: - InstanceLauncher(QString instId); - -private -slots: - void onTerminated(); - void onLoginComplete(); - void doLogin(const QString &errorMsg); - -public: - int launch(); -}; diff --git a/logic/JarUtils.cpp b/logic/JarUtils.cpp new file mode 100644 index 00000000..3b4f780a --- /d |
