[Zone🅱️uilder]: Fix rawfiles (#614)
This commit is contained in:
parent
874a8027af
commit
7778798f17
@ -18,18 +18,21 @@ namespace Assets
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto data = Utils::Compression::ZLib::Compress(rawFile.getBuffer());
|
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());
|
||||||
|
|
||||||
if (data.size() < rawFile.getBuffer().size())
|
if (asset->len < static_cast<int>(compressed_size))
|
||||||
{
|
{
|
||||||
asset->buffer = builder->getAllocator()->duplicateString(data);
|
asset->buffer = builder->getAllocator()->allocateArray<char>(compressed_size);
|
||||||
asset->compressedLen = static_cast<int>(data.size());
|
compress2((Bytef*)(asset->buffer), &compressed_size, (const Bytef*)(rawFile.getBuffer().data()), rawFile.getBuffer().size(), Z_BEST_COMPRESSION);
|
||||||
|
asset->compressedLen = static_cast<int>(compressed_size);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
asset->buffer = builder->getAllocator()->duplicateString(rawFile.getBuffer());
|
asset->buffer = builder->getAllocator()->allocateArray<char>(rawFile.getBuffer().size() + 1);
|
||||||
|
std::memcpy(const_cast<char*>(asset->buffer), rawFile.getBuffer().data(), rawFile.getBuffer().size());
|
||||||
asset->compressedLen = 0;
|
asset->compressedLen = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -518,8 +518,10 @@ namespace Components
|
|||||||
// Add branding asset
|
// Add branding asset
|
||||||
void ZoneBuilder::Zone::addBranding()
|
void ZoneBuilder::Zone::addBranding()
|
||||||
{
|
{
|
||||||
const char* data = "FastFile built using the IW4x ZoneBuilder!";
|
constexpr auto* data = "Built using the IW4x Zone:B:uilder Version 4";
|
||||||
this->branding = { this->zoneName.data(), static_cast<int>(strlen(data)), 0, data };
|
auto dataLen = std::strlen(data) + 1;
|
||||||
|
|
||||||
|
this->branding = { this->zoneName.data(), 0, static_cast<int>(dataLen), data };
|
||||||
|
|
||||||
if (this->findAsset(Game::XAssetType::ASSET_TYPE_RAWFILE, this->branding.name) != -1)
|
if (this->findAsset(Game::XAssetType::ASSET_TYPE_RAWFILE, this->branding.name) != -1)
|
||||||
{
|
{
|
||||||
|
1274
src/Game/Structs.hpp
1274
src/Game/Structs.hpp
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user