summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--depends/launcher/org/multimc/Utils.java31
-rw-r--r--depends/launcher/org/multimc/onesix/OneSixLauncher.java17
-rw-r--r--logic/OneSixUpdate.cpp148
-rw-r--r--logic/OneSixUpdate.h8
4 files changed, 111 insertions, 93 deletions
diff --git a/depends/launcher/org/multimc/Utils.java b/depends/launcher/org/multimc/Utils.java
index ba90c07f..c4d55b6e 100644
--- a/depends/launcher/org/multimc/Utils.java
+++ b/depends/launcher/org/multimc/Utils.java
@@ -28,6 +28,37 @@ import java.util.List;
public class Utils
{
/**
+ * Combine two parts of a path.
+ * @param path1
+ * @param path2
+ * @return the paths, combined
+ */
+ public static String combine (String path1, String path2)
+ {
+ File file1 = new File(path1);
+ File file2 = new File(file1, path2);
+ return file2.getPath();
+ }
+
+ /**
+ * Join a list of strings into a string using a separator!
+ * @param strings the string list to join
+ * @param separator the glue
+ * @return the result.
+ */
+ public static String join (List<String> strings, String separator)
+ {
+ StringBuilder sb = new StringBuilder();
+ String sep = "";
+ for(String s: strings)
+ {
+ sb.append(sep).append(s);
+ sep = separator;
+ }
+ return sb.toString();
+ }
+
+ /**
* Adds the specified library to the classpath
*
* @param s the path to add
diff --git a/depends/launcher/org/multimc/onesix/OneSixLauncher.java b/depends/launcher/org/multimc/onesix/OneSixLauncher.java
index 2232eeba..f25a3245 100644
--- a/depends/launcher/org/multimc/onesix/OneSixLauncher.java
+++ b/depends/launcher/org/multimc/onesix/OneSixLauncher.java
@@ -66,7 +66,11 @@ public class OneSixLauncher implements Launcher
return -1;
}
- final ClassLoader cl = ClassLoader.getSystemClassLoader();
+ String property = System.getProperty("os.arch");
+ List<String> allNativePaths = new ArrayList<String>();
+ boolean is_64 = property.equalsIgnoreCase("x86_64") || property.equalsIgnoreCase("amd64");
+ allNativePaths.add(natives);
+ allNativePaths.add(Utils.combine(natives, is_64 ? "64" : "32"));
// print the pretty things
{
@@ -74,6 +78,13 @@ public class OneSixLauncher implements Launcher
System.out.println(mainClass);
System.out.println();
+ System.out.println("Native paths:");
+ for (String s : allNativePaths)
+ {
+ System.out.println(s);
+ }
+ System.out.println();
+
System.out.println("Libraries:");
for (String s : libraries)
{
@@ -96,8 +107,10 @@ public class OneSixLauncher implements Launcher
System.out.println();
}
+ final ClassLoader cl = ClassLoader.getSystemClassLoader();
+
// set up the natives path(s).
- System.setProperty("java.library.path", natives );
+ System.setProperty("java.library.path", Utils.join(allNativePaths, String.valueOf(File.pathSeparatorChar)) );
Field fieldSysPath;
try
{
diff --git a/logic/OneSixUpdate.cpp b/logic/OneSixUpdate.cpp
index 4d93477a..5309a7e0 100644
--- a/logic/OneSixUpdate.cpp
+++ b/logic/OneSixUpdate.cpp
@@ -54,17 +54,7 @@ void OneSixUpdate::executeTask()
if (m_only_prepare)
{
- /*
- * FIXME: in offline mode, do not proceed!
- */
- setStatus(tr("Testing the Java installation..."));
- QString java_path = m_inst->settings().get("JavaPath").toString();
-
- checker.reset(new JavaChecker());
- connect(checker.get(), SIGNAL(checkFinished(JavaCheckResult)), this,
- SLOT(checkFinishedOffline(JavaCheckResult)));
- checker->path = java_path;
- checker->performCheck();
+ prepareForLaunch();
return;
}
@@ -83,46 +73,8 @@ void OneSixUpdate::executeTask()
}
else
{
- checkJavaOnline();
- }
-}
-
-void OneSixUpdate::checkJavaOnline()
-{
- setStatus(tr("Testing the Java installation..."));
- QString java_path = m_inst->settings().get("JavaPath").toString();
-
- checker.reset(new JavaChecker());
- connect(checker.get(), SIGNAL(checkFinished(JavaCheckResult)), this,
- SLOT(checkFinishedOnline(JavaCheckResult)));
- checker->path = java_path;
- checker->performCheck();
-}
-
-void OneSixUpdate::checkFinishedOnline(JavaCheckResult result)
-{
- if (result.valid)
- {
- java_is_64bit = result.is_64bit;
jarlibStart();
}
- else
- {
- emitFailed("The java binary doesn't work. Check the settings and correct the problem");
- }
-}
-
-void OneSixUpdate::checkFinishedOffline(JavaCheckResult result)
-{
- if (result.valid)
- {
- java_is_64bit = result.is_64bit;
- prepareForLaunch();
- }
- else
- {
- emitFailed("The java binary doesn't work. Check the settings and correct the problem");
- }
}
void OneSixUpdate::versionFileStart()
@@ -130,7 +82,8 @@ void OneSixUpdate::versionFileStart()
QLOG_INFO() << m_inst->name() << ": getting version file.";
setStatus(tr("Getting the version files from Mojang..."));
- QString urlstr = "http://" + URLConstants::AWS_DOWNLOAD_VERSIONS + targetVersion->descriptor() + "/" + targetVersion->descriptor() + ".json";
+ QString urlstr = "http://" + URLConstants::AWS_DOWNLOAD_VERSIONS +
+ targetVersion->descriptor() + "/" + targetVersion->descriptor() + ".json";
auto job = new NetJob("Version index");
job->addNetAction(ByteArrayDownload::make(QUrl(urlstr)));
specificVersionDownloadJob.reset(job);
@@ -186,7 +139,7 @@ void OneSixUpdate::versionFileFinished()
}
inst->reloadFullVersion();
- checkJavaOnline();
+ jarlibStart();
}
void OneSixUpdate::versionFileFailed()
@@ -230,7 +183,7 @@ void OneSixUpdate::assetIndexFinished()
{
emitFailed("Failed to read the assets index!");
}
-
+
QList<Md5EtagDownloadPtr> dls;
for (auto object : index.objects.values())
{
@@ -245,17 +198,17 @@ void OneSixUpdate::assetIndexFinished()
dls.append(objectDL);
}
}
- if(dls.size())
+ if (dls.size())
{
setStatus(tr("Getting the assets files from Mojang..."));
auto job = new NetJob("Assets for " + inst->name());
- for(auto dl: dls)
+ for (auto dl : dls)
job->addNetAction(dl);
jarlibDownloadJob.reset(job);
connect(jarlibDownloadJob.get(), SIGNAL(succeeded()), SLOT(assetsFinished()));
connect(jarlibDownloadJob.get(), SIGNAL(failed()), SLOT(assetsFailed()));
connect(jarlibDownloadJob.get(), SIGNAL(progress(qint64, qint64)),
- SIGNAL(progress(qint64, qint64)));
+ SIGNAL(progress(qint64, qint64)));
jarlibDownloadJob->start();
return;
}
@@ -277,8 +230,6 @@ void OneSixUpdate::assetsFailed()
emitFailed("Failed to download assets!");
}
-
-
void OneSixUpdate::jarlibStart()
{
setStatus(tr("Getting the library files from Mojang..."));
@@ -318,24 +269,37 @@ void OneSixUpdate::jarlibStart()
{
if (lib->hint() == "local")
continue;
- QString subst = java_is_64bit ? "64" : "32";
- QString storage = lib->storagePath();
- QString dl = lib->downloadUrl();
- storage.replace("${arch}", subst);
- dl.replace("${arch}", subst);
+ QString raw_storage = lib->storagePath();
+ QString raw_dl = lib->downloadUrl();
- auto entry = metacache->resolveEntry("libraries", storage);
- if (entry->stale)
+ auto f = [&](QString storage, QString dl)
{
- if (lib->hint() == "forge-pack-xz")
+ auto entry = metacache->resolveEntry("libraries", storage);
+ if (entry->stale)
{
- ForgeLibs.append(ForgeXzDownload::make(storage, entry));
- }
- else
- {
- jarlibDownloadJob->addNetAction(CacheDownload::make(dl, entry));
+ if (lib->hint() == "forge-pack-xz")
+ {
+ ForgeLibs.append(ForgeXzDownload::make(storage, entry));
+ }
+ else
+ {
+ jarlibDownloadJob->addNetAction(CacheDownload::make(dl, entry));
+ }
}
+ };
+ if (raw_storage.contains("${arch}"))
+ {
+ QString cooked_storage = raw_storage;
+ QString cooked_dl = raw_dl;
+ f(cooked_storage.replace("${arch}", "32"), cooked_dl.replace("${arch}", "32"));
+ cooked_storage = raw_storage;
+ cooked_dl = raw_dl;
+ f(cooked_storage.replace("${arch}", "64"), cooked_dl.replace("${arch}", "64"));
+ }
+ else
+ {
+ f(raw_storage, raw_dl);
}
}
// TODO: think about how to propagate this from the original json file... or IF AT ALL
@@ -388,7 +352,9 @@ void OneSixUpdate::prepareForLaunch()
auto libs_to_extract = version->getActiveNativeLibs();
// Acquire bag
- bool success = ensureFolderPathExists(natives_dir_raw);
+ bool success = true;
+ success &= ensureFolderPathExists(natives_dir_raw + "/32");
+ success &= ensureFolderPathExists(natives_dir_raw + "/64");
if (!success)
{
emitFailed("Could not create the native library folder:\n" + natives_dir_raw +
@@ -398,22 +364,38 @@ void OneSixUpdate::prepareForLaunch()
}
// Put swag in the bag
- QString subst = java_is_64bit ? "64" : "32";
for (auto lib : libs_to_extract)
{
+ auto f = [&](QString storage, QString arch = "")
+ {
+ QString path = "libraries/" + storage;
+ QLOG_INFO() << "Will extract " << path.toLocal8Bit();
+ if (JlCompress::extractWithExceptions(path, natives_dir_raw + "/" + arch,
+ lib->extract_excludes).isEmpty())
+ {
+ emitFailed(
+ "Could not extract the native library:\n" + path +
+ "\nMake sure MultiMC has appropriate permissions and there is enough space "
+ "on the storage device.");
+ return false;
+ }
+ };
QString storage = lib->storagePath();
- storage.replace("${arch}", subst);
-
- QString path = "libraries/" + storage;
- QLOG_INFO() << "Will extract " << path.toLocal8Bit();
- if (JlCompress::extractWithExceptions(path, natives_dir_raw, lib->extract_excludes)
- .isEmpty())
+ if (storage.contains("${arch}"))
{
- emitFailed(
- "Could not extract the native library:\n" + path +
- "\nMake sure MultiMC has appropriate permissions and there is enough space "
- "on the storage device.");
- return;
+ QString cooked_storage = storage;
+ cooked_storage.replace("${arch}", "32");
+ if (!f(cooked_storage, "32"))
+ return;
+ cooked_storage = storage;
+ cooked_storage.replace("${arch}", "64");
+ if (!f(cooked_storage, "64"))
+ return;
+ }
+ else
+ {
+ if (!f(storage))
+ return;
}
}
diff --git a/logic/OneSixUpdate.h b/logic/OneSixUpdate.h
index 00b769c7..bc717a94 100644
--- a/logic/OneSixUpdate.h
+++ b/logic/OneSixUpdate.h
@@ -21,7 +21,6 @@
#include "logic/net/NetJob.h"
#include "logic/tasks/Task.h"
-#include "logic/JavaChecker.h"
class MinecraftVersion;
class BaseInstance;
@@ -50,10 +49,6 @@ slots:
void assetsFinished();
void assetsFailed();
- void checkJavaOnline();
- void checkFinishedOnline(JavaCheckResult result);
- void checkFinishedOffline(JavaCheckResult result);
-
// extract the appropriate libraries
void prepareForLaunch();
@@ -65,7 +60,4 @@ private:
std::shared_ptr<MinecraftVersion> targetVersion;
BaseInstance *m_inst = nullptr;
bool m_only_prepare = false;
- std::shared_ptr<JavaChecker> checker;
-
- bool java_is_64bit = false;
};