Changeset - r23668:3775f9f7b899
[Not reviewed]
master
0 2 0
Charles Pigott - 5 years ago 2019-04-22 06:22:06
charlespigott@googlemail.com
Codechange: Remove SpriteTypeByte type
2 files changed with 2 insertions and 4 deletions:
0 comments (0 inline, 0 general)
src/gfx_type.h
Show inline comments
 
@@ -273,49 +273,49 @@ enum TextColour {
 
DECLARE_ENUM_AS_BIT_SET(TextColour)
 

	
 
/** Defines a few values that are related to animations using palette changes */
 
enum PaletteAnimationSizes {
 
	PALETTE_ANIM_SIZE  = 28,   ///< number of animated colours
 
	PALETTE_ANIM_START = 227,  ///< Index in  the _palettes array from which all animations are taking places (table/palettes.h)
 
};
 

	
 
/** Define the operation GfxFillRect performs */
 
enum FillRectMode {
 
	FILLRECT_OPAQUE,  ///< Fill rectangle with a single colour
 
	FILLRECT_CHECKER, ///< Draw only every second pixel, used for greying-out
 
	FILLRECT_RECOLOUR, ///< Apply a recolour sprite to the screen content
 
};
 

	
 
/** Palettes OpenTTD supports. */
 
enum PaletteType {
 
	PAL_DOS,        ///< Use the DOS palette.
 
	PAL_WINDOWS,    ///< Use the Windows palette.
 
	PAL_AUTODETECT, ///< Automatically detect the palette based on the graphics pack.
 
	MAX_PAL = 2,    ///< The number of palettes.
 
};
 

	
 
/** Types of sprites that might be loaded */
 
enum SpriteType {
 
enum SpriteType : byte {
 
	ST_NORMAL   = 0,      ///< The most basic (normal) sprite
 
	ST_MAPGEN   = 1,      ///< Special sprite for the map generator
 
	ST_FONT     = 2,      ///< A sprite used for fonts
 
	ST_RECOLOUR = 3,      ///< Recolour sprite
 
	ST_INVALID  = 4,      ///< Pseudosprite or other unusable sprite, used only internally
 
};
 

	
 
/** The number of milliseconds per game tick. */
 
static const uint MILLISECONDS_PER_TICK = 30;
 

	
 
/** Information about the currently used palette. */
 
struct Palette {
 
	Colour palette[256]; ///< Current palette. Entry 0 has to be always fully transparent!
 
	int first_dirty;     ///< The first dirty element.
 
	int count_dirty;     ///< The number of dirty elements.
 
};
 

	
 
/** Modes for 8bpp support */
 
enum Support8bpp {
 
	S8BPP_NONE = 0, ///< No support for 8bpp by OS or hardware, force 32bpp blitters.
 
	S8BPP_SYSTEM,   ///< No 8bpp support by hardware, do not try to use 8bpp video modes or hardware palettes.
 
	S8BPP_HARDWARE, ///< Full 8bpp support by OS and hardware.
 
};
 

	
src/spritecache.cpp
Show inline comments
 
@@ -8,57 +8,55 @@
 
 */
 

	
 
/** @file spritecache.cpp Caching of sprites. */
 

	
 
#include "stdafx.h"
 
#include "fileio_func.h"
 
#include "spriteloader/grf.hpp"
 
#include "gfx_func.h"
 
#include "error.h"
 
#include "zoom_func.h"
 
#include "settings_type.h"
 
#include "blitter/factory.hpp"
 
#include "core/math_func.hpp"
 
#include "core/mem_func.hpp"
 

	
 
#include "table/sprites.h"
 
#include "table/strings.h"
 
#include "table/palette_convert.h"
 

	
 
#include "safeguards.h"
 

	
 
/* Default of 4MB spritecache */
 
uint _sprite_cache_size = 4;
 

	
 
typedef SimpleTinyEnumT<SpriteType, byte> SpriteTypeByte;
 

	
 
struct SpriteCache {
 
	void *ptr;
 
	size_t file_pos;
 
	uint32 id;
 
	uint16 file_slot;
 
	int16 lru;
 
	SpriteTypeByte 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.
 
	bool warned;         ///< True iff the user has been warned about incorrect use of this sprite
 
	byte container_ver;  ///< Container version of the GRF the sprite is from.
 
};
 

	
 

	
 
static uint _spritecache_items = 0;
 
static SpriteCache *_spritecache = nullptr;
 

	
 

	
 
static inline SpriteCache *GetSpriteCache(uint index)
 
{
 
	return &_spritecache[index];
 
}
 

	
 
static inline bool IsMapgenSpriteID(SpriteID sprite)
 
{
 
	return IsInsideMM(sprite, 4845, 4882);
 
}
 

	
 
static SpriteCache *AllocateSpriteCache(uint index)
 
{
 
	if (index >= _spritecache_items) {
 
		/* Add another 1024 items to the 'pool' */
 
		uint items = Align(index + 1, 1024);
0 comments (0 inline, 0 general)