@ -162,7 +162,7 @@ bool SpriteExists(SpriteID id)
*/
SpriteType GetSpriteType ( SpriteID sprite )
{
if ( ! SpriteExists ( sprite ) ) return S T_INVALID ;
if ( ! SpriteExists ( sprite ) ) return S priteType: : Invalid ;
return GetSpriteCache ( sprite ) - > type ;
}
@ -461,8 +461,8 @@ static void *ReadSprite(const SpriteCache *sc, SpriteID id, SpriteType sprite_ty
SpriteFile & file = * sc - > file ;
size_t file_pos = sc - > file_pos ;
assert ( sprite_type ! = S T_RECOLOUR ) ;
assert ( IsMapgenSpriteID ( id ) = = ( sprite_type = = S T_MAPGEN ) ) ;
assert ( sprite_type ! = S priteType: : Recolour ) ;
assert ( IsMapgenSpriteID ( id ) = = ( sprite_type = = S priteType: : MapGen ) ) ;
assert ( sc - > type = = sprite_type ) ;
Debug ( sprite , 9 , " Load sprite {} " , id ) ;
@ -472,7 +472,7 @@ static void *ReadSprite(const SpriteCache *sc, SpriteID id, SpriteType sprite_ty
sprite [ ZOOM_LVL_NORMAL ] . type = sprite_type ;
SpriteLoaderGrf sprite_loader ( file . GetContainerVersion ( ) ) ;
if ( sprite_type ! = S T_MAPGEN & & encoder - > Is32BppSupported ( ) ) {
if ( sprite_type ! = S priteType: : MapGen & & encoder - > Is32BppSupported ( ) ) {
/* Try for 32bpp sprites first. */
sprite_avail = sprite_loader . LoadSprite ( sprite , file , file_pos , sprite_type , true , sc - > control_flags ) ;
}
@ -481,12 +481,12 @@ static void *ReadSprite(const SpriteCache *sc, SpriteID id, SpriteType sprite_ty
}
if ( sprite_avail = = 0 ) {
if ( sprite_type = = S T_MAPGEN ) return nullptr ;
if ( sprite_type = = S priteType: : MapGen ) return nullptr ;
if ( id = = SPR_IMG_QUERY ) usererror ( " Okay... something went horribly wrong. I couldn't load the fallback sprite. What should I do? " ) ;
return ( void * ) GetRawSprite ( SPR_IMG_QUERY , S T_NORMAL , allocator , encoder ) ;
return ( void * ) GetRawSprite ( SPR_IMG_QUERY , S priteType: : Normal , allocator , encoder ) ;
}
if ( sprite_type = = S T_MAPGEN ) {
if ( sprite_type = = S priteType: : MapGen ) {
/* Ugly hack to work around the problem that the old landscape
* generator assumes that those sprites are stored uncompressed in
* the memory , and they are only read directly by the code , never
@ -516,10 +516,10 @@ static void *ReadSprite(const SpriteCache *sc, SpriteID id, SpriteType sprite_ty
if ( ! ResizeSprites ( sprite , sprite_avail , encoder ) ) {
if ( id = = SPR_IMG_QUERY ) usererror ( " Okay... something went horribly wrong. I couldn't resize the fallback sprite. What should I do? " ) ;
return ( void * ) GetRawSprite ( SPR_IMG_QUERY , S T_NORMAL , allocator , encoder ) ;
return ( void * ) GetRawSprite ( SPR_IMG_QUERY , S priteType: : Normal , allocator , encoder ) ;
}
if ( sprite - > type = = S T_FONT & & ZOOM_LVL_GUI ! = ZOOM_LVL_NORMAL ) {
if ( sprite - > type = = S priteType: : Font & & ZOOM_LVL_GUI ! = ZOOM_LVL_NORMAL ) {
/* Make ZOOM_LVL_NORMAL be ZOOM_LVL_GUI */
sprite [ ZOOM_LVL_NORMAL ] . width = sprite [ ZOOM_LVL_GUI ] . width ;
sprite [ ZOOM_LVL_NORMAL ] . height = sprite [ ZOOM_LVL_GUI ] . height ;
@ -629,7 +629,7 @@ bool LoadNextSprite(int load_index, SpriteFile &file, uint file_sprite_id)
file . ReadByte ( ) ;
return false ;
}
type = S T_RECOLOUR ;
type = S priteType: : Recolour ;
data = ReadRecolourSprite ( file , num ) ;
} else if ( file . GetContainerVersion ( ) > = 2 & & grf_type = = 0xFD ) {
if ( num ! = 4 ) {
@ -645,15 +645,15 @@ bool LoadNextSprite(int load_index, SpriteFile &file, uint file_sprite_id)
} else {
file_pos = SIZE_MAX ;
}
type = S T_NORMAL ;
type = S priteType: : Normal ;
} else {
file . SkipBytes ( 7 ) ;
type = SkipSpriteData ( file , grf_type , num - 8 ) ? ST_NORMAL : ST_INVALID ;
type = SkipSpriteData ( file , grf_type , num - 8 ) ? SpriteType : : Normal : SpriteType : : Invalid ;
/* Inline sprites are not supported for container version >= 2. */
if ( file . GetContainerVersion ( ) > = 2 ) return false ;
}
if ( type = = S T_INVALID ) return false ;
if ( type = = S priteType: : Invalid ) return false ;
if ( load_index > = MAX_SPRITES ) {
usererror ( " Tried to load too many sprites (#%d; max %d) " , load_index , MAX_SPRITES ) ;
@ -662,8 +662,8 @@ bool LoadNextSprite(int load_index, SpriteFile &file, uint file_sprite_id)
bool is_mapgen = IsMapgenSpriteID ( load_index ) ;
if ( is_mapgen ) {
if ( type ! = S T_NORMAL ) usererror ( " Uhm, would you be so kind not to load a NewGRF that changes the type of the map generator sprites? " ) ;
type = S T_MAPGEN ;
if ( type ! = S priteType: : Normal ) usererror ( " Uhm, would you be so kind not to load a NewGRF that changes the type of the map generator sprites? " ) ;
type = S priteType: : MapGen ;
}
SpriteCache * sc = AllocateSpriteCache ( load_index ) ;
@ -828,7 +828,7 @@ static void DeleteEntryFromSpriteCache()
cur_lru = 0xffff ;
for ( SpriteID i = 0 ; i ! = _spritecache_items ; i + + ) {
SpriteCache * sc = GetSpriteCache ( i ) ;
if ( sc - > type ! = S T_RECOLOUR & & sc - > ptr ! = nullptr & & sc - > lru < cur_lru ) {
if ( sc - > type ! = S priteType: : Recolour & & sc - > ptr ! = nullptr & & sc - > lru < cur_lru ) {
cur_lru = sc - > lru ;
best = i ;
}
@ -888,7 +888,7 @@ void *SimpleSpriteAlloc(size_t size)
/**
* Handles the case when a sprite of different type is requested than is present in the SpriteCache .
* For S T_FONT sprites , it is normal . In other cases , default sprite is loaded instead .
* For S priteType: : Font sprites , it is normal . In other cases , default sprite is loaded instead .
* @ param sprite ID of loaded sprite
* @ param requested requested sprite type
* @ param sc the currently known sprite cache for the requested sprite
@ -898,33 +898,33 @@ void *SimpleSpriteAlloc(size_t size)
static void * HandleInvalidSpriteRequest ( SpriteID sprite , SpriteType requested , SpriteCache * sc , AllocatorProc * allocator )
{
static const char * const sprite_types [ ] = {
" normal " , // S T_NORMAL
" map generator " , // S T_MAPGEN
" character " , // S T_FONT
" recolour " , // S T_RECOLOUR
" normal " , // S priteType::Normal
" map generator " , // S priteType::MapGen
" character " , // S priteType::Font
" recolour " , // S priteType::Recolour
} ;
SpriteType available = sc - > type ;
if ( requested = = S T_FONT & & available = = ST_NORMAL ) {
if ( sc - > ptr = = nullptr ) sc - > type = S T_FONT ;
if ( requested = = S priteType: : Font & & available = = SpriteType : : Normal ) {
if ( sc - > ptr = = nullptr ) sc - > type = S priteType: : Font ;
return GetRawSprite ( sprite , sc - > type , allocator ) ;
}
byte warning_level = sc - > warned ? 6 : 0 ;
sc - > warned = true ;
Debug ( sprite , warning_level , " Tried to load {} sprite #{} as a {} sprite. Probable cause: NewGRF interference " , sprite_types [ available ] , sprite , sprite_types [ requested ] ) ;
Debug ( sprite , warning_level , " Tried to load {} sprite #{} as a {} sprite. Probable cause: NewGRF interference " , sprite_types [ static_cast < byte > ( available ) ] , sprite , sprite_types [ static_cast < byte > ( requested ) ] ) ;
switch ( requested ) {
case ST_NORMAL :
case SpriteType : : Normal :
if ( sprite = = SPR_IMG_QUERY ) usererror ( " Uhm, would you be so kind not to load a NewGRF that makes the 'query' sprite a non-normal sprite? " ) ;
FALLTHROUGH ;
case ST_FONT :
return GetRawSprite ( SPR_IMG_QUERY , S T_NORMAL , allocator ) ;
case ST_RECOLOUR :
case SpriteType : : Font :
return GetRawSprite ( SPR_IMG_QUERY , S priteType: : Normal , allocator ) ;
case SpriteType : : Recolour :
if ( sprite = = PALETTE_TO_DARK_BLUE ) usererror ( " Uhm, would you be so kind not to load a NewGRF that makes the 'PALETTE_TO_DARK_BLUE' sprite a non-remap sprite? " ) ;
return GetRawSprite ( PALETTE_TO_DARK_BLUE , S T_RECOLOUR , allocator ) ;
case ST_MAPGEN :
/* this shouldn't happen, overriding of S T_MAPGEN sprites is checked in LoadNextSprite()
return GetRawSprite ( PALETTE_TO_DARK_BLUE , S priteType: : Recolour , allocator ) ;
case SpriteType : : MapGen :
/* this shouldn't happen, overriding of S priteType::MapGen sprites is checked in LoadNextSprite()
* ( the only case the check fails is when these sprites weren ' t even loaded . . . ) */
default :
NOT_REACHED ( ) ;
@ -942,8 +942,8 @@ static void *HandleInvalidSpriteRequest(SpriteID sprite, SpriteType requested, S
*/
void * GetRawSprite ( SpriteID sprite , SpriteType type , AllocatorProc * allocator , SpriteEncoder * encoder )
{
assert ( type ! = S T_MAPGEN | | IsMapgenSpriteID ( sprite ) ) ;
assert ( type < S T_INVALID ) ;
assert ( type ! = S priteType: : MapGen | | IsMapgenSpriteID ( sprite ) ) ;
assert ( type < S priteType: : Invalid ) ;
if ( ! SpriteExists ( sprite ) ) {
Debug ( sprite , 1 , " Tried to load non-existing sprite #{}. Probable cause: Wrong/missing NewGRFs " , sprite ) ;
@ -1042,7 +1042,7 @@ void GfxClearSpriteCache()
/* Clear sprite ptr for all cached items */
for ( uint i = 0 ; i ! = _spritecache_items ; i + + ) {
SpriteCache * sc = GetSpriteCache ( i ) ;
if ( sc - > type ! = S T_RECOLOUR & & sc - > ptr ! = nullptr ) DeleteEntryFromSpriteCache ( i ) ;
if ( sc - > type ! = S priteType: : Recolour & & sc - > ptr ! = nullptr ) DeleteEntryFromSpriteCache ( i ) ;
}
VideoDriver : : GetInstance ( ) - > ClearSystemSprites ( ) ;