Use asset identified by name and type when writing asset dependency to make sure that the pointer always matches one that would have been written to the zone already even when using an asset from another loaded zone

This commit is contained in:
Jan 2021-03-21 21:29:02 +01:00
parent a2ef445455
commit d99eb0ab24
2 changed files with 6 additions and 2 deletions

View File

@ -865,9 +865,13 @@ class ZoneWriteTemplate::Internal final : BaseTemplate
m_intendation++; m_intendation++;
LINE("assert(pAsset != nullptr);") LINE("assert(pAsset != nullptr);")
LINE("assert(m_asset != nullptr);")
LINE("assert(m_asset->m_ptr != nullptr);")
LINE("") LINE("")
LINE(MakeTypePtrVarName(m_env.m_asset->m_definition) << " = pAsset;") LINE("auto* zoneAsset = static_cast<"<<m_env.m_asset->m_definition->GetFullName()<<"*>(m_asset->m_ptr);")
LINE(MakeTypePtrVarName(m_env.m_asset->m_definition) << " = &zoneAsset;")
LINE("WritePtr_" << MakeSafeTypeName(m_env.m_asset->m_definition) << "(false);") LINE("WritePtr_" << MakeSafeTypeName(m_env.m_asset->m_definition) << "(false);")
LINE("*pAsset = zoneAsset;")
m_intendation--; m_intendation--;
LINE("}") LINE("}")

View File

@ -8,9 +8,9 @@
class AssetWriter : public ContentWriterBase class AssetWriter : public ContentWriterBase
{ {
protected:
XAssetInfoGeneric* m_asset; XAssetInfoGeneric* m_asset;
protected:
scr_string_t* varScriptString; scr_string_t* varScriptString;
AssetWriter(XAssetInfoGeneric* asset, Zone* zone, IZoneOutputStream* stream); AssetWriter(XAssetInfoGeneric* asset, Zone* zone, IZoneOutputStream* stream);