mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-07-01 09:07:55 -05:00
chore: fix annoying IW4 cross-type pointer reusage with dirty hack
The game reuses pointer across different types as long as bytes and size matches This leads to non-pointer and pointer types being reused To fix this loading code now handles block memory offsets by nulling and block offsets to non-block data with pointing to raw block data The behaviour only seems to realistically happen on nulled memory
This commit is contained in:
@ -993,7 +993,7 @@ namespace
|
||||
|
||||
if (info && !info->m_has_matching_cross_platform_structure)
|
||||
{
|
||||
LINEF("*{0} = m_stream.ConvertOffsetToPointerLookup(*{0});", MakeTypePtrVarName(def))
|
||||
LINEF("*{0} = m_stream.ConvertOffsetToPointerLookup(*{0}).Expect();", MakeTypePtrVarName(def))
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1659,7 +1659,21 @@ namespace
|
||||
|
||||
if (ShouldAllocOutOfBlock(*member, loadType))
|
||||
{
|
||||
LINEF("{0} = m_stream.ConvertOffsetToPointerLookup({0});", MakeMemberAccess(info, member, modifier))
|
||||
LINE_STARTF("{0} = m_stream.ConvertOffsetToPointerLookup({0})", MakeMemberAccess(info, member, modifier))
|
||||
if (loadType == MemberLoadType::POINTER_ARRAY)
|
||||
{
|
||||
LINE_MIDDLEF(".OrNulled({0}uz * ({1}), sizeof({2}{3}) * ({1}), m_memory)",
|
||||
member->m_member->m_type_declaration->GetSize(),
|
||||
MakeEvaluation(modifier.GetPointerArrayCountEvaluation()),
|
||||
MakeTypeDecl(member->m_member->m_type_declaration.get()),
|
||||
MakeFollowingReferences(modifier.GetFollowingDeclarationModifiers()))
|
||||
}
|
||||
else
|
||||
{
|
||||
LINE_MIDDLE(".Expect()")
|
||||
}
|
||||
|
||||
LINE_END(";")
|
||||
}
|
||||
else
|
||||
{
|
||||
|
Reference in New Issue
Block a user