Skip to content

Commit

Permalink
Engine: fix SpriteCache letting non-existant sprite number to MRU list
Browse files Browse the repository at this point in the history
  • Loading branch information
ivan-mogilko committed Feb 5, 2025
1 parent 3a1fc8d commit 9bb2350
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion Common/ac/spritecache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -227,13 +227,15 @@ Bitmap *SpriteCache::operator [] (sprkey_t index)
{
// invalid sprite slot
assert(index >= 0); // out of positive range indexes are valid to fail
if (index < 0 || (size_t)index >= _spriteData.size())
if (!DoesSpriteExist(index))
return nullptr;

// Externally added sprite or locked sprite, don't put it into MRU list
if (_spriteData[index].IsExternalSprite() || _spriteData[index].IsLocked())
return _spriteData[index].Image;

// Safety check: must be a sprite from resources
assert(_spriteData[index].IsAssetSprite());
if (_spriteData[index].Image)
{
// Move to the beginning of the MRU list
Expand Down

0 comments on commit 9bb2350

Please sign in to comment.