public override Packet GetNextPacket()
        {
            Packet packet = null;
            try
            {
                if (reader.Read())
                {
                    var id = reader.GetInt32(0);
                    var datetime = reader.GetDateTime(1);
                    var direction = (Direction)reader.GetInt32(2);
                    var opcode = (uint)reader.GetInt32(3);
                    var blob = reader.GetValue(4);

                    var data = new byte[0];

                    if (!DBNull.Value.Equals(blob))
                    {
                        data = (byte[])blob;

                        //decompress
                        if (opcode == 502 || opcode == 763 || (ClientBuildAmount < 9183 && opcode == 751))
                        {
                            using (var ms = new System.IO.MemoryStream(data))
                            using (var br = new System.IO.BinaryReader(ms))
                            {
                                var zsstream = new ComponentAce.Compression.Libs.zlib.ZStream();
                                var compdata = new byte[data.Length - 4];
                                System.Array.Copy(data, 4, compdata, 0, data.Length - 4);
                                int decompsize = br.ReadInt32();
                                var decompdata = new byte[decompsize];
                                zsstream.inflateInit();
                                zsstream.avail_in = compdata.Length;
                                zsstream.next_in = compdata;
                                zsstream.avail_out = decompsize;
                                zsstream.next_out = decompdata;
                                var ret = zsstream.inflate(ComponentAce.Compression.Libs.zlib.zlibConst.Z_NO_FLUSH);
                                var ret2 = zsstream.inflateEnd();

                                data = decompdata;
                            }
                        }
                    }

                    packet = new Packet(id, datetime, direction, opcode, data, data.Length, ClientBuild);

                    currentIndex = id;
                }

            }
            catch (Exception exc)
            {
                delegatemanager.AddException(exc);
            }

            return packet;
        }
        public override Packet GetNextPacket()
        {
            Packet tPacket = null;
            if (reader != null)
            {

                try
                {

                    if (reader.Read())
                    {
                        try
                        {
                            int id = reader.GetInt32(0);
                            DateTime datetime = reader.GetDateTime(1);
                            int direction = reader.GetInt32(2);
                            uint opcode = (uint)reader.GetInt32(3);
                            Object tBlob = reader.GetValue(4);

                            byte[] data = new byte[0];

                            if (!DBNull.Value.Equals(tBlob))
                            {
                                data = (byte[])tBlob;

                                //decompress
                                if (opcode == 502 || opcode == 763 || (ClientBuild < 9183 && opcode == 751))
                                {
                                    using (System.IO.MemoryStream ms = new System.IO.MemoryStream(data))
                                    {
                                        using (System.IO.BinaryReader br = new System.IO.BinaryReader(ms))
                                        {
                                            ComponentAce.Compression.Libs.zlib.ZStream tZStream = new ComponentAce.Compression.Libs.zlib.ZStream();
                                            byte[] tnew = new byte[data.Length - 4];
                                            System.Array.Copy(data, 4, tnew, 0, data.Length - 4);
                                            int tdecompsize = br.ReadInt32();
                                            byte[] tdecompdata = new byte[tdecompsize];
                                            tZStream.inflateInit();
                                            tZStream.avail_in = tnew.Length;
                                            tZStream.next_in = tnew;
                                            tZStream.avail_out = tdecompsize;
                                            tZStream.next_out = tdecompdata;
                                            int ret = tZStream.inflate(ComponentAce.Compression.Libs.zlib.zlibConst.Z_NO_FLUSH);
                                            int ret2 = tZStream.inflateEnd();

                                            data = tdecompdata;
                                        }
                                    }
                                }
                            }
                            tPacket = new Packet(id, datetime, (byte)direction, opcode, data, data.Length, ClientBuild);

                            currentIndex = id;

                        }
                        catch (Exception exc)
                        {
                            System.Console.WriteLine(string.Format("Log {0} at index {1} has Error: {2}", fileName, currentIndex + 1, exc.Message));
                            System.Diagnostics.Debug.WriteLine(string.Format("Log {0} at index {1} has Error: {2}", fileName, currentIndex + 1, exc.Message));
                        }
                    }
                }
                catch (Exception exc)
                {
                    System.Console.WriteLine(string.Format("Log {0} at index {1} has Error: {2}", fileName, currentIndex + 1, exc.Message));
                    System.Diagnostics.Debug.WriteLine(string.Format("Log {0} at index {1} has Error: {2}", fileName, currentIndex + 1, exc.Message));

                }
            }

            return tPacket;
        }