Fix old map array tunnel head conversion
[openttd/fttd.git] / src / spritecache.h
blob481d55ed94b45f7c4bb84570a3f0f6e2ef7e9a73
1 /* $Id$ */
3 /*
4 * This file is part of OpenTTD.
5 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
6 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
7 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
8 */
10 /** @file spritecache.h Functions to cache sprites in memory. */
12 #ifndef SPRITECACHE_H
13 #define SPRITECACHE_H
15 #include "core/alloc_type.hpp"
16 #include "blitter/blitter.h"
17 #include "gfx_type.h"
19 extern uint _sprite_cache_size;
21 void *GetRawSprite (SpriteID sprite, SpriteType type, bool cache = true);
22 bool SpriteExists(SpriteID sprite);
24 bool IsNormalSprite (SpriteID sprite);
25 uint GetOriginFileSlot(SpriteID sprite);
26 uint GetSpriteCountForSlot(uint file_slot, SpriteID begin, SpriteID end);
27 uint GetMaxSpriteID();
30 static inline const Sprite *GetSprite(SpriteID sprite, SpriteType type)
32 assert (type == ST_NORMAL || type == ST_FONT);
33 return (Sprite*)GetRawSprite(sprite, type);
36 static inline const byte *GetNonSprite(SpriteID sprite, SpriteType type)
38 assert(type == ST_RECOLOUR);
39 return (byte*)GetRawSprite(sprite, type);
42 /** Data structure describing a map generator sprite. */
43 struct MapGenSprite : Sprite {
44 byte data[]; ///< Sprite data
47 const MapGenSprite *GetMapGenSprite (SpriteID sprite);
49 void GfxInitSpriteMem();
50 void GfxClearSpriteCache();
51 void IncreaseSpriteLRU();
53 void ReadGRFSpriteOffsets (const struct GRFHeader *header);
54 size_t GetGRFSpriteOffset(uint32 id);
55 bool LoadNextSprite(int load_index, byte file_index, uint file_sprite_id, byte container_version);
56 bool SkipSpriteData(byte type, uint16 num);
57 void DupSprite(SpriteID old_spr, SpriteID new_spr);
59 #endif /* SPRITECACHE_H */