| 153 | }; |
| 154 | |
| 155 | void AssetPack::Load() |
| 156 | { |
| 157 | auto path = Path.u8string(); |
| 158 | auto archive = Zip::Open(path, ZipAccess::read); |
| 159 | if (!archive->Exists(ManifestFileName)) |
| 160 | { |
| 161 | throw std::runtime_error("Manifest does not exist."); |
| 162 | } |
| 163 | |
| 164 | AssetPackLoadContext loadContext(path, archive.get()); |
| 165 | |
| 166 | auto manifestJson = archive->GetFileData(ManifestFileName); |
| 167 | auto jManifest = Json::FromVector(manifestJson); |
| 168 | auto& jObjects = jManifest["objects"]; |
| 169 | |
| 170 | _entries.clear(); |
| 171 | for (auto& jObject : jObjects) |
| 172 | { |
| 173 | Entry entry; |
| 174 | entry.ObjectId = jObject["id"].get<std::string>(); |
| 175 | |
| 176 | if (jObject.contains("samples")) |
| 177 | { |
| 178 | entry.TableIndex = _sampleTable.GetCount(); |
| 179 | _sampleTable.ReadFromJson(&loadContext, jObject); |
| 180 | entry.TableLength = _sampleTable.GetCount() - entry.TableIndex; |
| 181 | } |
| 182 | _entries.push_back(entry); |
| 183 | } |
| 184 | } |
| 185 | } // namespace OpenRCT2 |
no test coverage detected