Fix liteloader, some cleanups.
This commit is contained in:
60
logic/RWStorage.h
Normal file
60
logic/RWStorage.h
Normal file
@ -0,0 +1,60 @@
|
||||
#pragma once
|
||||
template <typename K, typename V>
|
||||
class RWStorage
|
||||
{
|
||||
public:
|
||||
void add(K key, V value)
|
||||
{
|
||||
QWriteLocker l(&lock);
|
||||
cache[key] = value;
|
||||
stale_entries.remove(key);
|
||||
}
|
||||
V get(K key)
|
||||
{
|
||||
QReadLocker l(&lock);
|
||||
if(cache.contains(key))
|
||||
{
|
||||
return cache[key];
|
||||
}
|
||||
else return V();
|
||||
}
|
||||
bool get(K key, V& value)
|
||||
{
|
||||
QReadLocker l(&lock);
|
||||
if(cache.contains(key))
|
||||
{
|
||||
value = cache[key];
|
||||
return true;
|
||||
}
|
||||
else return false;
|
||||
}
|
||||
bool has(K key)
|
||||
{
|
||||
QReadLocker l(&lock);
|
||||
return cache.contains(key);
|
||||
}
|
||||
bool stale(K key)
|
||||
{
|
||||
QReadLocker l(&lock);
|
||||
if(!cache.contains(key))
|
||||
return true;
|
||||
return stale_entries.contains(key);
|
||||
}
|
||||
void setStale(K key)
|
||||
{
|
||||
QReadLocker l(&lock);
|
||||
if(cache.contains(key))
|
||||
{
|
||||
stale_entries.insert(key);
|
||||
}
|
||||
}
|
||||
void clear()
|
||||
{
|
||||
QWriteLocker l(&lock);
|
||||
cache.clear();
|
||||
}
|
||||
private:
|
||||
QReadWriteLock lock;
|
||||
QMap<K, V> cache;
|
||||
QSet<K> stale_entries;
|
||||
};
|
@ -22,7 +22,6 @@
|
||||
#include <QJsonObject>
|
||||
#include <QJsonArray>
|
||||
#include <QVariant>
|
||||
#include <QDebug>
|
||||
|
||||
#include "logger/QsLog.h"
|
||||
|
||||
|
@ -21,7 +21,6 @@
|
||||
#include <QJsonObject>
|
||||
#include <QJsonArray>
|
||||
#include <QVariant>
|
||||
#include <QDebug>
|
||||
|
||||
#include "logger/QsLog.h"
|
||||
|
||||
|
@ -22,7 +22,6 @@
|
||||
#include <QJsonObject>
|
||||
#include <QJsonArray>
|
||||
#include <QVariant>
|
||||
#include <QDebug>
|
||||
|
||||
#include "logger/QsLog.h"
|
||||
|
||||
|
@ -49,13 +49,12 @@ bool LiteLoaderInstaller::add(OneSixInstance *to)
|
||||
|
||||
QJsonArray libraries;
|
||||
|
||||
for (auto libStr : m_version->libraries)
|
||||
for (auto rawLibrary : m_version->libraries)
|
||||
{
|
||||
OneSixLibrary lib(libStr);
|
||||
rawLibrary->insertType = RawLibrary::Prepend;
|
||||
OneSixLibrary lib(rawLibrary);
|
||||
lib.finalize();
|
||||
QJsonObject libObj = lib.toJson();
|
||||
libObj.insert("insert", QString("prepend"));
|
||||
libraries.append(libObj);
|
||||
libraries.append(lib.toJson());
|
||||
}
|
||||
|
||||
// liteloader
|
||||
|
@ -16,6 +16,7 @@
|
||||
#include "LiteLoaderVersionList.h"
|
||||
#include "MultiMC.h"
|
||||
#include "logic/net/URLConstants.h"
|
||||
#include <MMCError.h>
|
||||
|
||||
#include <QtXml>
|
||||
|
||||
@ -206,7 +207,21 @@ void LLListLoadTask::listDownloaded()
|
||||
const QJsonArray libs = artefact.value("libraries").toArray();
|
||||
for (auto lIt = libs.begin(); lIt != libs.end(); ++lIt)
|
||||
{
|
||||
version->libraries.append((*lIt).toObject().value("name").toString());
|
||||
auto libobject = (*lIt).toObject();
|
||||
try
|
||||
{
|
||||
auto lib = RawLibrary::fromJson(libobject, "versions.json");
|
||||
if(lib->m_name.startsWith("org.ow2.asm:asm-all:"))
|
||||
{
|
||||
lib->m_base_url = "http://repo.maven.apache.org/maven2/";
|
||||
}
|
||||
version->libraries.append(lib);
|
||||
}
|
||||
catch (MMCError &e)
|
||||
{
|
||||
QLOG_ERROR() << "Couldn't read JSON object:";
|
||||
continue;
|
||||
}
|
||||
}
|
||||
perMcVersionList.append(version);
|
||||
}
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include "logic/BaseVersionList.h"
|
||||
#include "logic/tasks/Task.h"
|
||||
#include "logic/net/NetJob.h"
|
||||
#include <logic/minecraft/RawLibrary.h>
|
||||
|
||||
class LLListLoadTask;
|
||||
class QNetworkReply;
|
||||
@ -55,7 +56,7 @@ public:
|
||||
int timestamp;
|
||||
bool isLatest;
|
||||
QString tweakClass;
|
||||
QStringList libraries;
|
||||
QList<RawLibraryPtr> libraries;
|
||||
|
||||
// meta
|
||||
QString defaultUrl;
|
||||
|
@ -13,7 +13,6 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <QDebug>
|
||||
#include <QFile>
|
||||
#include <QDir>
|
||||
#include <QUuid>
|
||||
|
@ -22,7 +22,6 @@
|
||||
#include <QMessageBox>
|
||||
#include <QObject>
|
||||
#include <QDir>
|
||||
#include <QDebug>
|
||||
#include <qresource.h>
|
||||
#include <modutils.h>
|
||||
|
||||
|
@ -91,7 +91,7 @@ public:
|
||||
|
||||
/*!
|
||||
* \brief Sets the value of the setting with the given ID.
|
||||
* If no setting with the given ID exists, returns false and logs to qDebug
|
||||
* If no setting with the given ID exists, returns false
|
||||
* \param id The ID of the setting to change.
|
||||
* \param value The new value of the setting.
|
||||
* \return True if successful, false if it failed.
|
||||
|
Reference in New Issue
Block a user