Renamed requires fields

Signed-off-by: Trial97 <alexandru.tripon97@gmail.com>
This commit is contained in:
Trial97 2023-06-06 10:34:05 +03:00
parent 1840505a0f
commit 6505a62801
No known key found for this signature in database
GPG Key ID: 55EF5DA53DB36318
9 changed files with 19 additions and 20 deletions

View File

@ -56,10 +56,10 @@ static Version::Ptr parseCommonVersion(const QString &uid, const QJsonObject &ob
version->setType(ensureString(obj, "type", QString())); version->setType(ensureString(obj, "type", QString()));
version->setRecommended(ensureBoolean(obj, QString("recommended"), false)); version->setRecommended(ensureBoolean(obj, QString("recommended"), false));
version->setVolatile(ensureBoolean(obj, QString("volatile"), false)); version->setVolatile(ensureBoolean(obj, QString("volatile"), false));
RequireSet requires, conflicts; RequireSet reqs, conflicts;
parseRequires(obj, &requires, "requires"); parseRequires(obj, &reqs, "requires");
parseRequires(obj, &conflicts, "conflicts"); parseRequires(obj, &conflicts, "conflicts");
version->setRequires(requires, conflicts); version->setRequires(reqs, conflicts);
return version; return version;
} }
@ -176,7 +176,6 @@ void parseRequires(const QJsonObject& obj, RequireSet* ptr, const char * keyName
{ {
if(obj.contains(keyName)) if(obj.contains(keyName))
{ {
QSet<QString> requires;
auto reqArray = requireArray(obj, keyName); auto reqArray = requireArray(obj, keyName);
auto iter = reqArray.begin(); auto iter = reqArray.begin();
while(iter != reqArray.end()) while(iter != reqArray.end())

View File

@ -116,9 +116,9 @@ void Meta::Version::setTime(const qint64 time)
emit timeChanged(); emit timeChanged();
} }
void Meta::Version::setRequires(const Meta::RequireSet &requires, const Meta::RequireSet &conflicts) void Meta::Version::setRequires(const Meta::RequireSet &reqs, const Meta::RequireSet &conflicts)
{ {
m_requires = requires; m_requires = reqs;
m_conflicts = conflicts; m_conflicts = conflicts;
emit requiresChanged(); emit requiresChanged();
} }

View File

@ -63,7 +63,7 @@ public:
{ {
return m_time; return m_time;
} }
const Meta::RequireSet &requires() const const Meta::RequireSet &requiredSet() const
{ {
return m_requires; return m_requires;
} }
@ -91,7 +91,7 @@ public:
public: // for usage by format parsers only public: // for usage by format parsers only
void setType(const QString &type); void setType(const QString &type);
void setTime(const qint64 time); void setTime(const qint64 time);
void setRequires(const Meta::RequireSet &requires, const Meta::RequireSet &conflicts); void setRequires(const Meta::RequireSet &reqs, const Meta::RequireSet &conflicts);
void setVolatile(bool volatile_); void setVolatile(bool volatile_);
void setRecommended(bool recommended); void setRecommended(bool recommended);
void setProvidesRecommendations(); void setProvidesRecommendations();

View File

@ -77,7 +77,7 @@ QVariant VersionList::data(const QModelIndex &index, int role) const
case ParentVersionRole: case ParentVersionRole:
{ {
// FIXME: HACK: this should be generic and be replaced by something else. Anything that is a hard 'equals' dep is a 'parent uid'. // FIXME: HACK: this should be generic and be replaced by something else. Anything that is a hard 'equals' dep is a 'parent uid'.
auto & reqs = version->requires(); auto & reqs = version->requiredSet();
auto iter = std::find_if(reqs.begin(), reqs.end(), [](const Require & req) auto iter = std::find_if(reqs.begin(), reqs.end(), [](const Require & req)
{ {
return req.uid == "net.minecraft"; return req.uid == "net.minecraft";
@ -92,7 +92,7 @@ QVariant VersionList::data(const QModelIndex &index, int role) const
case UidRole: return version->uid(); case UidRole: return version->uid();
case TimeRole: return version->time(); case TimeRole: return version->time();
case RequiresRole: return QVariant::fromValue(version->requires()); case RequiresRole: return QVariant::fromValue(version->requiredSet());
case SortRole: return version->rawTime(); case SortRole: return version->rawTime();
case VersionPtrRole: return QVariant::fromValue(version); case VersionPtrRole: return QVariant::fromValue(version);
case RecommendedRole: return version->isRecommended(); case RecommendedRole: return version->isRecommended();

View File

@ -451,9 +451,9 @@ void Component::updateCachedData()
m_cachedVolatile = file->m_volatile; m_cachedVolatile = file->m_volatile;
changed = true; changed = true;
} }
if(!deepCompare(m_cachedRequires, file->requires)) if(!deepCompare(m_cachedRequires, file->m_requires))
{ {
m_cachedRequires = file->requires; m_cachedRequires = file->m_requires;
changed = true; changed = true;
} }
if(!deepCompare(m_cachedConflicts, file->conflicts)) if(!deepCompare(m_cachedConflicts, file->conflicts))

View File

@ -276,7 +276,7 @@ VersionFilePtr OneSixVersionFormat::versionFileFromJson(const QJsonDocument &doc
if (root.contains("requires")) if (root.contains("requires"))
{ {
Meta::parseRequires(root, &out->requires); Meta::parseRequires(root, &out->m_requires);
} }
QString dependsOnMinecraftVersion = root.value("mcVersion").toString(); QString dependsOnMinecraftVersion = root.value("mcVersion").toString();
if(!dependsOnMinecraftVersion.isEmpty()) if(!dependsOnMinecraftVersion.isEmpty())
@ -284,9 +284,9 @@ VersionFilePtr OneSixVersionFormat::versionFileFromJson(const QJsonDocument &doc
Meta::Require mcReq; Meta::Require mcReq;
mcReq.uid = "net.minecraft"; mcReq.uid = "net.minecraft";
mcReq.equalsVersion = dependsOnMinecraftVersion; mcReq.equalsVersion = dependsOnMinecraftVersion;
if (out->requires.count(mcReq) == 0) if (out->m_requires.count(mcReq) == 0)
{ {
out->requires.insert(mcReq); out->m_requires.insert(mcReq);
} }
} }
if (root.contains("conflicts")) if (root.contains("conflicts"))
@ -392,9 +392,9 @@ QJsonDocument OneSixVersionFormat::versionFileToJson(const VersionFilePtr &patch
} }
root.insert("mods", array); root.insert("mods", array);
} }
if(!patch->requires.empty()) if(!patch->m_requires.empty())
{ {
Meta::serializeRequires(root, &patch->requires, "requires"); Meta::serializeRequires(root, &patch->m_requires, "requires");
} }
if(!patch->conflicts.empty()) if(!patch->conflicts.empty())
{ {

View File

@ -138,7 +138,7 @@ public: /* data */
* Prism Launcher: set of packages this depends on * Prism Launcher: set of packages this depends on
* NOTE: this is shared with the meta format!!! * NOTE: this is shared with the meta format!!!
*/ */
Meta::RequireSet requires; Meta::RequireSet m_requires;
/** /**
* Prism Launcher: set of packages this conflicts with * Prism Launcher: set of packages this conflicts with

View File

@ -352,7 +352,7 @@ QString PackInstallTask::getVersionForLoader(QString uid)
if(m_version.loader.recommended || m_version.loader.latest) { if(m_version.loader.recommended || m_version.loader.latest) {
for (int i = 0; i < vlist->versions().size(); i++) { for (int i = 0; i < vlist->versions().size(); i++) {
auto version = vlist->versions().at(i); auto version = vlist->versions().at(i);
auto reqs = version->requires(); auto reqs = version->requiredSet();
// filter by minecraft version, if the loader depends on a certain version. // filter by minecraft version, if the loader depends on a certain version.
// not all mod loaders depend on a given Minecraft version, so we won't do this // not all mod loaders depend on a given Minecraft version, so we won't do this

View File

@ -68,7 +68,7 @@ QString AtlUserInteractionSupportImpl::chooseVersion(Meta::VersionList::Ptr vlis
// select recommended build // select recommended build
for (int i = 0; i < vlist->versions().size(); i++) { for (int i = 0; i < vlist->versions().size(); i++) {
auto version = vlist->versions().at(i); auto version = vlist->versions().at(i);
auto reqs = version->requires(); auto reqs = version->requiredSet();
// filter by minecraft version, if the loader depends on a certain version. // filter by minecraft version, if the loader depends on a certain version.
if (minecraftVersion != nullptr) { if (minecraftVersion != nullptr) {