| 302 | } |
| 303 | |
| 304 | void ReadWriteObjectsChunk(OrcaStream& os) |
| 305 | { |
| 306 | static constexpr uint8_t kDescriptorNone = 0; |
| 307 | static constexpr uint8_t kDescriptorDat = 1; |
| 308 | static constexpr uint8_t kDescriptorJson = 2; |
| 309 | |
| 310 | if (os.getMode() == OrcaStream::Mode::reading) |
| 311 | { |
| 312 | std::fill(std::begin(_pathToSurfaceMap), std::end(_pathToSurfaceMap), kObjectEntryIndexNull); |
| 313 | std::fill(std::begin(_pathToQueueSurfaceMap), std::end(_pathToQueueSurfaceMap), kObjectEntryIndexNull); |
| 314 | std::fill(std::begin(_pathToRailingsMap), std::end(_pathToRailingsMap), kObjectEntryIndexNull); |
| 315 | auto* pathToSurfaceMap = _pathToSurfaceMap; |
| 316 | auto* pathToQueueSurfaceMap = _pathToQueueSurfaceMap; |
| 317 | auto* pathToRailingsMap = _pathToRailingsMap; |
| 318 | const auto version = os.getHeader().targetVersion; |
| 319 | |
| 320 | ObjectList requiredObjects; |
| 321 | struct LegacyFootpathMapping |
| 322 | { |
| 323 | ObjectEntryIndex originalEntryIndex; |
| 324 | const RCT2::FootpathMapping& mapping; |
| 325 | }; |
| 326 | std::vector<LegacyFootpathMapping> legacyPathMappings; |
| 327 | os.readWriteChunk( |
| 328 | ParkFileChunkType::objects, [&requiredObjects, version, &legacyPathMappings](OrcaStream::ChunkStream& cs) { |
| 329 | auto numSubLists = cs.read<uint16_t>(); |
| 330 | for (size_t i = 0; i < numSubLists; i++) |
| 331 | { |
| 332 | auto objectType = static_cast<ObjectType>(cs.read<uint16_t>()); |
| 333 | auto subListSize = static_cast<ObjectEntryIndex>(cs.read<uint32_t>()); |
| 334 | for (ObjectEntryIndex j = 0; j < subListSize; j++) |
| 335 | { |
| 336 | auto kind = cs.read<uint8_t>(); |
| 337 | |
| 338 | switch (kind) |
| 339 | { |
| 340 | case kDescriptorNone: |
| 341 | break; |
| 342 | case kDescriptorDat: |
| 343 | { |
| 344 | RCTObjectEntry datEntry; |
| 345 | cs.read(&datEntry, sizeof(datEntry)); |
| 346 | ObjectEntryDescriptor desc(datEntry); |
| 347 | if (version < kFixedObsoleteFootpathsVersion && datEntry.GetType() == ObjectType::paths) |
| 348 | { |
| 349 | auto footpathMapping = GetFootpathMapping(desc); |
| 350 | if (footpathMapping != nullptr) |
| 351 | { |
| 352 | legacyPathMappings.push_back(LegacyFootpathMapping{ j, *footpathMapping }); |
| 353 | continue; |
| 354 | } |
| 355 | } |
| 356 | |
| 357 | requiredObjects.SetObject(j, desc); |
| 358 | break; |
| 359 | } |
| 360 | case kDescriptorJson: |
| 361 | { |
nothing calls this directly
no test coverage detected