Merge pull request #615 from diamante0018/develop
[RawFiles]: Actually fix parse code
This commit is contained in:
commit
d7afbd72e1
@ -18,16 +18,16 @@ namespace Assets
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto compressed_size = compressBound(rawFile.getBuffer().size());
|
|
||||||
|
|
||||||
asset->name = builder->getAllocator()->duplicateString(name);
|
asset->name = builder->getAllocator()->duplicateString(name);
|
||||||
asset->len = static_cast<int>(rawFile.getBuffer().size());
|
asset->len = static_cast<int>(rawFile.getBuffer().size());
|
||||||
|
|
||||||
if (asset->len < static_cast<int>(compressed_size))
|
const auto compressedData = Utils::Compression::ZLib::Compress(rawFile.getBuffer());
|
||||||
|
// Only save the compressed buffer if we gained space
|
||||||
|
if (compressedData.size() < rawFile.getBuffer().size())
|
||||||
{
|
{
|
||||||
asset->buffer = builder->getAllocator()->allocateArray<char>(compressed_size);
|
asset->buffer = builder->getAllocator()->duplicateString(compressedData);
|
||||||
compress2((Bytef*)(asset->buffer), &compressed_size, (const Bytef*)(rawFile.getBuffer().data()), rawFile.getBuffer().size(), Z_BEST_COMPRESSION);
|
std::memcpy(const_cast<char*>(asset->buffer), compressedData.data(), compressedData.size());
|
||||||
asset->compressedLen = static_cast<int>(compressed_size);
|
asset->compressedLen = static_cast<int>(compressedData.size());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -36,8 +36,6 @@ namespace Assets
|
|||||||
asset->compressedLen = 0;
|
asset->compressedLen = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
asset->len = static_cast<int>(rawFile.getBuffer().size());
|
|
||||||
|
|
||||||
header->rawfile = asset;
|
header->rawfile = asset;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user