diff options
author | peter1138 <peter1138@openttd.org> | 2006-04-16 11:26:23 +0000 |
---|---|---|
committer | peter1138 <peter1138@openttd.org> | 2006-04-16 11:26:23 +0000 |
commit | 4db1144b6d71aaf511a78b45c1536ca90d629f4f (patch) | |
tree | 72812e5738fce554ec0583b1c1cde2685dbabeef /spritecache.c | |
parent | 60d123c0fa896e8367065844364102557103baf6 (diff) | |
download | openttd-4db1144b6d71aaf511a78b45c1536ca90d629f4f.tar.xz |
(svn r4446) - Add function to determine if a Sprite ID exists.
Diffstat (limited to 'spritecache.c')
-rw-r--r-- | spritecache.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/spritecache.c b/spritecache.c index d7357f7f2..555304f77 100644 --- a/spritecache.c +++ b/spritecache.c @@ -71,6 +71,13 @@ static bool ReadSpriteHeaderSkipData(void) 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* ReadSprite(SpriteID id) @@ -80,7 +87,7 @@ static void* ReadSprite(SpriteID id) DEBUG(spritecache, 9) ("load sprite %d", id); - if (_sprite_file_pos[id] == 0 && id != 0) { + if (!SpriteExists(id)) { error( "Tried to load non-existing sprite #%d.\n" "Probable cause: Wrong/missing NewGRFs", |