mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-12-27 12:31:50 +00:00
chore: do not make ignoring reference dependencies required
* when dependency comes from global asset pools
This commit is contained in:
@@ -104,7 +104,7 @@ XAssetInfoGeneric* AssetCreationContext::LoadDefaultAssetDependency(const asset_
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
XAssetInfoGeneric* AssetCreationContext::LoadDependencyGeneric(const asset_type_t assetType, const std::string& assetName)
|
XAssetInfoGeneric* AssetCreationContext::LoadDependencyGeneric(const asset_type_t assetType, const std::string& assetName, bool required)
|
||||||
{
|
{
|
||||||
auto* alreadyLoadedAsset = m_zone.m_pools->GetAssetOrAssetReference(assetType, assetName);
|
auto* alreadyLoadedAsset = m_zone.m_pools->GetAssetOrAssetReference(assetType, assetName);
|
||||||
if (alreadyLoadedAsset)
|
if (alreadyLoadedAsset)
|
||||||
@@ -131,7 +131,7 @@ XAssetInfoGeneric* AssetCreationContext::LoadDependencyGeneric(const asset_type_
|
|||||||
|
|
||||||
con::error("Could not load asset \"{}\" of type \"{}\"", assetName, *m_zone.m_pools->GetAssetTypeName(assetType));
|
con::error("Could not load asset \"{}\" of type \"{}\"", assetName, *m_zone.m_pools->GetAssetTypeName(assetType));
|
||||||
}
|
}
|
||||||
else
|
else if (required)
|
||||||
{
|
{
|
||||||
con::error("Missing asset \"{}\" of type \"{}\"", assetName, *m_zone.m_pools->GetAssetTypeName(assetType));
|
con::error("Missing asset \"{}\" of type \"{}\"", assetName, *m_zone.m_pools->GetAssetTypeName(assetType));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ public:
|
|||||||
return static_cast<XAssetInfo<typename AssetType::Type>*>(LoadDependencyGeneric(AssetType::EnumEntry, assetName));
|
return static_cast<XAssetInfo<typename AssetType::Type>*>(LoadDependencyGeneric(AssetType::EnumEntry, assetName));
|
||||||
}
|
}
|
||||||
|
|
||||||
XAssetInfoGeneric* LoadDependencyGeneric(asset_type_t assetType, const std::string& assetName);
|
XAssetInfoGeneric* LoadDependencyGeneric(asset_type_t assetType, const std::string& assetName, bool required = true);
|
||||||
|
|
||||||
template<typename AssetType> IndirectAssetReference LoadIndirectAssetReference(const std::string& assetName)
|
template<typename AssetType> IndirectAssetReference LoadIndirectAssetReference(const std::string& assetName)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -11,19 +11,32 @@ GlobalAssetPoolsAssetStealer::GlobalAssetPoolsAssetStealer(GenericAssetRegistrat
|
|||||||
|
|
||||||
std::optional<XAssetInfoGeneric*> GlobalAssetPoolsAssetStealer::Visit_Dependency(const asset_type_t assetType, const char* assetName)
|
std::optional<XAssetInfoGeneric*> GlobalAssetPoolsAssetStealer::Visit_Dependency(const asset_type_t assetType, const char* assetName)
|
||||||
{
|
{
|
||||||
auto assetNameToLoad = assetName;
|
if (assetName && assetName[0] == ',')
|
||||||
if (assetNameToLoad && assetNameToLoad[0] == ',')
|
|
||||||
assetNameToLoad = &assetNameToLoad[1];
|
|
||||||
|
|
||||||
auto* newDependency = m_context.LoadDependencyGeneric(assetType, assetNameToLoad);
|
|
||||||
if (!newDependency)
|
|
||||||
{
|
{
|
||||||
m_failure = true;
|
/*
|
||||||
return std::nullopt;
|
Try to load the actual asset when the asset from the global asset pools just references one.
|
||||||
|
If that fails, keep the reference to not destroy previous existing behaviour of just being able to use assets from the global pools
|
||||||
|
without ignores.
|
||||||
|
*/
|
||||||
|
auto* nonReferenceAssetName = &assetName[1];
|
||||||
|
|
||||||
|
auto* assetDependency = m_context.LoadDependencyGeneric(assetType, nonReferenceAssetName, false);
|
||||||
|
if (assetDependency)
|
||||||
|
{
|
||||||
|
m_registration.AddDependency(assetDependency);
|
||||||
|
return assetDependency;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m_registration.AddDependency(newDependency);
|
auto* newDependency = m_context.LoadDependencyGeneric(assetType, assetName);
|
||||||
return newDependency;
|
if (newDependency)
|
||||||
|
{
|
||||||
|
m_registration.AddDependency(newDependency);
|
||||||
|
return newDependency;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_failure = true;
|
||||||
|
return std::nullopt;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::optional<scr_string_t> GlobalAssetPoolsAssetStealer::Visit_ScriptString(scr_string_t scriptString)
|
std::optional<scr_string_t> GlobalAssetPoolsAssetStealer::Visit_ScriptString(scr_string_t scriptString)
|
||||||
|
|||||||
Reference in New Issue
Block a user