mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-04-21 00:25:44 +00:00
Make sure scriptstring arrays are being reallocated when they are reusable so if it is being referenced again the scriptstring indices are the ones of the zone instead of the asset that originally loaded them
This commit is contained in:
parent
6cca45fc26
commit
3cfcfa0c5d
@ -40,7 +40,12 @@ $TypeVarName(structure.Type)$->$member.Member.Name$$PrintArrayIndices(reference)
|
||||
$\n$
|
||||
|
||||
varScriptString = $TypeVarName(structure.Type)$->$member.Member.Name$$PrintArrayIndices(reference)$;$\n$
|
||||
$if(!member.IsReusable)$
|
||||
LoadScriptStringArray(true, $PrintEvaluation(reference.ArrayPointerCountEvaluation)$);
|
||||
$else$
|
||||
LoadScriptStringArrayRealloc(true, $PrintEvaluation(reference.ArrayPointerCountEvaluation)$);$\n$
|
||||
$TypeVarName(structure.Type)$->$member.Member.Name$$PrintArrayIndices(reference)$ = varScriptString;
|
||||
$endif$
|
||||
|
||||
%>
|
||||
|
||||
@ -70,6 +75,11 @@ if($TypeVarName(structure.Type)$->$member.Member.Name$$PrintArrayIndices(referen
|
||||
else
|
||||
{
|
||||
$TypeVarName(structure.Type)$->$member.Member.Name$$PrintArrayIndices(reference)$ = m_stream->ConvertOffsetToPointer($TypeVarName(structure.Type)$->$member.Member.Name$$PrintArrayIndices(reference)$);
|
||||
$if(member.IsScriptString)$
|
||||
varScriptString = $TypeVarName(structure.Type)$->$member.Member.Name$$PrintArrayIndices(reference)$;
|
||||
LoadScriptStringArrayRealloc(false, $PrintEvaluation(reference.ArrayPointerCountEvaluation)$);
|
||||
$TypeVarName(structure.Type)$->$member.Member.Name$$PrintArrayIndices(reference)$ = varScriptString;
|
||||
$endif$
|
||||
}$\\$
|
||||
$endif$
|
||||
>>
|
||||
|
@ -52,10 +52,30 @@ void AssetLoader::LoadScriptStringArray(const bool atStreamStart, const size_t c
|
||||
if (atStreamStart)
|
||||
m_stream->Load<scr_string_t>(varScriptString, count);
|
||||
|
||||
auto* ptr = varScriptString;
|
||||
for (size_t index = 0; index < count; index++)
|
||||
{
|
||||
*varScriptString = UseScriptString(*varScriptString);
|
||||
varScriptString++;
|
||||
*ptr = UseScriptString(*ptr);
|
||||
ptr++;
|
||||
}
|
||||
}
|
||||
|
||||
void AssetLoader::LoadScriptStringArrayRealloc(const bool atStreamStart, const size_t count)
|
||||
{
|
||||
assert(varScriptString != nullptr);
|
||||
|
||||
if (atStreamStart)
|
||||
m_stream->Load<scr_string_t>(varScriptString, count);
|
||||
|
||||
auto* scriptStringsNew = static_cast<scr_string_t*>(m_zone->GetMemory()->Alloc(sizeof scr_string_t * count));
|
||||
memcpy_s(scriptStringsNew, sizeof scr_string_t * count, varScriptString, sizeof scr_string_t * count);
|
||||
varScriptString = scriptStringsNew;
|
||||
|
||||
auto* ptr = varScriptString;
|
||||
for (size_t index = 0; index < count; index++)
|
||||
{
|
||||
*ptr = UseScriptString(*ptr);
|
||||
ptr++;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -22,6 +22,7 @@ protected:
|
||||
|
||||
scr_string_t UseScriptString(scr_string_t scrString);
|
||||
void LoadScriptStringArray(bool atStreamStart, size_t count);
|
||||
void LoadScriptStringArrayRealloc(bool atStreamStart, size_t count);
|
||||
|
||||
XAssetInfoGeneric* LinkAsset(std::string name, void* asset);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user