Skip to content

Commit b77ebf9

Browse files
authored
Merge pull request #1 from Amethyst-szs/master
Fix bfres and byml alignment in SarcAlignment.cs
2 parents c34ccbf + f1f7781 commit b77ebf9

5 files changed

Lines changed: 42 additions & 6 deletions

File tree

src/SarcLibrary/Writers/SarcAlignment.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ public static int Estimate(KeyValuePair<string, ArraySegment<byte>> sarcEntry, i
3333
"bgsdw" or "bksky" or "bpref" or
3434
"glght" or "glpbd" or "glpbm" or
3535
"gsdw" or "ksky" or "pref" => LCM(result, 8),
36-
"baglmf" => LCM(result, 0x80),
37-
"sharc" or "sharcb" => LCM(result, 0x1000),
36+
"byml" or "baglmf" => LCM(result, 0x80),
37+
"bfres" or "sharc" or "sharcb" => LCM(result, 0x1000),
3838
"bofx" or "fmd" or "ftx" or "genvres" or "gtx" or "ofx" => LCM(result, 0x2000),
3939
_ => result
4040
};
@@ -50,7 +50,7 @@ public static int Estimate(KeyValuePair<string, ArraySegment<byte>> sarcEntry, i
5050
"bchemical" or "bas" or "batcllist" or "batcl" or "baischedule" or "bdmgparam" or
5151
"brgconfiglist" or "brgconfig" or "brgbw" or "bawareness" or "bdrop" or "bshop" or
5252
"brecipe" or "blod" or "bbonectrl" or "blifecondition" or "bumii" or "baniminfo" or
53-
"byaml" or "bassetting" or "hkrb" or "hkrg" or "bphyssb" or "hkcl" or "hksc" or
53+
"byaml" or "byml" or "bassetting" or "hkrb" or "hkrg" or "bphyssb" or "hkcl" or "hksc" or
5454
"hktmrb" or "brgcon" or "esetlist" or "bdemo" or "bfevfl" or "bfevtm")) {
5555
result = LCM(result, GetBinaryFileAlignment(sarcEntry.Value));
5656

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
using Revrs;
2+
3+
namespace SarcLibrary.Tests;
4+
5+
public class AlignmentTest
6+
{
7+
[Fact]
8+
public void TestSMOAirCurrentSarcAlignment()
9+
{
10+
byte[] data = DataProvider.GetAirCurrent();
11+
var sarc = Sarc.FromBinary(data);
12+
Assert.NotNull(sarc);
13+
14+
MemoryStream output = new();
15+
sarc.Write(output);
16+
17+
DataProvider.WriteGeneratedAirCurrent(output);
18+
19+
Assert.Equal(data, output.ToArray());
20+
}
21+
}
33.5 KB
Binary file not shown.

src/Tests/SarcLibrary.Tests/DataProvider.cs

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,29 @@ public static class DataProvider
66
{
77
public static byte[] GetTest1(Endianness endianness)
88
{
9-
return File.ReadAllBytes(endianness switch {
9+
return File.ReadAllBytes(endianness switch
10+
{
1011
Endianness.Little => "Data/Test1-LE.sarc",
1112
_ => "Data/Test1-BE.sarc"
1213
});
1314
}
14-
15+
1516
public static Stream StreamTest1(Endianness endianness)
1617
{
17-
return File.OpenRead(endianness switch {
18+
return File.OpenRead(endianness switch
19+
{
1820
Endianness.Little => "Data/Test1-LE.sarc",
1921
_ => "Data/Test1-BE.sarc"
2022
});
2123
}
24+
25+
26+
public static byte[] GetAirCurrent()
27+
{
28+
return File.ReadAllBytes("Data/AirCurrent.sarc");
29+
}
30+
public static void WriteGeneratedAirCurrent(MemoryStream stream)
31+
{
32+
File.WriteAllBytes("Data/AirCurrentOutput.sarc", stream.ToArray());
33+
}
2234
}

src/Tests/SarcLibrary.Tests/SarcLibrary.Tests.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@
2929
<Content Include="Data\Test1-LE.sarc">
3030
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
3131
</Content>
32+
<Content Include="Data\AirCurrent.sarc">
33+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
34+
</Content>
3235
</ItemGroup>
3336

3437
<ItemGroup>

0 commit comments

Comments
 (0)