Skip to content

Commit

Permalink
Bugfix for adding new sculps/modifiers
Browse files Browse the repository at this point in the history
  • Loading branch information
cmarNYC committed May 17, 2017
1 parent 55adf92 commit ceb7b5a
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions s4pi Wrappers/CASPartResource/CASPreset.cs
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,7 @@ protected override Stream UnParse()
w.Write(this.unknown);
}
w.Write(this.chanceForRandom);

this.flagList = this.flagList ?? new FlagList(this.OnResourceChanged);
if (this.flagList == null) this.flagList = new FlagList(OnResourceChanged);
if (this.version >= 10)
{
this.flagList.UnParse(ms);
Expand Down Expand Up @@ -204,11 +203,11 @@ public Sculpt(int apiVersion, EventHandler handler, Stream s, uint version)
}
}

public void UnParse(Stream s)
public void UnParse(Stream s, uint version)
{
BinaryWriter w = new BinaryWriter(s);
w.Write(this.instance);
if (parentVersion < 9)
if (version < 9)
{
w.Write(this.region);
}
Expand Down Expand Up @@ -314,7 +313,7 @@ public override void UnParse(Stream s)
w.Write(this.Count);
foreach (var reference in this)
{
reference.UnParse(s);
reference.UnParse(s, parentVersion);
}
}

Expand All @@ -327,7 +326,7 @@ protected override Sculpt CreateElement(Stream s)

protected override void WriteElement(Stream s, Sculpt element)
{
element.UnParse(s);
element.UnParse(s, parentVersion);
}
}

Expand Down Expand Up @@ -356,12 +355,12 @@ public Modifier(int apiVersion, EventHandler handler, Stream s, uint version)
}
}

public void UnParse(Stream s)
public void UnParse(Stream s, uint version)
{
BinaryWriter w = new BinaryWriter(s);
w.Write(this.instance);
w.Write(this.weight);
if (parentVersion < 9)
if (version < 9)
{
w.Write(this.region);
}
Expand Down Expand Up @@ -482,7 +481,7 @@ public override void UnParse(Stream s)
w.Write(this.Count);
foreach (var reference in this)
{
reference.UnParse(s);
reference.UnParse(s, parentVersion);
}
}

Expand All @@ -495,7 +494,7 @@ protected override Modifier CreateElement(Stream s)

protected override void WriteElement(Stream s, Modifier element)
{
element.UnParse(s);
element.UnParse(s, parentVersion);
}
}
#endregion
Expand Down

0 comments on commit ceb7b5a

Please sign in to comment.