Exemplo n.º 1
0
MinecraftProcess* OneSixInstance::prepareForLaunch ( QString user, QString session )
{
	I_D(OneSixInstance);
	cleanupAfterRun();
	auto version = d->version;
	if(!version)
		return nullptr;
	auto libs_to_extract = version->getActiveNativeLibs();
	QString natives_dir_raw = PathCombine(instanceRoot(), "natives/");
	bool success = ensureFolderPathExists(natives_dir_raw);
	if(!success)
	{
		// FIXME: handle errors
		return nullptr;
	}
	
	for(auto lib: libs_to_extract)
	{
		QString path = "libraries/" + lib->storagePath();
		qDebug() << "Will extract " << path.toLocal8Bit();
		if(JlCompress::extractWithExceptions(path, natives_dir_raw, lib->extract_excludes).isEmpty())
		{
			return nullptr;
		}
	}

	QStringList args;
	args.append(Util::Commandline::splitArgs(settings().get("JvmArgs").toString()));
	args << QString("-Xms%1m").arg(settings().get("MinMemAlloc").toInt());
	args << QString("-Xmx%1m").arg(settings().get("MaxMemAlloc").toInt());
	args << QString("-XX:PermSize=%1m").arg(settings().get("PermGen").toInt());
	QDir natives_dir(natives_dir_raw);
	args << QString("-Djava.library.path=%1").arg( natives_dir.absolutePath() );
	QString classPath;
	{
		auto libs = version->getActiveNormalLibs();
		for (auto lib: libs)
		{
			QFileInfo fi(QString("libraries/") + lib->storagePath());
			classPath.append(fi.absoluteFilePath());
#ifdef Q_OS_WIN32
			classPath.append(';');
#else
			classPath.append(':');
#endif
		}
		QString targetstr = "versions/" + version->id + "/" + version->id + ".jar";
		QFileInfo fi(targetstr);
		classPath.append(fi.absoluteFilePath());
	}
	if(classPath.size())
	{
		args << "-cp";
		args << classPath;
	}
	args << version->mainClass;
	args.append(processMinecraftArgs(user, session));
	
	// create the process and set its parameters
	MinecraftProcess * proc = new MinecraftProcess(this);
	proc->setMinecraftArguments(args);
	proc->setMinecraftWorkdir(minecraftRoot());
	return proc;
}
Exemplo n.º 2
0
MinecraftProcess *OneSixInstance::prepareForLaunch(LoginResponse response)
{
	I_D(OneSixInstance);
	cleanupAfterRun();
	auto version = d->version;
	if (!version)
		return nullptr;
	auto libs_to_extract = version->getActiveNativeLibs();
	QString natives_dir_raw = PathCombine(instanceRoot(), "natives/");
	bool success = ensureFolderPathExists(natives_dir_raw);
	if (!success)
	{
		// FIXME: handle errors
		return nullptr;
	}

	for (auto lib : libs_to_extract)
	{
		QString path = "libraries/" + lib->storagePath();
		QLOG_INFO() << "Will extract " << path.toLocal8Bit();
		if (JlCompress::extractWithExceptions(path, natives_dir_raw, lib->extract_excludes)
				.isEmpty())
		{
			return nullptr;
		}
	}

	QStringList args;
	args.append(Util::Commandline::splitArgs(settings().get("JvmArgs").toString()));
	args << QString("-Xms%1m").arg(settings().get("MinMemAlloc").toInt());
	args << QString("-Xmx%1m").arg(settings().get("MaxMemAlloc").toInt());
	args << QString("-XX:PermSize=%1m").arg(settings().get("PermGen").toInt());

/**
 * HACK: Stupid hack for Intel drivers.
 * See: https://mojang.atlassian.net/browse/MCL-767
 */
#ifdef Q_OS_WIN32
	args << QString("-XX:HeapDumpPath=MojangTricksIntelDriversForPerformance_javaw.exe_"
					"minecraft.exe.heapdump");
#endif

	QDir natives_dir(natives_dir_raw);
	args << QString("-Djava.library.path=%1").arg(natives_dir.absolutePath());
	QString classPath;
	{
		auto libs = version->getActiveNormalLibs();
		for (auto lib : libs)
		{
			QFileInfo fi(QString("libraries/") + lib->storagePath());
			classPath.append(fi.absoluteFilePath());
#ifdef Q_OS_WIN32
			classPath.append(';');
#else
			classPath.append(':');
#endif
		}
		QString targetstr = "versions/" + version->id + "/" + version->id + ".jar";
		QFileInfo fi(targetstr);
		classPath.append(fi.absoluteFilePath());
	}
	if (classPath.size())
	{
		args << "-cp";
		args << classPath;
	}
	args << version->mainClass;
	args.append(processMinecraftArgs(response));

	// Set the width and height for 1.6 instances
	bool maximize = settings().get("LaunchMaximized").toBool();
	if (maximize)
	{
		// this is probably a BAD idea
		// args << QString("--fullscreen");
	}
	else
	{
		args << QString("--width") << settings().get("MinecraftWinWidth").toString();
		args << QString("--height") << settings().get("MinecraftWinHeight").toString();
	}

	// create the process and set its parameters
	MinecraftProcess *proc = new MinecraftProcess(this);
	proc->setMinecraftArguments(args);
	proc->setMinecraftWorkdir(minecraftRoot());
	return proc;
}