Codechange: Replace pointer to Sprite array with reference to SpriteCollection. (#11580)

Add `SpriteLoader::SpriteCollection` type which is an array of `SpriteLoad::Sprite`.

This removes the ambiguity of what `SpriteLoader::Sprite *` is pointing to,
and cleans up mismatches using both dereference -> and array access [] for the
same object.
This commit is contained in:
Peter Nelson
2023-12-20 20:38:21 +00:00
committed by GitHub
parent 7466c3c39e
commit b85ecf9ac2
25 changed files with 90 additions and 82 deletions

View File

@@ -65,6 +65,11 @@ public:
static ReusableBuffer<SpriteLoader::CommonPixel> buffer[ZOOM_LVL_END];
};
/**
* Type defining a collection of sprites, one for each zoom level.
*/
using SpriteCollection = std::array<Sprite, ZOOM_LVL_END>;
/**
* Load a sprite from the disk and return a sprite struct which is the same for all loaders.
* @param[out] sprite The sprites to fill with data.
@@ -75,7 +80,7 @@ public:
* @param control_flags Control flags, see SpriteCacheCtrlFlags.
* @return Bit mask of the zoom levels successfully loaded or 0 if no sprite could be loaded.
*/
virtual uint8_t LoadSprite(SpriteLoader::Sprite *sprite, SpriteFile &file, size_t file_pos, SpriteType sprite_type, bool load_32bpp, byte control_flags) = 0;
virtual uint8_t LoadSprite(SpriteLoader::SpriteCollection &sprite, SpriteFile &file, size_t file_pos, SpriteType sprite_type, bool load_32bpp, byte control_flags) = 0;
virtual ~SpriteLoader() = default;
};
@@ -94,7 +99,7 @@ public:
/**
* Convert a sprite from the loader to our own format.
*/
virtual Sprite *Encode(const SpriteLoader::Sprite *sprite, AllocatorProc *allocator) = 0;
virtual Sprite *Encode(const SpriteLoader::SpriteCollection &sprite, AllocatorProc *allocator) = 0;
/**
* Get the value which the height and width on a sprite have to be aligned by.