Skip to content

Commit

Permalink
Merge branch 'hotfix/use-unsigned-integers'
Browse files Browse the repository at this point in the history
  • Loading branch information
Kaplas80 committed Mar 11, 2020
2 parents 0ce149b + 2d8e767 commit fba8a9a
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 13 deletions.
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project>
<PropertyGroup>
<Version>1.2.1</Version>
<Version>1.2.2</Version>
<Product>ParManager</Product>

<Authors>Kaplas</Authors>
Expand Down
6 changes: 3 additions & 3 deletions ParLibrary/Converter/ParArchiveReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,9 @@ public NodeContainerFormat Convert(BinaryFormat source)
for (int i = 0; i < totalFileCount; i++)
{
uint compressionFlag = reader.ReadUInt32();
int size = reader.ReadInt32();
int compressedSize = reader.ReadInt32();
int offset = reader.ReadInt32();
uint size = reader.ReadUInt32();
uint compressedSize = reader.ReadUInt32();
uint offset = reader.ReadUInt32();
int attributes = reader.ReadInt32();
int unknown2 = reader.ReadInt32();
int unknown3 = reader.ReadInt32();
Expand Down
4 changes: 2 additions & 2 deletions ParLibrary/Converter/ParArchiveWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -341,8 +341,8 @@ private static void WriteFiles(DataWriter writer, IEnumerable<Node> files, long

writer.Write(parFile.IsCompressed ? 0x80000000 : 0x00000000);
writer.Write(parFile.DecompressedSize);
writer.Write((int)node.Stream.Length);
writer.Write((int)dataPosition);
writer.Write((uint)node.Stream.Length);
writer.Write((uint)dataPosition);
writer.Write(attributes);
writer.Write(parFile.Unknown2);
writer.Write(parFile.Unknown3);
Expand Down
6 changes: 3 additions & 3 deletions ParLibrary/ParFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public ParFile(DataStream stream)

this.CanBeCompressed = true;
this.IsCompressed = false;
this.DecompressedSize = (int)stream.Length;
this.DecompressedSize = (uint)stream.Length;
this.Attributes = 0x00000020;
this.Unknown2 = 0x00000000;
this.Unknown3 = 0x00000000;
Expand All @@ -59,7 +59,7 @@ public ParFile(DataStream stream, long offset, long length)
{
this.CanBeCompressed = true;
this.IsCompressed = false;
this.DecompressedSize = (int)length;
this.DecompressedSize = (uint)length;
this.Attributes = 0x00000020;
this.Unknown2 = 0x00000000;
this.Unknown3 = 0x00000000;
Expand All @@ -79,7 +79,7 @@ public ParFile(DataStream stream, long offset, long length)
/// <summary>
/// Gets or sets the file size (decompressed).
/// </summary>
public int DecompressedSize { get; set; }
public uint DecompressedSize { get; set; }

/// <summary>
/// Gets or sets the file attributes.
Expand Down
9 changes: 5 additions & 4 deletions Tests/ParLib.UnitTests/SllzTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ namespace ParLib.UnitTests
{
using System.Text;
using NUnit.Framework;
using ParLibrary;
using ParLibrary.Sllz;
using Yarhl.FileFormat;
using Yarhl.IO;
Expand All @@ -27,19 +28,19 @@ public void TestSllz(byte compressorVersion)
byte[] buffer = Encoding.ASCII.GetBytes(sampleText);

DataStream dataStream = DataStreamFactory.FromArray(buffer, 0, buffer.Length);
using var binaryFormat = new BinaryFormat(dataStream);
using var binaryFormat = new ParFile(dataStream);

var parameters = new CompressorParameters
{
Endianness = 0x00,
Version = compressorVersion,
};

var compressedBinaryFormat = (BinaryFormat)ConvertFormat.With<Compressor, CompressorParameters>(parameters, binaryFormat);
var decompressedBinaryFormat = (BinaryFormat)ConvertFormat.With<Decompressor>(compressedBinaryFormat);
var compressedBinaryFormat = (ParFile)ConvertFormat.With<Compressor, CompressorParameters>(parameters, binaryFormat);
var decompressedBinaryFormat = (ParFile)ConvertFormat.With<Decompressor>(compressedBinaryFormat);

Assert.IsTrue(compressedBinaryFormat.Stream.Length < decompressedBinaryFormat.Stream.Length);
Assert.IsTrue(dataStream.Compare(decompressedBinaryFormat.Stream));
}
}
}
}

0 comments on commit fba8a9a

Please sign in to comment.