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

Method Load

src/openrct2/object/RideObject.cpp:294–362  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

292 }
293
294 void RideObject::Load()
295 {
296 GetStringTable().Sort();
297 _legacyType.naming.Name = LanguageAllocateObjectString(GetName());
298 _legacyType.naming.Description = LanguageAllocateObjectString(GetDescription());
299 _legacyType.capacity = LanguageAllocateObjectString(GetCapacity());
300 _legacyType.images_offset = LoadImages();
301 _legacyType.vehicle_preset_list = &_presetColours;
302
303 int32_t currentCarImagesOffset = _legacyType.images_offset + RCT2::ObjectLimits::kMaxRideTypesPerRideEntry;
304 for (int32_t i = 0; i < RCT2::ObjectLimits::kMaxCarTypesPerRideEntry; i++)
305 {
306 CarEntry& carEntry = _legacyType.Cars[i];
307 if (carEntry.GroupEnabled(SpriteGroupType::SlopeFlat))
308 {
309 // RCT2 calculates num_vertical_frames and num_horizontal_frames and overwrites these properties on the car
310 // entry. Immediately afterwards, the two were multiplied in order to calculate base_num_frames and were never
311 // used again. This has been changed to use the calculation results directly - num_vertical_frames and
312 // num_horizontal_frames are no longer set on the car entry.
313 // 0x6DE946
314 carEntry.base_num_frames = CalculateNumVerticalFrames(carEntry) * CalculateNumHorizontalFrames(carEntry);
315 uint32_t baseImageId = currentCarImagesOffset;
316 uint32_t imageIndex = baseImageId;
317 carEntry.base_image_id = baseImageId;
318
319 for (uint8_t spriteGroup = 0; spriteGroup < EnumValue(SpriteGroupType::Count); spriteGroup++)
320 {
321 if (carEntry.SpriteGroups[spriteGroup].Enabled())
322 {
323 carEntry.SpriteGroups[spriteGroup].imageId = imageIndex;
324 const auto spriteCount = carEntry.base_num_frames
325 * carEntry.NumRotationSprites(static_cast<SpriteGroupType>(spriteGroup))
326 * SpriteGroupMultiplier[spriteGroup];
327 imageIndex += spriteCount;
328 }
329 }
330
331 carEntry.NumCarImages = imageIndex - currentCarImagesOffset;
332
333 // Move the offset over this car's images. Including peeps
334 currentCarImagesOffset = imageIndex + carEntry.no_seating_rows * carEntry.NumCarImages;
335 // 0x6DEB0D
336
337 if (!carEntry.flags.has(CarEntryFlag::recalculateSpriteBounds))
338 {
339 int32_t num_images = currentCarImagesOffset - baseImageId;
340 if (carEntry.flags.has(CarEntryFlag::spriteBoundsIncludeInvertedSet))
341 {
342 num_images *= 2;
343 }
344
345 if (_shouldLoadImages)
346 {
347 CarEntrySetImageMaxSizes(carEntry, num_images);
348 }
349 }
350
351 if (!_peepLoadingPositions[i].empty())

Callers

nothing calls this directly

Calls 10

EnumValueFunction · 0.85
CarEntrySetImageMaxSizesFunction · 0.85
GroupEnabledMethod · 0.80
EnabledMethod · 0.80
NumRotationSpritesMethod · 0.80
hasMethod · 0.65
GetNameFunction · 0.50
SortMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected