Skip to content

Commit

Permalink
Fix: Inline subobjects even if it is empty. (these are usually insert…
Browse files Browse the repository at this point in the history
…ed by the compiler, but we must declare them for re-compiling purposes).
  • Loading branch information
EliotVU committed Apr 25, 2024
1 parent 84b46ee commit b613696
Showing 1 changed file with 26 additions and 32 deletions.
58 changes: 26 additions & 32 deletions src/Core/Classes/UDefaultProperty.cs
Original file line number Diff line number Diff line change
Expand Up @@ -679,44 +679,38 @@ private string DeserializeDefaultPropertyValue(PropertyType type, ref Deserializ
{
var constantObject = _Buffer.ReadObject();
Record(nameof(constantObject), constantObject);
if (constantObject != null)
if (constantObject == null)
{
var inline = false;
// If true, object is an archetype or subobject.
if (constantObject.Outer == _Container &&
(deserializeFlags & DeserializeFlags.WithinStruct) == 0)
// =none
propertyValue = "none";
break;
}

// If the object is part of the current container, then it probably was an inlined declaration.
bool shouldInline = constantObject.Outer == _Container &&
(deserializeFlags & DeserializeFlags.WithinStruct) == 0;
if (shouldInline)
{
// Unknown objects are only deserialized on demand.
constantObject.BeginDeserializing();
propertyValue = constantObject.Decompile() + "\r\n";

_TempFlags |= DoNotAppendName;
if ((deserializeFlags & DeserializeFlags.WithinArray) != 0)
{
// Unknown objects are only deserialized on demand.
constantObject.BeginDeserializing();
if (constantObject.Properties != null && constantObject.Properties.Count > 0)
{
inline = true;
propertyValue = constantObject.Decompile() + "\r\n" + UDecompilingState.Tabs;

_TempFlags |= DoNotAppendName;
if ((deserializeFlags & DeserializeFlags.WithinArray) != 0)
{
_TempFlags |= ReplaceNameMarker;
propertyValue += $"%ARRAYNAME%={constantObject.Name}";
}
else
{
propertyValue += $"{Name}={constantObject.Name}";
}
}
_TempFlags |= ReplaceNameMarker;
propertyValue += $"{UDecompilingState.Tabs}%ARRAYNAME%={constantObject.Name}";
}

if (!inline)
// =CLASS'Package.Group(s)+.Name'
else
{
propertyValue = PropertyDisplay.FormatLiteral(constantObject);
propertyValue += $"{UDecompilingState.Tabs}{Name}={constantObject.Name}";
}

break;
}
else
{
// =none
propertyValue = "none";
}

// =Class'Package.Group.Name'
propertyValue = PropertyDisplay.FormatLiteral(constantObject);

break;
}
Expand Down

0 comments on commit b613696

Please sign in to comment.