2
0
mirror of https://github.com/Laupetin/OpenAssetTools.git synced 2025-09-24 09:16:39 +00:00

ZoneLoading: Properly link assets as dependencies instead of only saving the name of the dependency

This commit is contained in:
Jan
2020-02-18 13:16:39 +01:00
parent 246d74992c
commit 992e9cea30
16 changed files with 159 additions and 61 deletions

View File

@@ -12,11 +12,13 @@ class AssetPoolDynamic final : public AssetPool<T>
using AssetPool<T>::m_asset_lookup;
std::vector<XAssetInfo<T>*> m_assets;
asset_type_t m_type;
public:
explicit AssetPoolDynamic(const int priority)
AssetPoolDynamic(const int priority, const asset_type_t type)
{
GlobalAssetPool<T>::LinkAssetPool(this, priority);
m_type = type;
}
AssetPoolDynamic(AssetPoolDynamic<T>&) = delete;
@@ -30,7 +32,7 @@ public:
for(auto* entry : m_assets)
{
delete entry->m_asset;
delete entry->m_ptr;
delete entry;
}
@@ -38,16 +40,17 @@ public:
m_asset_lookup.clear();
}
XAssetInfo<T>* AddAsset(std::string name, T* asset, std::vector<std::string>& scriptStrings, std::vector<XAssetDependency>& dependencies) override
XAssetInfo<T>* AddAsset(std::string name, T* asset, std::vector<std::string>& scriptStrings, std::vector<XAssetInfoGeneric*>& dependencies) override
{
auto* newInfo = new XAssetInfo<T>();
newInfo->m_type = m_type;
newInfo->m_name = std::move(name);
newInfo->m_script_strings = std::move(scriptStrings);
newInfo->m_dependencies = std::move(dependencies);
T* newAsset = new T();
memcpy(newAsset, asset, sizeof(T));
newInfo->m_asset = newAsset;
newInfo->m_ptr = newAsset;
m_assets.push_back(newInfo);
m_asset_lookup[newInfo->m_name] = newInfo;