diff --git a/BundleFormat/BundleEntry.cs b/BundleFormat/BundleEntry.cs
index 70956bb..0844533 100644
--- a/BundleFormat/BundleEntry.cs
+++ b/BundleFormat/BundleEntry.cs
@@ -20,7 +20,7 @@ public byte[] Data
return null;
if (Compressed)
- return RawData.Decompress((int)UncompressedSize);
+ return RawData.Decompress();
return RawData;
}
diff --git a/BundleFormat/BundleFormat.csproj b/BundleFormat/BundleFormat.csproj
index 494662b..96808d3 100644
--- a/BundleFormat/BundleFormat.csproj
+++ b/BundleFormat/BundleFormat.csproj
@@ -4,9 +4,6 @@
Library
true
-
-
-
diff --git a/BundleFormat/Extensions.cs b/BundleFormat/Extensions.cs
index ebb3080..7caf4a5 100644
--- a/BundleFormat/Extensions.cs
+++ b/BundleFormat/Extensions.cs
@@ -1,19 +1,15 @@
using System;
-using System.Buffers;
using System.Buffers.Binary;
using System.Collections.Generic;
+using System.IO;
+using System.IO.Compression;
using System.Numerics;
using System.Text;
-using System.Windows.Forms;
-using LibDeflate;
namespace BundleFormat
{
public static class Extensions
{
- private static Decompressor decompressor = new ZlibDecompressor();
- private static Compressor compressor = new ZlibCompressor(9);
-
public static string AsString(this byte[] self)
{
if (self == null)
@@ -45,18 +41,23 @@ public static string MakePreview(this byte[] self, int start, int end)
public static byte[] Compress(this byte[] self)
{
- return compressor.Compress(self).Memory.ToArray();
+ MemoryStream uncompressed = new(self);
+ MemoryStream compressed = new();
+ using (ZLibStream zlibStream = new(compressed, CompressionLevel.SmallestSize, true))
+ {
+ uncompressed.CopyTo(zlibStream);
+ }
+ return compressed.ToArray();
}
- public static byte[] Decompress(this byte[] self, int uncompressedSize)
+ public static byte[] Decompress(this byte[] self)
{
- var status = decompressor.Decompress(self, uncompressedSize, out var owner, out var bytesRead);
- if (status != OperationStatus.Done)
+ MemoryStream decompressed = new();
+ using (ZLibStream zlibStream = new(new MemoryStream(self), CompressionMode.Decompress))
{
- MessageBox.Show("Error decompressing data, status: " + status.ToString() + ", read: " + bytesRead.ToString(), "Error", MessageBoxButtons.OK);
- return null;
+ zlibStream.CopyTo(decompressed);
}
- return owner.Memory.ToArray();
+ return decompressed.ToArray();
}
public static bool Matches(this byte[] self, byte[] other)
diff --git a/BundleManager/BundleManager.csproj b/BundleManager/BundleManager.csproj
index b0081f6..0e57966 100644
--- a/BundleManager/BundleManager.csproj
+++ b/BundleManager/BundleManager.csproj
@@ -12,7 +12,6 @@
-
diff --git a/VaultFormat/AttribSysVaultForm.cs b/VaultFormat/AttribSysVaultForm.cs
index a89fa55..35c2005 100644
--- a/VaultFormat/AttribSysVaultForm.cs
+++ b/VaultFormat/AttribSysVaultForm.cs
@@ -1,12 +1,12 @@
using BundleUtilities;
using LangEditor;
-using Newtonsoft.Json;
using PluginAPI;
using System;
using System.Collections;
using System.ComponentModel;
using System.Globalization;
using System.IO;
+using System.Text.Json;
using System.Windows.Forms;
namespace VaultFormat
@@ -14,6 +14,11 @@ namespace VaultFormat
public delegate void Notify(); // delegate
public partial class AttribSysVaultForm : Form, IEntryEditor
{
+ private readonly JsonSerializerOptions jsonSerializerOptions = new()
+ {
+ WriteIndented = true
+ };
+
public AttribSysVaultForm()
{
InitializeComponent();
@@ -148,7 +153,8 @@ private void exportVaultToolStripMenuItem_Click(object sender, EventArgs e)
try
{
// Convertion of the AttribSys. Might need smarter structure to only keep the essential data concerning the configuration of the vehicle
- string jsonContent = JsonConvert.SerializeObject(AttribSys, Formatting.Indented);
+
+ string jsonContent = JsonSerializer.Serialize(AttribSys, jsonSerializerOptions);
File.WriteAllText(saveDialog.FileName, jsonContent);
diff --git a/VaultFormat/VaultFormat.csproj b/VaultFormat/VaultFormat.csproj
index 232e433..8d2457e 100644
--- a/VaultFormat/VaultFormat.csproj
+++ b/VaultFormat/VaultFormat.csproj
@@ -4,9 +4,6 @@
Library
true
-
-
-