Create enum for sprite cache control flag bits

This commit is contained in:
Jonathan G Rennison
2022-08-14 09:30:41 +01:00
parent 4e5e85e7aa
commit 27316f70ec
2 changed files with 10 additions and 9 deletions

View File

@@ -98,20 +98,16 @@ PACK_N(struct SpriteCache {
SpriteType type; ///< In some cases a single sprite is misused by two NewGRFs. Once as real sprite and once as recolour sprite. If the recolour sprite gets into the cache it might be drawn as real sprite which causes enormous trouble. SpriteType type; ///< In some cases a single sprite is misused by two NewGRFs. Once as real sprite and once as recolour sprite. If the recolour sprite gets into the cache it might be drawn as real sprite which causes enormous trouble.
/** byte flags; ///< Control flags, see SpriteCacheCtrlFlags
* Bit 0: warned True iff the user has been warned about incorrect use of this sprite.
* Bit 1: has_non_palette True iff there is at least one non-paletter sprite present (such that 32bpp mode can be used).
*/
byte flags;
void *GetPtr() { return this->buffer.GetPtr(); } void *GetPtr() { return this->buffer.GetPtr(); }
SpriteType GetType() const { return this->type; } SpriteType GetType() const { return this->type; }
void SetType(SpriteType type) { this->type = type; } void SetType(SpriteType type) { this->type = type; }
bool GetWarned() const { return HasBit(this->flags, 0); } bool GetWarned() const { return HasBit(this->flags, SCCF_WARNED); }
void SetWarned(bool warned) { SB(this->flags, 0, 1, warned ? 1 : 0); } void SetWarned(bool warned) { SB(this->flags, SCCF_WARNED, 1, warned ? 1 : 0); }
bool GetHasNonPalette() const { return HasBit(this->flags, 1); } bool GetHasNonPalette() const { return HasBit(this->flags, SCCF_HAS_NON_PALETTE); }
void SetHasNonPalette(bool non_palette) { SB(this->flags, 1, 1, non_palette ? 1 : 0); } void SetHasNonPalette(bool non_palette) { SB(this->flags, SCCF_HAS_NON_PALETTE, 1, non_palette ? 1 : 0); }
}, 4); }, 4);
static std::vector<SpriteCache> _spritecache; static std::vector<SpriteCache> _spritecache;

View File

@@ -22,6 +22,11 @@ struct Sprite {
byte data[]; ///< Sprite data. byte data[]; ///< Sprite data.
}; };
enum SpriteCacheCtrlFlags {
SCCF_WARNED = 0, ///< True iff the user has been warned about incorrect use of this sprite.
SCCF_HAS_NON_PALETTE = 1, ///< True iff there is at least one non-paletter sprite present (such that 32bpp mode can be used).
};
extern uint _sprite_cache_size; extern uint _sprite_cache_size;
typedef void *AllocatorProc(size_t size); typedef void *AllocatorProc(size_t size);