1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-30 21:32:42 +00:00

Move outside the condition + fix bug: missing offset

This commit is contained in:
Cédric Mocquillon 2023-03-03 13:29:13 +01:00
parent d73ab7ef6f
commit 78251a2bb1

@ -635,11 +635,11 @@ namespace Bsa
// append chunks
for (const auto& c : fileRecord.texturesChunks)
{
Files::IStreamPtr streamPtr = Files::openConstrainedFileStream(mFilepath, c.offset, c.packedSize);
std::istream* fileStream = streamPtr.get();
if (c.packedSize != 0)
{
Files::IStreamPtr streamPtr = Files::openConstrainedFileStream(mFilepath, c.offset, c.packedSize);
std::istream* fileStream = streamPtr.get();
boost::iostreams::filtering_streambuf<boost::iostreams::input> inputStreamBuf;
inputStreamBuf.push(boost::iostreams::zlib_decompressor());
inputStreamBuf.push(*fileStream);
@ -650,9 +650,7 @@ namespace Bsa
// uncompressed chunk
else
{
Files::IStreamPtr streamPtr = Files::openConstrainedFileStream(mFilepath, c.offset, c.packedSize);
std::istream* fileStream = streamPtr.get();
fileStream->read(memoryStreamPtr->getRawData(), c.size);
fileStream->read(memoryStreamPtr->getRawData() + offset, c.size);
}
offset += c.size;
}