OpenTTD Source
12.0-beta2
|
Go to the source code of this file.
Data Structures | |
struct | Sprite |
Data structure describing a sprite. More... | |
Typedefs | |
typedef void * | AllocatorProc(size_t size) |
Functions | |
void * | SimpleSpriteAlloc (size_t size) |
Sprite allocator simply using malloc. | |
void * | GetRawSprite (SpriteID sprite, SpriteType type, AllocatorProc *allocator=nullptr, SpriteEncoder *encoder=nullptr) |
Reads a sprite (from disk or sprite cache). More... | |
bool | SpriteExists (SpriteID sprite) |
SpriteType | GetSpriteType (SpriteID sprite) |
Get the sprite type of a given sprite. More... | |
SpriteFile * | GetOriginFile (SpriteID sprite) |
Get the SpriteFile of a given sprite. More... | |
uint32 | GetSpriteLocalID (SpriteID sprite) |
Get the GRF-local sprite id of a given sprite. More... | |
uint | GetSpriteCountForFile (const std::string &filename, SpriteID begin, SpriteID end) |
Count the sprites which originate from a specific file in a range of SpriteIDs. More... | |
uint | GetMaxSpriteID () |
Get a reasonable (upper bound) estimate of the maximum SpriteID used in OpenTTD; there will be no sprites with a higher SpriteID, although there might be up to roughly a thousand unused SpriteIDs below this number. More... | |
static const Sprite * | GetSprite (SpriteID sprite, SpriteType type) |
static const byte * | GetNonSprite (SpriteID sprite, SpriteType type) |
void | GfxInitSpriteMem () |
void | GfxClearSpriteCache () |
Remove all encoded sprites from the sprite cache without discarding sprite location information. | |
void | IncreaseSpriteLRU () |
SpriteFile & | OpenCachedSpriteFile (const std::string &filename, Subdirectory subdir, bool palette_remap) |
Open/get the SpriteFile that is cached for use in the sprite cache. More... | |
void | ReadGRFSpriteOffsets (SpriteFile &file) |
Parse the sprite section of GRFs. More... | |
size_t | GetGRFSpriteOffset (uint32 id) |
Get the file offset for a specific sprite in the sprite section of a GRF. More... | |
bool | LoadNextSprite (int load_index, SpriteFile &file, uint file_sprite_id) |
Load a real or recolour sprite. More... | |
bool | SkipSpriteData (SpriteFile &file, byte type, uint16 num) |
Skip the given amount of sprite graphics data. More... | |
void | DupSprite (SpriteID old_spr, SpriteID new_spr) |
Variables | |
uint | _sprite_cache_size |
Functions to cache sprites in memory.
Definition in file spritecache.h.
size_t GetGRFSpriteOffset | ( | uint32 | id | ) |
Get the file offset for a specific sprite in the sprite section of a GRF.
id | ID of the sprite to look up. |
Definition at line 541 of file spritecache.cpp.
References _grf_sprite_offsets.
Referenced by LoadNextSprite().
uint GetMaxSpriteID | ( | ) |
Get a reasonable (upper bound) estimate of the maximum SpriteID used in OpenTTD; there will be no sprites with a higher SpriteID, although there might be up to roughly a thousand unused SpriteIDs below this number.
Definition at line 220 of file spritecache.cpp.
Referenced by SpriteAlignerWindow::OnClick(), SpriteAlignerWindow::OnQueryTextFinished(), and UpdateCursorSize().
SpriteFile* GetOriginFile | ( | SpriteID | sprite | ) |
Get the SpriteFile of a given sprite.
sprite | The sprite to look at. |
Definition at line 173 of file spritecache.cpp.
void* GetRawSprite | ( | SpriteID | sprite, |
SpriteType | type, | ||
AllocatorProc * | allocator, | ||
SpriteEncoder * | encoder | ||
) |
Reads a sprite (from disk or sprite cache).
If the sprite is not available or of wrong type, a fallback sprite is returned.
sprite | Sprite to read. |
type | Expected sprite type. |
allocator | Allocator function to use. Set to nullptr to use the usual sprite cache. |
encoder | Sprite encoder to use. Set to nullptr to use the currently active blitter. |
Definition at line 905 of file spritecache.cpp.
Count the sprites which originate from a specific file in a range of SpriteIDs.
file | The loaded SpriteFile. |
begin | First sprite in range. |
end | First sprite not in range. |
Definition at line 197 of file spritecache.cpp.
References GetCachedSpriteFileByName().
uint32 GetSpriteLocalID | ( | SpriteID | sprite | ) |
Get the GRF-local sprite id of a given sprite.
sprite | The sprite to look at. |
Definition at line 184 of file spritecache.cpp.
SpriteType GetSpriteType | ( | SpriteID | sprite | ) |
Get the sprite type of a given sprite.
sprite | The sprite to look at. |
Definition at line 162 of file spritecache.cpp.
Referenced by SpriteAlignerWindow::OnClick(), and SpriteAlignerWindow::OnQueryTextFinished().
bool LoadNextSprite | ( | int | load_index, |
SpriteFile & | file, | ||
uint | file_sprite_id | ||
) |
Load a real or recolour sprite.
load_index | Global sprite index. |
file | GRF to load from. |
file_sprite_id | Sprite number in the GRF. |
container_version | Container version of the GRF. |
Definition at line 583 of file spritecache.cpp.
References SpriteFile::GetContainerVersion(), GetGRFSpriteOffset(), RandomAccessFile::GetPos(), MAX_SPRITES, RandomAccessFile::ReadByte(), RandomAccessFile::ReadDword(), ReadRecolourSprite(), RandomAccessFile::ReadWord(), RandomAccessFile::SkipBytes(), SkipSpriteData(), ST_INVALID, ST_NORMAL, ST_RECOLOUR, and usererror().
Referenced by LoadGrfFile().
SpriteFile& OpenCachedSpriteFile | ( | const std::string & | filename, |
Subdirectory | subdir, | ||
bool | palette_remap | ||
) |
Open/get the SpriteFile that is cached for use in the sprite cache.
filename | Name of the file at the disk. |
subdir | The sub directory to search this file in. |
palette_remap | Whether a palette remap needs to be performed for this file. |
Definition at line 95 of file spritecache.cpp.
References GetCachedSpriteFileByName().
Referenced by LoadGrfFile(), and LoadGrfFileIndexed().
void ReadGRFSpriteOffsets | ( | SpriteFile & | file | ) |
Parse the sprite section of GRFs.
container_version | Container version of the GRF we're currently processing. |
Definition at line 550 of file spritecache.cpp.
References _grf_sprite_offsets, SpriteFile::GetContainerVersion(), RandomAccessFile::GetPos(), RandomAccessFile::ReadDword(), RandomAccessFile::SeekTo(), and RandomAccessFile::SkipBytes().
Referenced by LoadGrfFile(), and LoadGrfFileIndexed().
bool SkipSpriteData | ( | SpriteFile & | file, |
byte | type, | ||
uint16 | num | ||
) |
Skip the given amount of sprite graphics data.
type | the type of sprite (compressed etc) |
num | the amount of sprites to skip |
Definition at line 125 of file spritecache.cpp.
References RandomAccessFile::ReadByte(), and RandomAccessFile::SkipBytes().
Referenced by LoadNextSprite().