mirror of https://github.com/OpenTTD/OpenTTD.git
(svn r4446) - Add function to determine if a Sprite ID exists.
This commit is contained in:
parent
60d123c0fa
commit
4db1144b6d
|
@ -71,6 +71,13 @@ static bool ReadSpriteHeaderSkipData(void)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Check if the given Sprite ID exists */
|
||||||
|
bool SpriteExists(SpriteID id)
|
||||||
|
{
|
||||||
|
/* Special case for Sprite ID zero -- its position is also 0... */
|
||||||
|
return _sprite_file_pos[id] != 0 || id == 0;
|
||||||
|
}
|
||||||
|
|
||||||
static void* AllocSprite(size_t);
|
static void* AllocSprite(size_t);
|
||||||
|
|
||||||
static void* ReadSprite(SpriteID id)
|
static void* ReadSprite(SpriteID id)
|
||||||
|
@ -80,7 +87,7 @@ static void* ReadSprite(SpriteID id)
|
||||||
|
|
||||||
DEBUG(spritecache, 9) ("load sprite %d", id);
|
DEBUG(spritecache, 9) ("load sprite %d", id);
|
||||||
|
|
||||||
if (_sprite_file_pos[id] == 0 && id != 0) {
|
if (!SpriteExists(id)) {
|
||||||
error(
|
error(
|
||||||
"Tried to load non-existing sprite #%d.\n"
|
"Tried to load non-existing sprite #%d.\n"
|
||||||
"Probable cause: Wrong/missing NewGRFs",
|
"Probable cause: Wrong/missing NewGRFs",
|
||||||
|
|
|
@ -13,6 +13,7 @@ typedef struct Sprite {
|
||||||
} Sprite;
|
} Sprite;
|
||||||
|
|
||||||
const void *GetRawSprite(SpriteID sprite);
|
const void *GetRawSprite(SpriteID sprite);
|
||||||
|
bool SpriteExists(SpriteID sprite);
|
||||||
|
|
||||||
static inline const Sprite *GetSprite(SpriteID sprite)
|
static inline const Sprite *GetSprite(SpriteID sprite)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue