Skip to content

Commit

Permalink
Fixes for gender parsing adjustments
Browse files Browse the repository at this point in the history
  • Loading branch information
Noggog committed Nov 14, 2023
1 parent a7cb801 commit e728c09
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 9 deletions.
1 change: 1 addition & 0 deletions Mutagen.Bethesda.Core/MutagenSource.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -861,6 +861,7 @@
<xs:attribute name="femaleMarker" type="xs:string" />
<xs:attribute name="markerPerGender" type="xs:boolean" />
<xs:attribute name="shortCircuit" type="xs:boolean" />
<xs:attribute name="parseNonConvertedItems" type="xs:boolean" />
</xs:extension>
</xs:complexContent>
</xs:complexType>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ internal static class GenderedItemBinaryOverlay
Func<OverlayStream, BinaryOverlayFactoryPackage, TypedParseParams, T> creator,
RecordTypeConverter femaleRecordConverter,
RecordTypeConverter maleRecordConverter,
bool shortCircuit = true)
bool shortCircuit = true,
bool parseNonConvertedItems = false)
where T : class
{
var initialPos = stream.Position;
Expand All @@ -78,18 +79,18 @@ internal static class GenderedItemBinaryOverlay
recordTypeConverter: femaleRecordConverter,
doNotShortCircuit: !shortCircuit));
}
else if (i == 0)
else if (parseNonConvertedItems && i == 0)
{
maleObj = creator(stream, package, new TypedParseParams(
lengthOverride: null,
recordTypeConverter: maleRecordConverter,
doNotShortCircuit: !shortCircuit));
}
else if (i == 1)
else if (parseNonConvertedItems && i == 1)
{
femaleObj = creator(stream, package, new TypedParseParams(
lengthOverride: null,
recordTypeConverter: maleRecordConverter,
recordTypeConverter: femaleRecordConverter,
doNotShortCircuit: !shortCircuit));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<UInt8 />
</Fields>
</Gendered>
<Gendered name="WeightSliderEnabled" binary="Custom" byteLength="2" generateClassMembers="false">
<Gendered name="WeightSliderEnabled" binary="Custom" byteLength="2" >
<Fields>
<Bool />
</Fields>
Expand All @@ -22,7 +22,7 @@
<Float name="WeaponAdjust" />
</Fields>
</Data>
<Gendered name="WorldModel" shortCircuit="false">
<Gendered name="WorldModel" shortCircuit="false" >
<MaleTypeOverrides>
<Mapping From="MODL" To="MOD2" />
<Mapping From="MODC" To="MO2C" />
Expand All @@ -41,7 +41,7 @@
<RefDirect refName="Model" />
</Fields>
</Gendered>
<Gendered name="FirstPersonModel" shortCircuit="false">
<Gendered name="FirstPersonModel" shortCircuit="false" parseNonConvertedItems="false">
<MaleTypeOverrides>
<Mapping From="MODL" To="MOD4" />
<Mapping From="MODC" To="MO4C" />
Expand Down
2 changes: 2 additions & 0 deletions Mutagen.Bethesda.Generation/Fields/GenderedType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public bool ItemNullable
public RecordType? FemaleMarker;
public bool MarkerPerGender;
public bool ShortCircuit;
public bool ParseNonConvertedItems;

public override void GenerateClear(StructuredStringBuilder sb, Accessor accessorPrefix)
{
Expand Down Expand Up @@ -271,6 +272,7 @@ public override async Task Load(XElement node, bool requireName = true)
}

ShortCircuit = node.GetAttribute<bool>("shortCircuit", true);
ParseNonConvertedItems = node.GetAttribute<bool>("parseNonConvertedItems", false);

FemaleConversions = RecordTypeConverterModule.GetConverter(node.Element(XName.Get("FemaleTypeOverrides", LoquiGenerator.Namespace)));
MaleConversions = RecordTypeConverterModule.GetConverter(node.Element(XName.Get("MaleTypeOverrides", LoquiGenerator.Namespace)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,11 @@ public override async Task GenerateWrapperRecordTypeParse(
{
args.Add("shortCircuit: false");
}

if (gendered.ParseNonConvertedItems)
{
args.Add("parseNonConvertedItems: true");
}

if (notNull)
{
Expand Down
2 changes: 1 addition & 1 deletion Mutagen.Bethesda.Starfield/Records/Major Records/Armor.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<FormLink name="ObjectEffect" recordType="EITM">
<Interface>IEffectRecord</Interface>
</FormLink>
<Gendered name="WorldModel">
<Gendered name="WorldModel" parseNonConvertedItems="true">
<MaleTypeOverrides>
<Mapping From="MODL" To="MOD2" />
<Mapping From="MODT" To="MO2T" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4929,7 +4929,8 @@ public override ParseResult FillRecordType(
stream: stream,
creator: static (s, p, r) => ModelBinaryOverlay.ModelFactory(s, p, r),
femaleRecordConverter: Armor_Registration.WorldModelFemaleConverter,
maleRecordConverter: Armor_Registration.WorldModelMaleConverter);
maleRecordConverter: Armor_Registration.WorldModelMaleConverter,
parseNonConvertedItems: true);
return (int)Armor_FieldIndex.WorldModel;
}
case RecordTypeInts.BO64:
Expand Down

0 comments on commit e728c09

Please sign in to comment.