2
0
mirror of https://github.com/Laupetin/OpenAssetTools.git synced 2026-01-13 20:21:48 +00:00

fix: do not override properties of foreign zones

This commit is contained in:
Jan Laupetin
2025-12-25 15:29:32 +01:00
parent 2442d7160c
commit ba39e3f4d9
5 changed files with 32 additions and 17 deletions

View File

@@ -10,6 +10,14 @@ AssetWriter::AssetWriter(XAssetInfoGeneric* asset, const Zone& zone, IZoneOutput
{
}
const char* AssetWriter::NonReferenceAssetName(const char* assetName)
{
if (assetName && assetName[0] == ',')
return &assetName[1];
return assetName;
}
scr_string_t AssetWriter::UseScriptString(const scr_string_t scrString) const
{
assert(scrString < m_asset->m_zone->m_script_strings.Count());
@@ -17,9 +25,7 @@ scr_string_t AssetWriter::UseScriptString(const scr_string_t scrString) const
if (m_asset->m_zone == &m_zone)
return scrString;
// This swap should have already been performed in GlobalAssetPoolsLoader
assert(false);
// The asset comes from a different zone, we need to translate it
const auto strValue = m_asset->m_zone->m_script_strings.CValue(scrString);
return m_zone.m_script_strings.GetScriptString(strValue);
}

View File

@@ -11,7 +11,8 @@ class AssetWriter : public ContentWriterBase
protected:
AssetWriter(XAssetInfoGeneric* asset, const Zone& zone, IZoneOutputStream& stream);
_NODISCARD scr_string_t UseScriptString(scr_string_t scrString) const;
[[nodiscard]] static const char* NonReferenceAssetName(const char* assetName);
[[nodiscard]] scr_string_t UseScriptString(scr_string_t scrString) const;
void WriteScriptStringArray(bool atStreamStart, size_t count);
XAssetInfoGeneric* m_asset;