public override bool HandlePacket(GameClient session, ref byte[] packet)
        {
            for (int i = 0; i < packet.Length; i++)
            {
                if (this.ReadByte(packet[i]))
                {
                    NewCryptoClientMessage message = new NewCryptoClientMessage();
                    message.Init((uint)HabboEncoding.DecodeInt16(new byte[] { this.Packet[0], this.Packet[1] }), this.Packet);
                    message.Skip(2);
                    session.HandlePacket(message);

                    Array.Clear(this.Packet, 0, this.Packet.Length);
                    this.Packet      = null;
                    this.Lenght      = null;
                    this.LenghtBytes = null;
                    this.Pointer     = 0;

                    if (session.Disconnected)
                    {
                        return(false); //packet disconnected the user! :D
                    }
                }
            }

            return(true);
        }
Пример #2
0
        private ClientMessage TryParseAsNewCrypto(byte[] packet)
        {
            try
            {
                int i = 0;
                while (i < packet.Length)
                {
                    int lenght = HabboEncoding.DecodeInt32(new byte[] { (byte)packet[i++], (byte)packet[i++], (byte)packet[i++], (byte)packet[i++] });
                    if (lenght > 0)
                    {
                        uint id = (uint)HabboEncoding.DecodeInt16(new byte[] { (byte)packet[i++], (byte)packet[i++] });
                        if (id > 0)
                        {
                            byte[] bytes = new byte[lenght - 2];
                            for (int j = 0; j < bytes.Length; j++)
                            {
                                bytes[j] = packet[i++];
                            }

                            NewCryptoClientMessage crypto = new NewCryptoClientMessage();
                            crypto.Init(id, bytes);
                            return(crypto);
                        }
                    }
                }
            }
            catch
            {
                return(null);
            }

            return(null);
        }