mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-04-20 16:15:43 +00:00
Add scriptstrings from loaded zones to newly linked zone
This commit is contained in:
parent
2a6d7c84c2
commit
5443ed4261
@ -86,6 +86,11 @@ XAssetInfoGeneric* AssetLoadingManager::LoadAssetDependency(const asset_type_t a
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// Make sure any used script string is available in the created zone
|
||||
// The replacement of the scr_string_t values will be done upon writing
|
||||
for(auto scrString : existingAsset->m_used_script_strings)
|
||||
m_context.m_zone->m_script_strings.AddScriptString(existingAsset->m_zone->m_script_strings[scrString]);
|
||||
|
||||
AddAsset(existingAsset->m_type, existingAsset->m_name, existingAsset->m_ptr, std::move(dependencies), existingAsset->m_used_script_strings, existingAsset->m_zone);
|
||||
auto* lastDependency = m_last_dependency_loaded;
|
||||
m_last_dependency_loaded = nullptr;
|
||||
|
@ -128,6 +128,7 @@ class ZoneWriteTemplate::Internal final : BaseTemplate
|
||||
{
|
||||
LINE("varScriptString = " << MakeMemberAccess(info, member, modifier) << ";")
|
||||
LINE("WriteScriptStringArray(true, " << MakeEvaluation(modifier.GetArrayPointerCountEvaluation()) << ");")
|
||||
LINE("m_stream->MarkFollowing("<<MakeMemberAccess(info, member, modifier)<<");")
|
||||
}
|
||||
else if (writeType == MemberWriteType::EMBEDDED_ARRAY)
|
||||
{
|
||||
@ -440,9 +441,6 @@ class ZoneWriteTemplate::Internal final : BaseTemplate
|
||||
|
||||
WriteMember_Alloc(info, member, modifier, writeType);
|
||||
|
||||
LINE("")
|
||||
LINE("m_stream->MarkFollowing("<<MakeMemberAccess(info, member, modifier)<<");")
|
||||
|
||||
m_intendation--;
|
||||
LINE("}")
|
||||
}
|
||||
|
@ -24,6 +24,17 @@ scr_string_t ZoneScriptStrings::AddScriptString(const std::string& value)
|
||||
return newScrStringIndex;
|
||||
}
|
||||
|
||||
scr_string_t ZoneScriptStrings::GetScriptString(const std::string& value) const
|
||||
{
|
||||
const auto existingScriptString = m_scr_string_lookup.find(value);
|
||||
if (existingScriptString != m_scr_string_lookup.end())
|
||||
return existingScriptString->second;
|
||||
|
||||
std::ostringstream str;
|
||||
str << "Unable to find script string \"" << value << "\"";
|
||||
throw std::runtime_error(str.str());
|
||||
}
|
||||
|
||||
size_t ZoneScriptStrings::Count() const
|
||||
{
|
||||
return m_scr_strings.size();
|
||||
|
@ -15,6 +15,7 @@ class ZoneScriptStrings
|
||||
|
||||
public:
|
||||
scr_string_t AddScriptString(const std::string& value);
|
||||
scr_string_t GetScriptString(const std::string& value) const;
|
||||
_NODISCARD size_t Count() const;
|
||||
_NODISCARD bool Empty() const;
|
||||
|
||||
|
@ -1,8 +1,6 @@
|
||||
#include "AssetWriter.h"
|
||||
|
||||
#include <cassert>
|
||||
#include <algorithm>
|
||||
#include <iterator>
|
||||
|
||||
AssetWriter::AssetWriter(XAssetInfoGeneric* asset, Zone* zone, IZoneOutputStream* stream)
|
||||
: ContentWriterBase(zone, stream),
|
||||
@ -19,15 +17,7 @@ scr_string_t AssetWriter::UseScriptString(const scr_string_t scrString) const
|
||||
return scrString;
|
||||
|
||||
const auto strValue = m_asset->m_zone->m_script_strings[scrString];
|
||||
const auto scrStringEntry = std::find(m_zone->m_script_strings.begin(), m_zone->m_script_strings.end(), strValue);
|
||||
assert(scrStringEntry != m_zone->m_script_strings.end());
|
||||
|
||||
if (scrStringEntry != m_zone->m_script_strings.end())
|
||||
{
|
||||
return static_cast<scr_string_t>(std::distance(scrStringEntry, m_zone->m_script_strings.begin()));
|
||||
}
|
||||
|
||||
return 0;
|
||||
return m_zone->m_script_strings.GetScriptString(strValue);
|
||||
}
|
||||
|
||||
void AssetWriter::WriteScriptStringArray(const bool atStreamStart, const size_t count)
|
||||
|
Loading…
x
Reference in New Issue
Block a user