mirror of https://github.com/OpenTTD/OpenTTD
(svn r14191) -Codechange: unify the code to skip sprite payload (i.e. not the header).
-Fix: sprite payload skipping wouldn't skip enough bytes in a very small subset of compressed sprites.release/0.7
parent
e06c21426e
commit
d3d34d2aac
|
@ -5935,23 +5935,7 @@ void LoadNewGRFFile(GRFConfig *config, uint file_index, GrfLoadingStage stage)
|
||||||
}
|
}
|
||||||
|
|
||||||
FioSkipBytes(7);
|
FioSkipBytes(7);
|
||||||
num -= 8;
|
SkipSpriteData(type, num - 8);
|
||||||
|
|
||||||
if (type & 2) {
|
|
||||||
FioSkipBytes(num);
|
|
||||||
} else {
|
|
||||||
while (num > 0) {
|
|
||||||
int8 i = FioReadByte();
|
|
||||||
if (i >= 0) {
|
|
||||||
num -= i;
|
|
||||||
FioSkipBytes(i);
|
|
||||||
} else {
|
|
||||||
i = -(i >> 3);
|
|
||||||
num -= i;
|
|
||||||
FioReadByte();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_skip_sprites > 0) _skip_sprites--;
|
if (_skip_sprites > 0) _skip_sprites--;
|
||||||
|
|
|
@ -56,5 +56,6 @@ struct DrawBuildingsTileStruct {
|
||||||
/** Iterate through all DrawTileSeqStructs in DrawTileSprites. */
|
/** Iterate through all DrawTileSeqStructs in DrawTileSprites. */
|
||||||
#define foreach_draw_tile_seq(idx, list) for (idx = list; ((byte) idx->delta_x) != 0x80; idx++)
|
#define foreach_draw_tile_seq(idx, list) for (idx = list; ((byte) idx->delta_x) != 0x80; idx++)
|
||||||
|
|
||||||
|
void SkipSpriteData(byte type, uint16 num);
|
||||||
|
|
||||||
#endif /* SPRITE_H */
|
#endif /* SPRITE_H */
|
||||||
|
|
|
@ -72,6 +72,35 @@ static int _compact_cache_counter;
|
||||||
|
|
||||||
static void CompactSpriteCache();
|
static void CompactSpriteCache();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Skip the given amount of sprite graphics data.
|
||||||
|
* @param type the type of sprite (compressed etc)
|
||||||
|
* @param num the amount of sprites to skip
|
||||||
|
*/
|
||||||
|
void SkipSpriteData(byte type, uint16 num)
|
||||||
|
{
|
||||||
|
if (type & 2) {
|
||||||
|
FioSkipBytes(num);
|
||||||
|
} else {
|
||||||
|
while (num > 0) {
|
||||||
|
int8 i = FioReadByte();
|
||||||
|
if (i >= 0) {
|
||||||
|
i = (i == 0) ? 0x80 : i;
|
||||||
|
num -= i;
|
||||||
|
FioSkipBytes(i);
|
||||||
|
} else {
|
||||||
|
i = -(i >> 3);
|
||||||
|
num -= i;
|
||||||
|
FioReadByte();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Read the sprite header data and then skip the real payload.
|
||||||
|
* @return true if the sprite is a pseudo sprite.
|
||||||
|
*/
|
||||||
static bool ReadSpriteHeaderSkipData()
|
static bool ReadSpriteHeaderSkipData()
|
||||||
{
|
{
|
||||||
uint16 num = FioReadWord();
|
uint16 num = FioReadWord();
|
||||||
|
@ -88,24 +117,7 @@ static bool ReadSpriteHeaderSkipData()
|
||||||
}
|
}
|
||||||
|
|
||||||
FioSkipBytes(7);
|
FioSkipBytes(7);
|
||||||
num -= 8;
|
SkipSpriteData(type, num - 8);
|
||||||
if (num == 0) return true;
|
|
||||||
|
|
||||||
if (type & 2) {
|
|
||||||
FioSkipBytes(num);
|
|
||||||
} else {
|
|
||||||
while (num > 0) {
|
|
||||||
int8 i = FioReadByte();
|
|
||||||
if (i >= 0) {
|
|
||||||
num -= i;
|
|
||||||
FioSkipBytes(i);
|
|
||||||
} else {
|
|
||||||
i = -(i >> 3);
|
|
||||||
num -= i;
|
|
||||||
FioReadByte();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue