mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-06-11 07:18:11 -05:00
ZoneLoading: Properly link assets as dependencies instead of only saving the name of the dependency
This commit is contained in:
@ -10,22 +10,18 @@ AssetLoader::AssetLoader(const asset_type_t assetType, IZoneScriptStringProvider
|
||||
varScriptString = nullptr;
|
||||
}
|
||||
|
||||
void AssetLoader::AddDependency(const asset_type_t type, std::string& name)
|
||||
void AssetLoader::AddDependency(XAssetInfoGeneric* assetInfo)
|
||||
{
|
||||
for(auto& existingDependency : m_dependencies)
|
||||
if (assetInfo == nullptr)
|
||||
return;
|
||||
|
||||
const auto existingEntry = std::find(m_dependencies.begin(), m_dependencies.end(), assetInfo);
|
||||
if(existingEntry != m_dependencies.end())
|
||||
{
|
||||
if(existingDependency.m_type == type
|
||||
&& existingDependency.m_name == name)
|
||||
{
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
XAssetDependency dependency;
|
||||
dependency.m_type = type;
|
||||
dependency.m_name = name;
|
||||
|
||||
m_dependencies.push_back(dependency);
|
||||
m_dependencies.push_back(assetInfo);
|
||||
}
|
||||
|
||||
scr_string_t AssetLoader::UseScriptString(const scr_string_t scrString)
|
||||
@ -63,7 +59,12 @@ void AssetLoader::LoadScriptStringArray(const bool atStreamStart, const size_t c
|
||||
}
|
||||
}
|
||||
|
||||
void* AssetLoader::LinkAsset(std::string name, void* asset)
|
||||
XAssetInfoGeneric* AssetLoader::LinkAsset(std::string name, void* asset)
|
||||
{
|
||||
return m_zone->GetPools()->AddAsset(m_asset_type, std::move(name), asset, m_used_script_strings, m_dependencies);
|
||||
}
|
||||
return m_zone->GetPools()->AddAsset(m_asset_type, std::move(name), asset, m_used_script_strings, m_dependencies);;
|
||||
}
|
||||
|
||||
XAssetInfoGeneric* AssetLoader::GetAssetInfo(std::string name) const
|
||||
{
|
||||
return m_zone->GetPools()->GetAsset(m_asset_type, std::move(name));
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
#include "Pool/XAssetInfo.h"
|
||||
#include "ContentLoader.h"
|
||||
#include "IZoneScriptStringProvider.h"
|
||||
#include "Zone/XAssetDependency.h"
|
||||
|
||||
class AssetLoader : public ContentLoader
|
||||
{
|
||||
@ -9,7 +9,7 @@ class AssetLoader : public ContentLoader
|
||||
|
||||
std::vector<std::string> m_used_script_strings;
|
||||
|
||||
std::vector<XAssetDependency> m_dependencies;
|
||||
std::vector<XAssetInfoGeneric*> m_dependencies;
|
||||
|
||||
protected:
|
||||
IZoneScriptStringProvider* m_script_string_provider;
|
||||
@ -18,10 +18,12 @@ protected:
|
||||
|
||||
AssetLoader(asset_type_t assetType, IZoneScriptStringProvider* scriptStringProvider, Zone* zone, IZoneInputStream* stream);
|
||||
|
||||
void AddDependency(asset_type_t type, std::string& name);
|
||||
void AddDependency(XAssetInfoGeneric* assetInfo);
|
||||
|
||||
scr_string_t UseScriptString(scr_string_t scrString);
|
||||
void LoadScriptStringArray(bool atStreamStart, size_t count);
|
||||
|
||||
void* LinkAsset(std::string name, void* asset);
|
||||
XAssetInfoGeneric* LinkAsset(std::string name, void* asset);
|
||||
|
||||
XAssetInfoGeneric* GetAssetInfo(std::string name) const;
|
||||
};
|
||||
|
Reference in New Issue
Block a user