aboutsummaryrefslogtreecommitdiff
path: root/logic
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2013-10-06 01:13:40 +0200
committerPetr Mrázek <peterix@gmail.com>2013-10-06 01:13:40 +0200
commitf83119ce7ec3d11a903901b8eff762d2b0a9f635 (patch)
tree5c30d7b9fff0f9417e7f2cd79d8ad9ea56d7f056 /logic
parenteba9b3d759dbf6e402e91ab897059f1d274aef90 (diff)
downloadPrismLauncher-f83119ce7ec3d11a903901b8eff762d2b0a9f635.tar.gz
PrismLauncher-f83119ce7ec3d11a903901b8eff762d2b0a9f635.tar.bz2
PrismLauncher-f83119ce7ec3d11a903901b8eff762d2b0a9f635.zip
Added file logger
Diffstat (limited to 'logic')
-rw-r--r--logic/BaseInstance.cpp2
-rw-r--r--logic/BaseInstance.h6
-rw-r--r--logic/BaseInstance_p.h2
-rw-r--r--logic/BaseVersion.h4
-rw-r--r--logic/ForgeInstaller.cpp4
-rw-r--r--logic/ForgeInstaller.h6
-rw-r--r--logic/InstanceFactory.cpp5
-rw-r--r--logic/InstanceLauncher.cpp2
-rw-r--r--logic/LegacyInstance.cpp8
-rw-r--r--logic/LegacyInstance.h8
-rw-r--r--logic/LegacyInstance_p.h8
-rw-r--r--logic/LegacyUpdate.cpp213
-rw-r--r--logic/LegacyUpdate.h2
-rw-r--r--logic/Mod.cpp7
-rw-r--r--logic/ModList.cpp16
-rw-r--r--logic/OneSixAssets.cpp13
-rw-r--r--logic/OneSixInstance.cpp9
-rw-r--r--logic/OneSixInstance.h6
-rw-r--r--logic/OneSixInstance_p.h6
-rw-r--r--logic/OneSixLibrary.cpp2
-rw-r--r--logic/OneSixLibrary.h6
-rw-r--r--logic/OneSixRule.cpp6
-rw-r--r--logic/OneSixRule.h10
-rw-r--r--logic/OneSixUpdate.cpp25
-rw-r--r--logic/OneSixUpdate.h2
-rw-r--r--logic/OneSixVersion.cpp28
-rw-r--r--logic/OneSixVersion.h12
-rw-r--r--logic/lists/ForgeVersionList.cpp20
-rw-r--r--logic/lists/ForgeVersionList.h2
-rw-r--r--logic/lists/InstanceList.cpp218
-rw-r--r--logic/lists/LwjglVersionList.cpp62
-rw-r--r--logic/lists/LwjglVersionList.h6
-rw-r--r--logic/lists/MinecraftVersionList.cpp10
-rw-r--r--logic/net/ByteArrayDownload.cpp13
-rw-r--r--logic/net/ByteArrayDownload.h2
-rw-r--r--logic/net/CacheDownload.cpp10
-rw-r--r--logic/net/CacheDownload.h2
-rw-r--r--logic/net/Download.h18
-rw-r--r--logic/net/DownloadJob.cpp22
-rw-r--r--logic/net/DownloadJob.h2
-rw-r--r--logic/net/FileDownload.cpp12
-rw-r--r--logic/net/FileDownload.h2
-rw-r--r--logic/net/ForgeXzDownload.cpp26
-rw-r--r--logic/net/ForgeXzDownload.h2
-rw-r--r--logic/net/HttpMetaCache.cpp6
-rw-r--r--logic/net/HttpMetaCache.h2
-rw-r--r--logic/net/LoginTask.cpp4
-rw-r--r--logic/tasks/Task.cpp2
48 files changed, 441 insertions, 420 deletions
diff --git a/logic/BaseInstance.cpp b/logic/BaseInstance.cpp
index ec86596a..6a6b195b 100644
--- a/logic/BaseInstance.cpp
+++ b/logic/BaseInstance.cpp
@@ -132,7 +132,7 @@ InstanceList *BaseInstance::instList() const
return NULL;
}
-QSharedPointer<BaseVersionList> BaseInstance::versionList() const
+std::shared_ptr<BaseVersionList> BaseInstance::versionList() const
{
return MMC->minecraftlist();
}
diff --git a/logic/BaseInstance.h b/logic/BaseInstance.h
index 0056327a..e360d3ae 100644
--- a/logic/BaseInstance.h
+++ b/logic/BaseInstance.h
@@ -135,7 +135,7 @@ public:
* \brief Gets a pointer to this instance's version list.
* \return A pointer to the available version list for this instance.
*/
- virtual QSharedPointer<BaseVersionList> versionList() const;
+ virtual std::shared_ptr<BaseVersionList> versionList() const;
/*!
* \brief Gets this instance's settings object.
@@ -179,9 +179,9 @@ signals:
void nuked(BaseInstance * inst);
protected:
- QSharedPointer<BaseInstancePrivate> inst_d;
+ std::shared_ptr<BaseInstancePrivate> inst_d;
};
// pointer for lazy people
-typedef QSharedPointer<BaseInstance> InstancePtr;
+typedef std::shared_ptr<BaseInstance> InstancePtr;
diff --git a/logic/BaseInstance_p.h b/logic/BaseInstance_p.h
index a30916a4..06c0c0ba 100644
--- a/logic/BaseInstance_p.h
+++ b/logic/BaseInstance_p.h
@@ -4,7 +4,7 @@
class BaseInstance;
-#define I_D(Class) Class##Private * const d = (Class##Private * const) inst_d.data()
+#define I_D(Class) Class##Private * const d = (Class##Private * const) inst_d.get()
struct BaseInstancePrivate
{
diff --git a/logic/BaseVersion.h b/logic/BaseVersion.h
index be717fee..01745c46 100644
--- a/logic/BaseVersion.h
+++ b/logic/BaseVersion.h
@@ -14,7 +14,7 @@
*/
#pragma once
-#include <QSharedPointer>
+#include <memory>
/*!
* An abstract base class for versions.
@@ -40,6 +40,6 @@ struct BaseVersion
virtual QString typeString() const = 0;
};
-typedef QSharedPointer<BaseVersion> BaseVersionPtr;
+typedef std::shared_ptr<BaseVersion> BaseVersionPtr;
Q_DECLARE_METATYPE( BaseVersionPtr ) \ No newline at end of file
diff --git a/logic/ForgeInstaller.cpp b/logic/ForgeInstaller.cpp
index 9ae3f1e1..a946dd44 100644
--- a/logic/ForgeInstaller.cpp
+++ b/logic/ForgeInstaller.cpp
@@ -10,7 +10,7 @@
ForgeInstaller::ForgeInstaller(QString filename, QString universal_url)
{
- QSharedPointer<OneSixVersion> newVersion;
+ std::shared_ptr<OneSixVersion> newVersion;
m_universal_url = universal_url;
QuaZip zip(filename);
@@ -88,7 +88,7 @@ ForgeInstaller::ForgeInstaller(QString filename, QString universal_url)
realVersionId = m_forge_version->id = installObj.value("minecraft").toString();
}
-bool ForgeInstaller::apply(QSharedPointer<OneSixVersion> to)
+bool ForgeInstaller::apply(std::shared_ptr<OneSixVersion> to)
{
if (!m_forge_version)
return false;
diff --git a/logic/ForgeInstaller.h b/logic/ForgeInstaller.h
index f4ceaaef..f6f22a2a 100644
--- a/logic/ForgeInstaller.h
+++ b/logic/ForgeInstaller.h
@@ -1,6 +1,6 @@
#pragma once
#include <QString>
-#include <QSharedPointer>
+#include <memory>
class OneSixVersion;
@@ -9,11 +9,11 @@ class ForgeInstaller
public:
ForgeInstaller(QString filename, QString universal_url);
- bool apply(QSharedPointer<OneSixVersion> to);
+ bool apply(std::shared_ptr<OneSixVersion> to);
private:
// the version, read from the installer
- QSharedPointer<OneSixVersion> m_forge_version;
+ std::shared_ptr<OneSixVersion> m_forge_version;
QString internalPath;
QString finalPath;
QString realVersionId;
diff --git a/logic/InstanceFactory.cpp b/logic/InstanceFactory.cpp
index b5832ce5..0da62803 100644
--- a/logic/InstanceFactory.cpp
+++ b/logic/InstanceFactory.cpp
@@ -30,6 +30,7 @@
#include <setting.h>
#include "pathutils.h"
+#include <logger/QsLog.h>
InstanceFactory InstanceFactory::loader;
@@ -72,12 +73,12 @@ InstanceFactory::InstCreateError InstanceFactory::createInstance( BaseInstance*&
{
QDir rootDir(instDir);
- qDebug(instDir.toUtf8());
+ QLOG_DEBUG() << instDir.toUtf8();
if (!rootDir.exists() && !rootDir.mkpath("."))
{
return InstanceFactory::CantCreateDir;
}
- auto mcVer = version.dynamicCast<MinecraftVersion>();
+ auto mcVer = std::dynamic_pointer_cast<MinecraftVersion>(version);
if(!mcVer)
return InstanceFactory::NoSuchVersion;
diff --git a/logic/InstanceLauncher.cpp b/logic/InstanceLauncher.cpp
index 93b87f23..720052a3 100644
--- a/logic/InstanceLauncher.cpp
+++ b/logic/InstanceLauncher.cpp
@@ -61,7 +61,7 @@ int InstanceLauncher::launch()
{
std::cout << "Launching Instance '" << qPrintable ( instId ) << "'" << std::endl;
auto instance = MMC->instances()->getInstanceById(instId);
- if ( instance.isNull() )
+ if ( !instance )
{
std::cout << "Could not find instance requested. note that you have to specify the ID, not the NAME" << std::endl;
return 1;
diff --git a/logic/LegacyInstance.cpp b/logic/LegacyInstance.cpp
index 4f367980..2ffcb075 100644
--- a/logic/LegacyInstance.cpp
+++ b/logic/LegacyInstance.cpp
@@ -92,7 +92,7 @@ void LegacyInstance::cleanupAfterRun()
//FIXME: delete the launcher and icons and whatnot.
}
-QSharedPointer< ModList > LegacyInstance::coreModList()
+std::shared_ptr< ModList > LegacyInstance::coreModList()
{
I_D(LegacyInstance);
if(!d->core_mod_list)
@@ -104,7 +104,7 @@ QSharedPointer< ModList > LegacyInstance::coreModList()
return d->core_mod_list;
}
-QSharedPointer< ModList > LegacyInstance::jarModList()
+std::shared_ptr< ModList > LegacyInstance::jarModList()
{
I_D(LegacyInstance);
if(!d->jar_mod_list)
@@ -124,7 +124,7 @@ void LegacyInstance::jarModsChanged()
}
-QSharedPointer< ModList > LegacyInstance::loaderModList()
+std::shared_ptr< ModList > LegacyInstance::loaderModList()
{
I_D(LegacyInstance);
if(!d->loader_mod_list)
@@ -136,7 +136,7 @@ QSharedPointer< ModList > LegacyInstance::loaderModList()
return d->loader_mod_list;
}
-QSharedPointer< ModList > LegacyInstance::texturePackList()
+std::shared_ptr< ModList > LegacyInstance::texturePackList()
{
I_D(LegacyInstance);
if(!d->texture_pack_list)
diff --git a/logic/LegacyInstance.h b/logic/LegacyInstance.h
index 2eab9035..d7438cca 100644
--- a/logic/LegacyInstance.h
+++ b/logic/LegacyInstance.h
@@ -19,10 +19,10 @@ public:
QString modListFile() const;
////// Mod Lists //////
- QSharedPointer<ModList> jarModList();
- QSharedPointer<ModList> coreModList();
- QSharedPointer<ModList> loaderModList();
- QSharedPointer<ModList> texturePackList();
+ std::shared_ptr<ModList> jarModList();
+ std::shared_ptr<ModList> coreModList();
+ std::shared_ptr<ModList> loaderModList();
+ std::shared_ptr<ModList> texturePackList();
////// Directories //////
QString savesDir() const;
diff --git a/logic/LegacyInstance_p.h b/logic/LegacyInstance_p.h
index d1f417fe..0809b8d2 100644
--- a/logic/LegacyInstance_p.h
+++ b/logic/LegacyInstance_p.h
@@ -9,8 +9,8 @@ class ModList;
struct LegacyInstancePrivate: public BaseInstancePrivate
{
- QSharedPointer<ModList> jar_mod_list;
- QSharedPointer<ModList> core_mod_list;
- QSharedPointer<ModList> loader_mod_list;
- QSharedPointer<ModList> texture_pack_list;
+ std::shared_ptr<ModList> jar_mod_list;
+ std::shared_ptr<ModList> core_mod_list;
+ std::shared_ptr<ModList> loader_mod_list;
+ std::shared_ptr<ModList> texture_pack_list;
}; \ No newline at end of file
diff --git a/logic/LegacyUpdate.cpp b/logic/LegacyUpdate.cpp
index d8e622dd..5f5a2e52 100644
--- a/logic/LegacyUpdate.cpp
+++ b/logic/LegacyUpdate.cpp
@@ -9,9 +9,11 @@
#include <quazip.h>
#include <quazipfile.h>
#include <JlCompress.h>
+#include <logger/QsLog.h>
-
-LegacyUpdate::LegacyUpdate ( BaseInstance* inst, QObject* parent ) : BaseUpdate ( inst, parent ) {}
+LegacyUpdate::LegacyUpdate(BaseInstance *inst, QObject *parent) : BaseUpdate(inst, parent)
+{
+}
void LegacyUpdate::executeTask()
{
@@ -20,35 +22,35 @@ void LegacyUpdate::executeTask()
void LegacyUpdate::lwjglStart()
{
- LegacyInstance * inst = (LegacyInstance *) m_inst;
+ LegacyInstance *inst = (LegacyInstance *)m_inst;
+
+ lwjglVersion = inst->lwjglVersion();
+ lwjglTargetPath = PathCombine("lwjgl", lwjglVersion);
+ lwjglNativesPath = PathCombine(lwjglTargetPath, "natives");
- lwjglVersion = inst->lwjglVersion();
- lwjglTargetPath = PathCombine("lwjgl", lwjglVersion );
- lwjglNativesPath = PathCombine( lwjglTargetPath, "natives");
-
// if the 'done' file exists, we don't have to download this again
QFileInfo doneFile(PathCombine(lwjglTargetPath, "done"));
- if(doneFile.exists())
+ if (doneFile.exists())
{
jarStart();
return;
}
-
+
auto list = MMC->lwjgllist();
- if(!list->isLoaded())
+ if (!list->isLoaded())
{
emitFailed("Too soon! Let the LWJGL list load :)");
return;
}
-
+
setStatus("Downloading new LWJGL.");
auto version = list->getVersion(lwjglVersion);
- if(!version)
+ if (!version)
{
emitFailed("Game update failed: the selected LWJGL version is invalid.");
return;
}
-
+
QString url = version->url();
QUrl realUrl(url);
QString hostname = realUrl.host();
@@ -56,39 +58,42 @@ void LegacyUpdate::lwjglStart()
QNetworkRequest req(realUrl);
req.setRawHeader("Host", hostname.toLatin1());
req.setHeader(QNetworkRequest::UserAgentHeader, "Wget/1.14 (linux-gnu)");
- QNetworkReply * rep = worker->get ( req );
-
- m_reply = QSharedPointer<QNetworkReply> (rep, &QObject::deleteLater);
- connect(rep, SIGNAL(downloadProgress(qint64,qint64)), SIGNAL(progress(qint64,qint64)));
- connect(worker.data(), SIGNAL(finished(QNetworkReply*)), SLOT(lwjglFinished(QNetworkReply*)));
- //connect(rep, SIGNAL(error(QNetworkReply::NetworkError)), SLOT(downloadError(QNetworkReply::NetworkError)));
+ QNetworkReply *rep = worker->get(req);
+
+ m_reply = std::shared_ptr<QNetworkReply>(rep);
+ connect(rep, SIGNAL(downloadProgress(qint64, qint64)), SIGNAL(progress(qint64, qint64)));
+ connect(worker.get(), SIGNAL(finished(QNetworkReply *)),
+ SLOT(lwjglFinished(QNetworkReply *)));
+ // connect(rep, SIGNAL(error(QNetworkReply::NetworkError)),
+ // SLOT(downloadError(QNetworkReply::NetworkError)));
}
-void LegacyUpdate::lwjglFinished(QNetworkReply* reply)
+void LegacyUpdate::lwjglFinished(QNetworkReply *reply)
{
- if(m_reply != reply)
+ if (m_reply.get() != reply)
{
return;
}
- if(reply->error() != QNetworkReply::NoError)
+ if (reply->error() != QNetworkReply::NoError)
{
- emitFailed( "Failed to download: "+
- reply->errorString()+
- "\nSometimes you have to wait a bit if you download many LWJGL versions in a row. YMMV");
+ emitFailed("Failed to download: " + reply->errorString() +
+ "\nSometimes you have to wait a bit if you download many LWJGL versions in "
+ "a row. YMMV");
return;
}
auto worker = MMC->qnam();
- //Here i check if there is a cookie for me in the reply and extract it
- QList<QNetworkCookie> cookies = qvariant_cast<QList<QNetworkCookie>>(reply->header(QNetworkRequest::SetCookieHeader));
- if(cookies.count() != 0)
+ // Here i check if there is a cookie for me in the reply and extract it
+ QList<QNetworkCookie> cookies =
+ qvariant_cast<QList<QNetworkCookie>>(reply->header(QNetworkRequest::SetCookieHeader));
+ if (cookies.count() != 0)
{
- //you must tell which cookie goes with which url
+ // you must tell which cookie goes with which url
worker->cookieJar()->setCookiesFromUrl(cookies, QUrl("sourceforge.net"));
}
- //here you can check for the 302 or whatever other header i need
+ // here you can check for the 302 or whatever other header i need
QVariant newLoc = reply->header(QNetworkRequest::LocationHeader);
- if(newLoc.isValid())
+ if (newLoc.isValid())
{
QString redirectedTo = reply->header(QNetworkRequest::LocationHeader).toString();
QUrl realUrl(redirectedTo);
@@ -96,9 +101,10 @@ void LegacyUpdate::lwjglFinished(QNetworkReply* reply)
QNetworkRequest req(redirectedTo);
req.setRawHeader("Host", hostname.toLatin1());
req.setHeader(QNetworkRequest::UserAgentHeader, "Wget/1.14 (linux-gnu)");
- QNetworkReply * rep = worker->get(req);
- connect(rep, SIGNAL(downloadProgress(qint64,qint64)), SIGNAL(progress(qint64,qint64)));
- m_reply = QSharedPointer<QNetworkReply> (rep, &QObject::deleteLater);
+ QNetworkReply *rep = worker->get(req);
+ connect(rep, SIGNAL(downloadProgress(qint64, qint64)),
+ SIGNAL(progress(qint64, qint64)));
+ m_reply = std::shared_ptr<QNetworkReply>(rep);
return;
}
QFile saveMe("lwjgl.zip");
@@ -114,26 +120,26 @@ void LegacyUpdate::extractLwjgl()
// make sure the directories are there
bool success = ensureFolderPathExists(lwjglNativesPath);
-
- if(!success)
+
+ if (!success)
{
emitFailed("Failed to extract the lwjgl libs - error when creating required folders.");
return;
}
-
+
QuaZip zip("lwjgl.zip");
- if(!zip.open(QuaZip::mdUnzip))
+ if (!zip.open(QuaZip::mdUnzip))
{
emitFailed("Failed to extract the lwjgl libs - not a valid archive.");
return;
}
-
+
// and now we are going to access files inside it
QuaZipFile file(&zip);
- const QString jarNames[] = { "jinput.jar", "lwjgl_util.jar", "lwjgl.jar" };
- for(bool more=zip.goToFirstFile(); more; more=zip.goToNextFile())
+ const QString jarNames[] = {"jinput.jar", "lwjgl_util.jar", "lwjgl.jar"};
+ for (bool more = zip.goToFirstFile(); more; more = zip.goToNextFile())
{
- if(!file.open(QIODevice::ReadOnly))
+ if (!file.open(QIODevice::ReadOnly))
{
zip.close();
emitFailed("Failed to extract the lwjgl libs - error while reading archive.");
@@ -141,7 +147,7 @@ void LegacyUpdate::extractLwjgl()
}
QuaZipFileInfo info;
QString name = file.getActualFileName();
- if(name.endsWith('/'))
+ if (name.endsWith('/'))
{
file.close();
continue;
@@ -156,25 +162,25 @@ void LegacyUpdate::extractLwjgl()
}
}
// Not found? look for the natives
- if(destFileName.isEmpty())
+ if (destFileName.isEmpty())
{
#ifdef Q_OS_WIN32
QString nativesDir = "windows";
#else
- #ifdef Q_OS_MAC
+#ifdef Q_OS_MAC
QString nativesDir = "macosx";
- #else
+#else
QString nativesDir = "linux";
- #endif
+#endif
#endif
if (name.contains(nativesDir))
{
int lastSlash = name.lastIndexOf('/');
int lastBackSlash = name.lastIndexOf('\\');
- if(lastSlash != -1)
- name = name.mid(lastSlash+1);
- else if(lastBackSlash != -1)
- name = name.mid(lastBackSlash+1);
+ if (lastSlash != -1)
+ name = name.mid(lastSlash + 1);
+ else if (lastBackSlash != -1)
+ name = name.mid(lastBackSlash + 1);
destFileName = PathCombine(lwjglNativesPath, name);
}
}
@@ -190,7 +196,7 @@ void LegacyUpdate::extractLwjgl()
file.close(); // do not forget to close!
}
zip.close();
- m_reply.clear();
+ m_reply.reset();
QFile doneFile(PathCombine(lwjglTargetPath, "done"));
doneFile.open(QIODevice::WriteOnly);
doneFile.write("done.");
@@ -204,13 +210,13 @@ void LegacyUpdate::lwjglFailed()
void LegacyUpdate::jarStart()
{
- LegacyInstance * inst = (LegacyInstance *) m_inst;
- if(!inst->shouldUpdate() || inst->shouldUseCustomBaseJar())
+ LegacyInstance *inst = (LegacyInstance *)m_inst;
+ if (!inst->shouldUpdate() || inst->shouldUseCustomBaseJar())
{
ModTheJar();
return;
}
-
+
setStatus("Checking for jar updates...");
// Make directories
QDir binDir(inst->binDir());
@@ -226,13 +232,13 @@ void LegacyUpdate::jarStart()
QString urlstr("http://s3.amazonaws.com/Minecraft.Download/versions/");
QString intended_version_id = inst->intendedVersionId();
urlstr += intended_version_id + "/" + intended_version_id + ".jar";
-
+
auto dljob = new DownloadJob("Minecraft.jar for version " + intended_version_id);
dljob->addFileDownload(QUrl(urlstr), inst->defaultBaseJar());
legacyDownloadJob.reset(dljob);
connect(dljob, SIGNAL(succeeded()), SLOT(jarFinished()));
connect(dljob, SIGNAL(failed()), SLOT(jarFailed()));
- connect(dljob, SIGNAL(progress(qint64,qint64)), SIGNAL(progress(qint64,qint64)));
+ connect(dljob, SIGNAL(progress(qint64, qint64)), SIGNAL(progress(qint64, qint64)));
legacyDownloadJob->start();
}
@@ -248,34 +254,36 @@ void LegacyUpdate::jarFailed()
emitFailed("Failed to download the minecraft jar. Try again later.");
}
-bool LegacyUpdate::MergeZipFiles( QuaZip* into, QFileInfo from, QSet< QString >& contained, MetainfAction metainf )
+bool LegacyUpdate::MergeZipFiles(QuaZip *into, QFileInfo from, QSet<QString> &contained,
+ MetainfAction metainf)
{
setStatus("Installing mods - Adding " + from.fileName());
-
+
QuaZip modZip(from.filePath());
modZip.open(QuaZip::mdUnzip);
-
+
QuaZipFile fileInsideMod(&modZip);
- QuaZipFile zipOutFile( into );
- for(bool more=modZip.goToFirstFile(); more; more=modZip.goToNextFile())
+ QuaZipFile zipOutFile(into);
+ for (bool more = modZip.goToFirstFile(); more; more = modZip.goToNextFile())
{
QString filename = modZip.getCurrentFileName();
- if(filename.contains("META-INF") && metainf == LegacyUpdate::IgnoreMetainf)
+ if (filename.contains("META-INF") && metainf == LegacyUpdate::IgnoreMetainf)
{
- qDebug() << "Skipping META-INF " << filename << " from " << from.fileName();
+ QLOG_INFO() << "Skipping META-INF " << filename << " from " << from.fileName();
continue;
}
- if(contained.contains(filename))
+ if (contained.contains(filename))
{
- qDebug() << "Skipping already contained file " << filename << " from " << from.fileName();
+ QLOG_INFO() << "Skipping already contained file " << filename << " from "
+ << from.fileName();
continue;
}
contained.insert(filename);
- qDebug() << "Adding file " << filename << " from " << from.fileName();
-
- if(!fileInsideMod.open(QIODevice::ReadOnly))
+ QLOG_INFO() << "Adding file " << filename << " from " << from.fileName();
+
+ if (!fileInsideMod.open(QIODevice::ReadOnly))
{
- qDebug() << "Failed to open " << filename << " from " << from.fileName();
+ QLOG_ERROR() << "Failed to open " << filename << " from " << from.fileName();
return false;
}
/*
@@ -286,17 +294,17 @@ bool LegacyUpdate::MergeZipFiles( QuaZip* into, QFileInfo from, QSet< QString >&
/*
info_out.externalAttr = old_info.externalAttr;
*/
- if(!zipOutFile.open(QIODevice::WriteOnly, info_out))
+ if (!zipOutFile.open(QIODevice::WriteOnly, info_out))
{
- qDebug() << "Failed to open " << filename << " in the jar";
+ QLOG_ERROR() << "Failed to open " << filename << " in the jar";
fileInsideMod.close();
return false;
}
- if(!JlCompress::copyData(fileInsideMod, zipOutFile))
+ if (!JlCompress::copyData(fileInsideMod, zipOutFile))
{
zipOutFile.close();
fileInsideMod.close();
- qDebug() << "Failed to copy data of " << filename << " into the jar";
+ QLOG_ERROR() << "Failed to copy data of " << filename << " into the jar";
return false;
}
zipOutFile.close();
@@ -307,34 +315,34 @@ bool LegacyUpdate::MergeZipFiles( QuaZip* into, QFileInfo from, QSet< QString >&
void LegacyUpdate::ModTheJar()
{
- LegacyInstance * inst = (LegacyInstance *) m_inst;
-
- if(!inst->shouldRebuild())
+ LegacyInstance *inst = (LegacyInstance *)m_inst;
+
+ if (!inst->shouldRebuild())
{
emitSucceeded();
return;
}
-
+
// Get the mod list
auto modList = inst->jarModList();
-
- QFileInfo runnableJar (inst->runnableJar());
- QFileInfo baseJar (inst->baseJar());
+
+ QFileInfo runnableJar(inst->runnableJar());
+ QFileInfo baseJar(inst->baseJar());
bool base_is_custom = inst->shouldUseCustomBaseJar();
-
+
// Nothing to do if there are no jar mods to install, no backup and just the mc jar
- if(base_is_custom)
+ if (base_is_custom)
{
// yes, this can happen if the instance only has the runnable jar and not the base jar
// it *could* be assumed that such an instance is vanilla, but that wouldn't be safe
// because that's not something mmc4 guarantees
- if(runnableJar.isFile() && !baseJar.exists() && modList->empty())
+ if (runnableJar.isFile() && !baseJar.exists() && modList->empty())
{
inst->setShouldRebuild(false);
emitSucceeded();
return;
}
-
+
setStatus("Installing mods - backing up minecraft.jar...");
if (!baseJar.exists() && !QFile::copy(runnableJar.filePath(), baseJar.filePath()))
{
@@ -342,24 +350,24 @@ void LegacyUpdate::ModTheJar()
return;
}
}
-
+
if (!baseJar.exists())
{
emitFailed("The base jar " + baseJar.filePath() + " does not exist");
return;
}
-
+
if (runnableJar.exists() && !QFile::remove(runnableJar.filePath()))
{
emitFailed("Failed to delete old minecraft.jar");
return;
}
-
- //TaskStep(); // STEP 1
+
+ // TaskStep(); // STEP 1
setStatus("Installing mods - Opening minecraft.jar");
QuaZip zipOut(runnableJar.filePath());
- if(!zipOut.open(QuaZip::mdCreate))
+ if (!zipOut.open(QuaZip::mdCreate))
{
QFile::remove(runnableJar.filePath());
emitFailed("Failed to open the minecraft.jar for modding");
@@ -376,7 +384,7 @@ void LegacyUpdate::ModTheJar()
auto &mod = modList->operator[](i);
if (mod.type() == Mod::MOD_ZIPFILE)
{
- if(!MergeZipFiles(&zipOut, mod.filename(), addedFiles, LegacyUpdate::KeepMetainf))
+ if (!MergeZipFiles(&zipOut, mod.filename(), addedFiles, LegacyUpdate::KeepMetainf))
{