Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/SarcLibrary/Writers/SarcAlignment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ public static int Estimate(KeyValuePair<string, ArraySegment<byte>> sarcEntry, i
"bgsdw" or "bksky" or "bpref" or
"glght" or "glpbd" or "glpbm" or
"gsdw" or "ksky" or "pref" => LCM(result, 8),
"baglmf" => LCM(result, 0x80),
"sharc" or "sharcb" => LCM(result, 0x1000),
"byml" or "baglmf" => LCM(result, 0x80),
"bfres" or "sharc" or "sharcb" => LCM(result, 0x1000),
"bofx" or "fmd" or "ftx" or "genvres" or "gtx" or "ofx" => LCM(result, 0x2000),
_ => result
};
Expand All @@ -50,7 +50,7 @@ public static int Estimate(KeyValuePair<string, ArraySegment<byte>> sarcEntry, i
"bchemical" or "bas" or "batcllist" or "batcl" or "baischedule" or "bdmgparam" or
"brgconfiglist" or "brgconfig" or "brgbw" or "bawareness" or "bdrop" or "bshop" or
"brecipe" or "blod" or "bbonectrl" or "blifecondition" or "bumii" or "baniminfo" or
"byaml" or "bassetting" or "hkrb" or "hkrg" or "bphyssb" or "hkcl" or "hksc" or
"byaml" or "byml" or "bassetting" or "hkrb" or "hkrg" or "bphyssb" or "hkcl" or "hksc" or
"hktmrb" or "brgcon" or "esetlist" or "bdemo" or "bfevfl" or "bfevtm")) {
result = LCM(result, GetBinaryFileAlignment(sarcEntry.Value));

Expand Down
21 changes: 21 additions & 0 deletions src/Tests/SarcLibrary.Tests/AlignmentTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using Revrs;

namespace SarcLibrary.Tests;

public class AlignmentTest
{
[Fact]
public void TestSMOAirCurrentSarcAlignment()
{
byte[] data = DataProvider.GetAirCurrent();
var sarc = Sarc.FromBinary(data);
Assert.NotNull(sarc);

MemoryStream output = new();
sarc.Write(output);

DataProvider.WriteGeneratedAirCurrent(output);

Assert.Equal(data, output.ToArray());
}
}
Binary file added src/Tests/SarcLibrary.Tests/Data/AirCurrent.sarc
Binary file not shown.
18 changes: 15 additions & 3 deletions src/Tests/SarcLibrary.Tests/DataProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,29 @@ public static class DataProvider
{
public static byte[] GetTest1(Endianness endianness)
{
return File.ReadAllBytes(endianness switch {
return File.ReadAllBytes(endianness switch
{
Endianness.Little => "Data/Test1-LE.sarc",
_ => "Data/Test1-BE.sarc"
});
}

public static Stream StreamTest1(Endianness endianness)
{
return File.OpenRead(endianness switch {
return File.OpenRead(endianness switch
{
Endianness.Little => "Data/Test1-LE.sarc",
_ => "Data/Test1-BE.sarc"
});
}


public static byte[] GetAirCurrent()
{
return File.ReadAllBytes("Data/AirCurrent.sarc");
}
public static void WriteGeneratedAirCurrent(MemoryStream stream)
{
File.WriteAllBytes("Data/AirCurrentOutput.sarc", stream.ToArray());
}
}
3 changes: 3 additions & 0 deletions src/Tests/SarcLibrary.Tests/SarcLibrary.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@
<Content Include="Data\Test1-LE.sarc">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Data\AirCurrent.sarc">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>

<ItemGroup>
Expand Down