Skip to content

Commit

Permalink
Don't serialize IncludePendingResume on stop action, fix test weirdness
Browse files Browse the repository at this point in the history
  • Loading branch information
henbagle committed Dec 27, 2023
1 parent d3e7548 commit a4bd277
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
8 changes: 6 additions & 2 deletions ME3Tweaks.Wwiser.Tests/ConvertTests/HircChunkConvertTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@ public void Convert56to134_Works()
HircConverter.ConvertHircChunk(hirc, from, to);

var newData = TestHelpers.Serialize(result, to);
TestHelpers.WriteStreamToFile(new MemoryStream(newData), TestData.GetTestDataFilePath("Convert", "HIRC", "Out134"));
Assert.That(newData.Length, Is.EqualTo(TestData.GetTestDataBytes(@"Convert", @"HIRC", @"134.bin").Length));
var data134 = TestData.GetTestDataBytes(@"Convert", @"HIRC", @"134.bin");
Assert.That(newData.Length, Is.EqualTo(data134.Length));

var outfile = TestData.GetTestDataFilePath("Convert", "HIRC", "Out134");
File.WriteAllText(outfile, string.Empty); // Wipe out file
TestHelpers.WriteStreamToFile(new MemoryStream(newData), outfile);
}
}
Binary file modified ME3Tweaks.Wwiser.Tests/TestData/Convert/HIRC/134.bin.bak
Binary file not shown.
5 changes: 4 additions & 1 deletion ME3Tweaks.Wwiser/Model/Action/Specific/ActiveFlags.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using BinarySerialization;
using ME3Tweaks.Wwiser.Model.Hierarchy;

namespace ME3Tweaks.Wwiser.Model.Action.Specific;

Expand Down Expand Up @@ -27,6 +28,8 @@ public void Serialize(Stream stream, Endianness endianness, BinarySerializationC
{
// TODO: IncludePendingResume on stop?
var version = serializationContext.FindAncestor<BankSerializationContext>().Version;
var action = serializationContext.FindAncestor<HircItem>() as Hierarchy.Action;
var notStop = action?.Type.Value != ActionTypeValue.Stop;
if (version <= 56)
{
stream.Write(BitConverter.GetBytes((uint)(IncludePendingResume ? 0 : 1)));
Expand All @@ -40,7 +43,7 @@ public void Serialize(Stream stream, Endianness endianness, BinarySerializationC
else
{
ActiveFlagsInner flags = 0;
if (IncludePendingResume) flags |= ActiveFlagsInner.IncludePendingResume;
if (IncludePendingResume && notStop) flags |= ActiveFlagsInner.IncludePendingResume;
if (ApplyToStateTransitions) flags |= ActiveFlagsInner.ApplyToStateTransitions;
if (ApplyToDynamicSequence) flags |= ActiveFlagsInner.ApplyToDynamicSequence;
stream.WriteByte((byte)flags);
Expand Down

0 comments on commit a4bd277

Please sign in to comment.