MCPcopy Create free account
hub / github.com/OpenRCT2/OpenRCT2 / ReadWriteObjectsChunk

Method ReadWriteObjectsChunk

src/openrct2/park/ParkFile.cpp:304–485  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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 {

Callers

nothing calls this directly

Calls 15

fillFunction · 0.85
GetFootpathMappingFunction · 0.85
MapToNewObjectIdentifierFunction · 0.85
VersionTupleFunction · 0.85
AppendRequiredObjectsFunction · 0.85
GetContextFunction · 0.85
getTransientObjectTypesFunction · 0.85
VersionStringFunction · 0.85
readWriteChunkMethod · 0.80

Tested by

no test coverage detected