1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-15 11:03:00 +01:00

Fix #19989: Crash with small scenery objects having no offsets defined (#19990)

This commit is contained in:
Matthias Moninger
2023-04-19 08:35:09 +03:00
committed by GitHub
parent 2fd3eb47e7
commit 98aa816e5f
3 changed files with 4 additions and 1 deletions

View File

@@ -62,6 +62,7 @@ struct SmallSceneryEntry
money64 price;
money64 removal_price;
uint8_t* frame_offsets;
uint16_t FrameOffsetCount;
uint16_t animation_delay;
uint16_t animation_mask;
uint16_t num_frames;

View File

@@ -76,10 +76,12 @@ void SmallSceneryObject::Load()
_legacyType.image = LoadImages();
_legacyType.scenery_tab_id = OBJECT_ENTRY_INDEX_NULL;
_legacyType.FrameOffsetCount = 0;
if (_legacyType.HasFlag(SMALL_SCENERY_FLAG_HAS_FRAME_OFFSETS))
{
_legacyType.frame_offsets = _frameOffsets.data();
_legacyType.FrameOffsetCount = static_cast<uint16_t>(_frameOffsets.size());
}
PerformFixes();

View File

@@ -277,7 +277,7 @@ static void PaintSmallSceneryBody(
frame = (frame >> delay) & sceneryEntry->animation_mask;
auto imageIndex = 0;
if (frame < sceneryEntry->num_frames)
if (frame < sceneryEntry->FrameOffsetCount)
{
imageIndex = sceneryEntry->frame_offsets[frame];
}