File diff r10959:4b345c618e31 → r10960:e97ebf9cf99b
src/spritecache.cpp
Show inline comments
 
/* $Id$ */
 

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

	
 
#include "stdafx.h"
 
#include "openttd.h"
 
#include "variables.h"
 
#include "debug.h"
 
#include "spritecache.h"
 
#include "gfx_type.h"
 
#include "fileio_func.h"
 
#include "spriteloader/grf.hpp"
 
#include "core/alloc_func.hpp"
 
#include "core/math_func.hpp"
 
#include "gfx_func.h"
 
#ifdef WITH_PNG
 
#include "spriteloader/png.hpp"
 
#endif /* WITH_PNG */
 
#include "blitter/factory.hpp"
 
#include "core/math_func.hpp"
 
#include "core/enum_type.hpp"
 

	
 
#include "table/sprites.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.
 
	bool warned;         ///< True iff the user has been warned about incorrect use of this sprite
 
};
 

	
 

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

	
 

	
 
static inline SpriteCache *GetSpriteCache(uint index)