Exemplo n.º 1
0
    public static byte[] UncompressChunk(ref byte[] iBytes, int outSize)
    {
        Console.WriteLine(Environment.CurrentDirectory);
        // zlib doesn't seem to work in 64bit, try this, and fallback to trying zlib if failed
        //if (is64BitProcess && File.Exists(ExternalCompressionName))
        //{
        //    var hex = HeroDesigner.ZLib.Helpers.byteArrayToHexString(iBytes);
        //    var proc = Process.Start(new ProcessStartInfo(ExternalCompressionName, "uncompress " + iBytes.Length + " " + outSize + " \"" + hex + "\"")
        //    {
        //        UseShellExecute = false,
        //        RedirectStandardOutput = true,
        //    });
        //    var output = proc.StandardOutput.ReadToEnd();
        //    if (proc.ExitCode == 0)
        //    {
        //        var text = new string(output.SkipWhile(x => x != '-').SkipWhile(x => x == '-').TakeWhile(x => x != '-').ToArray()).Trim();
        //        var bytes = HeroDesigner.ZLib.Helpers.hexStringToByteArray(text);
        //        return bytes;
        //    }
        //}
        int length     = iBytes.Length;
        int destLength = outSize;

        byte[] array = new byte[destLength];

        if (Zlib.Uncompress(ref array[0], ref destLength, ref iBytes[0], length) == 0)
        {
            Array.Resize(ref array, destLength);
            return(array);
        }
        else
        {
            return(Array.Empty <byte>());
        }
    }
Exemplo n.º 2
0
    public static byte[] UncompressChunk(ref byte[] iBytes, int outSize)
    {
        int length     = iBytes.Length;
        int destLength = outSize;

        byte[] array = new byte[destLength];
        byte[] numArray;
        if (Zlib.Uncompress(ref array[0], ref destLength, ref iBytes[0], length) == 0)
        {
            Array.Resize <byte>(ref array, destLength);
            numArray = array;
        }
        else
        {
            numArray = new byte[0];
        }
        return(numArray);
    }
Exemplo n.º 3
0
 public Record(BethesdaRecord copyFrom)
 {
     this.RecordType = copyFrom.RecordType;
     this.Flags      = copyFrom.Flags;
     this.Id         = copyFrom.Id;
     this.Revision   = copyFrom.Revision;
     this.Version    = copyFrom.Version;
     this.UNKNOWN_22 = copyFrom.UNKNOWN_22;
     if (copyFrom.Flags.HasFlag(BethesdaRecordFlags.Compressed))
     {
         this.CompressedFieldData = copyFrom.Payload.ToArray();
         this.fields = new Lazy <List <Field> >(() => CopyFieldsFrom(BethesdaRecord.GetFields(new ArraySegment <byte>(Zlib.Uncompress(this.CompressedFieldData)))));
     }
     else
     {
         List <Field> myFields = CopyFieldsFrom(copyFrom.Fields);
         this.fields = new Lazy <List <Field> >(() => myFields);
         this.MakeFieldsNotLazy();
     }
 }