fix: do not reallocate assets for dynamic asset pool

This commit is contained in:
Jan 2024-12-31 12:39:09 +01:00
parent 306ffb730e
commit 80c4a9a2ae
No known key found for this signature in database
GPG Key ID: 44B581F78FF5C57C
2 changed files with 5 additions and 10 deletions

View File

@ -29,11 +29,6 @@ public:
{
GlobalAssetPool<T>::UnlinkAssetPool(this);
for (auto& entry : m_assets)
{
delete entry->Asset();
}
m_assets.clear();
m_asset_lookup.clear();
}
@ -42,10 +37,6 @@ public:
{
const auto normalizedName = XAssetInfo<T>::NormalizeAssetName(xAssetInfo->m_name);
T* newAsset = new T();
memcpy(newAsset, xAssetInfo->Asset(), sizeof(T));
xAssetInfo->m_ptr = newAsset;
auto* pAssetInfo = xAssetInfo.get();
m_asset_lookup[normalizedName] = pAssetInfo;
m_assets.emplace_back(std::move(xAssetInfo));

View File

@ -6,8 +6,12 @@ Zone::Zone(std::string name, const zone_priority_t priority, IGame* game)
m_name(std::move(name)),
m_priority(priority),
m_language(GameLanguage::LANGUAGE_NONE),
m_game(game)
m_game(game),
m_pools(ZoneAssetPools::CreateForGame(game->GetId(), this, priority))
{
const auto assetTypeCount = m_pools->GetAssetTypeCount();
for (auto i = 0; i < assetTypeCount; i++)
m_pools->InitPoolDynamic(i);
}
Zone::~Zone()