MCPcopy Create free account
hub / github.com/PolyMC/PolyMC / loadIndexedPackVersions

Method loadIndexedPackVersions

launcher/modplatform/modrinth/ModrinthPackIndex.cpp:95–117  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

93}
94
95void Modrinth::loadIndexedPackVersions(ModPlatform::IndexedPack& pack,
96 QJsonArray& arr,
97 const shared_qobject_ptr<QNetworkAccessManager>& network,
98 BaseInstance* inst)
99{
100 QVector<ModPlatform::IndexedVersion> unsortedVersions;
101 QString mcVersion = (static_cast<MinecraftInstance*>(inst))->getPackProfile()->getComponentVersion("net.minecraft");
102
103 for (auto versionIter : arr) {
104 auto obj = versionIter.toObject();
105 auto file = loadIndexedPackVersion(obj);
106
107 if(file.fileId.isValid()) // Heuristic to check if the returned value is valid
108 unsortedVersions.append(file);
109 }
110 auto orderSortPredicate = [](const ModPlatform::IndexedVersion& a, const ModPlatform::IndexedVersion& b) -> bool {
111 // dates are in RFC 3339 format
112 return a.date > b.date;
113 };
114 std::sort(unsortedVersions.begin(), unsortedVersions.end(), orderSortPredicate);
115 pack.versions = unsortedVersions;
116 pack.versionsLoaded = true;
117}
118
119auto Modrinth::loadIndexedPackVersion(QJsonObject &obj, QString preferred_hash_type, QString preferred_file_name) -> ModPlatform::IndexedVersion
120{

Callers

nothing calls this directly

Calls 6

getComponentVersionMethod · 0.80
getPackProfileMethod · 0.80
appendMethod · 0.80
beginMethod · 0.80
endMethod · 0.80
isValidMethod · 0.45

Tested by

no test coverage detected