| 103 | } |
| 104 | |
| 105 | auto FlameMod::loadIndexedPackVersion(QJsonObject& obj, bool load_changelog) -> ModPlatform::IndexedVersion |
| 106 | { |
| 107 | auto versionArray = Json::requireArray(obj, "gameVersions"); |
| 108 | if (versionArray.isEmpty()) { |
| 109 | return {}; |
| 110 | } |
| 111 | |
| 112 | ModPlatform::IndexedVersion file; |
| 113 | for (auto mcVer : versionArray) { |
| 114 | auto str = mcVer.toString(); |
| 115 | |
| 116 | if (str.contains('.')) |
| 117 | file.mcVersion.append(str); |
| 118 | } |
| 119 | |
| 120 | file.addonId = Json::requireInteger(obj, "modId"); |
| 121 | file.fileId = Json::requireInteger(obj, "id"); |
| 122 | file.date = Json::requireString(obj, "fileDate"); |
| 123 | file.version = Json::requireString(obj, "displayName"); |
| 124 | file.downloadUrl = Json::ensureString(obj, "downloadUrl"); |
| 125 | file.fileName = Json::requireString(obj, "fileName"); |
| 126 | |
| 127 | auto hash_list = Json::ensureArray(obj, "hashes"); |
| 128 | for (auto h : hash_list) { |
| 129 | auto hash_entry = Json::ensureObject(h); |
| 130 | auto hash_types = ProviderCaps.hashType(ModPlatform::Provider::FLAME); |
| 131 | auto hash_algo = enumToString(Json::ensureInteger(hash_entry, "algo", 1, "algorithm")); |
| 132 | if (hash_types.contains(hash_algo)) { |
| 133 | file.hash = Json::requireString(hash_entry, "value"); |
| 134 | file.hash_type = hash_algo; |
| 135 | break; |
| 136 | } |
| 137 | } |
| 138 | |
| 139 | if(load_changelog) |
| 140 | file.changelog = api.getModFileChangelog(file.addonId.toInt(), file.fileId.toInt()); |
| 141 | |
| 142 | return file; |
| 143 | } |
nothing calls this directly
no test coverage detected