コード例 #1
0
ファイル: BoolBit.cs プロジェクト: vangan123/rift-sunrise
 public override void Deserialize(ref PacketInStream Data)
 {
     if (PacketType == EPacketFieldType.True)
         val = (bool)true;
     else
         val = (bool)false;
 }
コード例 #2
0
 public override void Deserialize(ref PacketInStream Data)
 {
     val = Data.ReadEncoded7Bit();
 }
コード例 #3
0
        public bool ReadPacket()
        {
            if (Received.Count <= 0)
            {
                return(false);
            }

            if (!ReceiveCompress && !Crypted)
            {
                PacketInStream Packet = new PacketInStream(Received.ToArray(), Received.Count);
                long           Size   = Packet.ReadEncoded7Bit();

                if (Size > Packet.Length)
                {
                    return(false);
                }

                Received.RemoveRange(0, (int)(Packet.Position + Size));

                ISerializablePacket Pack = PacketProcessor.ReadPacket(ref Packet);
                if (Pack != null)
                {
                    Pack.OnRead(this);
                }

                return(true);
            }

            if (Crypted)
            {
                byte[] Packet = Received.ToArray();
                Received.Clear();
                Decrypt(Packet);
            }

            if (ReceiveCompress)
            {
                int End = -1;
                while ((End = GetEndCompression(ref Decrypted)) >= 0)
                {
                    byte[] ToUnCompress = new byte[End];
                    Buffer.BlockCopy(Decrypted.ToArray(), 0, ToUnCompress, 0, End);
                    Decrypted.RemoveRange(0, End);

                    byte[] Result = UnCompress(ToUnCompress);

                    Log.Dump("Decrypted", Result, 0, Result.Length);
                    PacketInStream Packet = new PacketInStream(Result, Result.Length);
                    long           Size   = Packet.ReadEncoded7Bit();

                    if (Size > Packet.Length)
                    {
                        Log.Error("ReadPacket", "Size > Packet.Lenght,Size=" + Size + ",Lenght=" + Packet.Length);
                        Packet.Dispose();
                        continue;
                    }

                    ISerializablePacket Pack = PacketProcessor.ReadPacket(ref Packet);
                    if (Pack != null)
                    {
                        Pack.OnRead(this);
                    }

                    Packet.Dispose();
                }
            }

            return(false);
        }
コード例 #4
0
ファイル: Encoded7Bit.cs プロジェクト: harpernz/RiftEMU
 public override void Deserialize(ref PacketInStream Data)
 {
     val = Data.ReadEncoded7Bit();
 }
コード例 #5
0
ファイル: Raw4Bit.cs プロジェクト: harpernz/RiftEMU
 public override void Deserialize(ref PacketInStream Data)
 {
     val = Data.Read(4);
 }
コード例 #6
0
        public override void Deserialize(ref PacketInStream Data)
        {
            long Size = Data.ReadEncoded7Bit();

            val = Data.Read((int)Size);
        }
コード例 #7
0
ファイル: PacketProcessor.cs プロジェクト: harpernz/RiftEMU
 public static ISerializablePacket ReadPacket(ref PacketInStream Stream)
 {
     return((ISerializablePacket)ReadField(ref Stream, 0, (int)EPacketFieldType.Packet).val);
 }
コード例 #8
0
 public abstract void Deserialize(ref PacketInStream Data);