[ZB]: Use mem allocator for branding (#781)

Co-authored-by: Roxanne <roxanne@thegamebakers.com>
This commit is contained in:
Louve 2023-02-17 13:43:52 +01:00 committed by GitHub
parent 512b7cb2ae
commit a588dea4b6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 21 deletions

View File

@ -25,27 +25,25 @@ namespace Assets
header->techniqueSet = builder->getIW4OfApi()->read<Game::MaterialTechniqueSet>(Game::ASSET_TYPE_TECHNIQUE_SET, name);
auto ptr = header->techniqueSet;
if (!ptr)
if (ptr)
{
return;
}
while (ptr->remappedTechniqueSet && ptr->remappedTechniqueSet != ptr)
{
ptr = ptr->remappedTechniqueSet;
builder->loadAsset(Game::ASSET_TYPE_TECHNIQUE_SET, ptr, false);
for (size_t i = 0; i < Game::TECHNIQUE_COUNT; i++)
while (ptr->remappedTechniqueSet && ptr->remappedTechniqueSet != ptr)
{
const auto technique = ptr->techniques[i];
if (technique)
ptr = ptr->remappedTechniqueSet;
builder->loadAsset(Game::ASSET_TYPE_TECHNIQUE_SET, ptr, false);
for (size_t i = 0; i < Game::TECHNIQUE_COUNT; i++)
{
for (size_t j = 0; j < technique->passCount; j++)
const auto technique = ptr->techniques[i];
if (technique)
{
const auto pass = &technique->passArray[j];
builder->loadAsset(Game::ASSET_TYPE_VERTEXDECL, pass->vertexDecl, true);
builder->loadAsset(Game::ASSET_TYPE_PIXELSHADER, pass->pixelShader, true);
builder->loadAsset(Game::ASSET_TYPE_VERTEXSHADER, pass->vertexShader, true);
for (size_t j = 0; j < technique->passCount; j++)
{
const auto pass = &technique->passArray[j];
builder->loadAsset(Game::ASSET_TYPE_VERTEXDECL, pass->vertexDecl, true);
builder->loadAsset(Game::ASSET_TYPE_PIXELSHADER, pass->pixelShader, true);
builder->loadAsset(Game::ASSET_TYPE_VERTEXSHADER, pass->vertexShader, true);
}
}
}
}

View File

@ -535,13 +535,12 @@ namespace Components
// Add branding asset
void ZoneBuilder::Zone::addBranding()
{
static std::string zoneBranding;
const auto now = std::chrono::system_clock::now();
zoneBranding = std::format("Built using the IW4x ZoneBuilder! {:%d-%m-%Y %H:%M:%OS}", now);
auto zoneBranding = std::format("Built using the IW4x ZoneBuilder! {:%d-%m-%Y %H:%M:%OS}", now);
auto brandingLen = zoneBranding.size(); // + 1 is added by the save code
this->branding = {this->zoneName.data(), 0, static_cast<int>(brandingLen), zoneBranding.data()};
this->branding = {this->zoneName.data(), 0, static_cast<int>(brandingLen), getAllocator()->duplicateString(zoneBranding)};
if (this->findAsset(Game::ASSET_TYPE_RAWFILE, this->branding.name) != -1)
{