File diff r2014:c6a34c339dda → r2015:73fac0e1e64b
spritecache.c
Show inline comments
 
@@ -164,49 +164,49 @@ static void* ReadSprite(SpriteID id)
 
			id
 
		);
 
	}
 

	
 
	FioSeekToFile(_sprite_file_pos[id]);
 

	
 
	type = FioReadByte();
 
	if (type == 0xFF) {
 
		byte* dest = AllocSprite(num);
 

	
 
		_sprite_ptr[id] = dest;
 
		FioReadBlock(dest, num);
 

	
 
		return dest;
 
	} else {
 
		uint height = FioReadByte();
 
		uint width  = FioReadWord();
 
		Sprite* sprite;
 
		byte* dest;
 

	
 
		num = (type & 0x02) ? width * height : num - 8;
 
		sprite = AllocSprite(sizeof(*sprite) + num);
 
		_sprite_ptr[id] = sprite;
 
		sprite->info   = type;
 
		sprite->height = (id != 142) ? height : 10;
 
		sprite->height = (id != 142) ? height : 10; // Compensate for a TTD bug
 
		sprite->width  = width;
 
		sprite->x_offs = FioReadWord();
 
		sprite->y_offs = FioReadWord();
 

	
 
		dest = sprite->data;
 
		while (num > 0) {
 
			int8 i = FioReadByte();
 

	
 
			if (i >= 0) {
 
				num -= i;
 
				for (; i > 0; --i) *dest++ = FioReadByte();
 
			} else {
 
				const byte* rel = dest - (((i & 7) << 8) | FioReadByte());
 

	
 
				i = -(i >> 3);
 
				num -= i;
 

	
 
				for (; i > 0; --i) *dest++ = *rel++;
 
			}
 
		}
 

	
 
		return sprite;
 
	}
 
}