Skip to content

Commit

Permalink
fix fts compression not setting uncompressed size correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
fredlllll committed May 26, 2024
1 parent 1b253d8 commit 7fd7dfe
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion ArxLibertatisEditorIO/ArxLibertatisEditorIO.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<PackageTags>arx fatalis libertatis editor io</PackageTags>
<NeutralLanguage>en</NeutralLanguage>
<Title>ArxLibertatisEditorIO</Title>
<Version>2.1.0</Version>
<Version>2.1.1</Version>
<PackageReleaseNotes>cleanup and add operators and util functions to Color</PackageReleaseNotes>
</PropertyGroup>

Expand Down
11 changes: 9 additions & 2 deletions ArxLibertatisEditorIO/RawIO/FTS/FTS_IO.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public int CalculatePolyCount()
return count;
}

public void WriteTo(Stream stream)
public void WriteTo(Stream stream, bool compressed=true)
{
header.count = uniqueHeaders.Length;

Expand All @@ -107,7 +107,14 @@ public void WriteTo(Stream stream)
sceneHeader.nb_portals = portals.Length;
sceneHeader.nb_rooms = rooms.Length - 1;

header.uncompressedsize = GetUncompressedSize();
if (compressed)
{
header.uncompressedsize = GetUncompressedSize();
}
else
{
header.uncompressedsize = 0; // signals that fts is not compressed
}

using StructWriter writer = new StructWriter(stream, System.Text.Encoding.ASCII, true);

Expand Down
6 changes: 1 addition & 5 deletions ArxLibertatisEditorIO/RawIO/RawArxLevel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,7 @@ public void SaveLevel(string dlfPath, string llfPath, string ftsPath, bool compr

using (MemoryStream ms = new MemoryStream())
{
if (!compressFts)
{
fts.header.uncompressedsize = 0; // signals that fts is not compressed
}
fts.WriteTo(ms);
fts.WriteTo(ms, compressFts);

ms.Position = 0;
Directory.CreateDirectory(Path.GetDirectoryName(ftsPath));
Expand Down

0 comments on commit 7fd7dfe

Please sign in to comment.