Skip to content

Commit

Permalink
remove SharpZipLib, no longer used for sqpack decompression
Browse files Browse the repository at this point in the history
  • Loading branch information
NotAdam committed Feb 22, 2020
1 parent 2aa7ad7 commit a6d63ac
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
1 change: 0 additions & 1 deletion Lumina/Data/Files/TexFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
using ICSharpCode.SharpZipLib.Tar;
using Lumina.Data.Parsing.Tex;
using Lumina.Extensions;

Expand Down
26 changes: 14 additions & 12 deletions Lumina/Data/SqPack.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
using System.Diagnostics;
using System.Diagnostics.Contracts;
using System.IO;
using System.Threading;
using ICSharpCode.SharpZipLib.Zip.Compression;
using System.IO.Compression;
using Lumina.Data.Structs;
using Lumina.Extensions;

Expand Down Expand Up @@ -86,7 +85,7 @@ protected T GetCachedFile< T >( long offset ) where T : FileResource
{
return null;
}

// only return from cache if target type matches
// otherwise we'll force a cache miss and parse it as per usual
if( cachedFile is T obj )
Expand Down Expand Up @@ -117,7 +116,7 @@ public T ReadFile< T >( long offset ) where T : FileResource
return obj;
}
}

using var fs = File.OpenRead();
using var br = new BinaryReader( fs );
using var ms = new MemoryStream();
Expand Down Expand Up @@ -182,7 +181,7 @@ public T ReadFile< T >( long offset ) where T : FileResource
file.Data = ms.ToArray();
if( file.Data.Length != file.FileInfo.RawFileSize )
Debug.WriteLine( "Read data size does not match file size." );

file.FileStream = new MemoryStream( file.Data, false );
file.Reader = new BinaryReader( file.FileStream );
file.FileStream.Position = 0;
Expand Down Expand Up @@ -348,18 +347,21 @@ protected void ReadFileBlock( long offset, FileStream fs, BinaryReader br, Memor
if( blockHeader.compressed_size == 32000 )
{
dest.Write( br.ReadBytes( (int)blockHeader.uncompressed_size ) );

return;
}

var data = br.ReadBytes( (int)blockHeader.uncompressed_size );

var inflater = new Inflater( true );

inflater.SetInput( data );
var bytesInflated = inflater.Inflate( data );

dest.Write( data );
var uncompressedData = new MemoryStream();
using( var compressedStream = new MemoryStream( data ) )
{
using var zlibStream = new DeflateStream( compressedStream, CompressionMode.Decompress );
zlibStream.CopyTo( uncompressedData );
zlibStream.Close();

uncompressedData.Position = 0;
uncompressedData.CopyTo( dest );
}

if( resetPosition )
fs.Position = originalPosition;
Expand Down
3 changes: 1 addition & 2 deletions Lumina/Lumina.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<PackageProjectUrl>https://github.com/NotAdam/Lumina</PackageProjectUrl>
<PackageLicenseFile>LICENSE</PackageLicenseFile>
<RepositoryUrl>https://github.com/NotAdam/Lumina</RepositoryUrl>
<PackageVersion>1.0.0-preview10</PackageVersion>
<PackageVersion>1.0.0</PackageVersion>
<Description>Lumina is a small, performant and simple library for interacting with FINAL FANTASY XIV game data.</Description>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
Expand All @@ -18,7 +18,6 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="SharpZipLib" Version="1.2.0" />
<PackageReference Include="System.Drawing.Common" Version="4.6.0" />
</ItemGroup>

Expand Down

0 comments on commit a6d63ac

Please sign in to comment.