Example #1
0
        public void Update(JagexBuffer b)
        {
            b.Position(0);

            Gender     = b.ReadByte();
            PrayerIcon = b.ReadUByte();
            b.ReadByte();
            SkullIcon = b.ReadShort() == 0 ? -1 : 0;

            for (int i = 0; i < 12; i++)
            {
                int lsb = b.ReadUByte();

                if (lsb == 0)
                {
                    EquipmentIndices[i] = 0;
                    continue;
                }

                EquipmentIndices[i] = (lsb << 8) + b.ReadUByte();

                if (i == 0 && this.EquipmentIndices[0] == 65535)
                {
                    b.ReadUShort();
                    break;
                }
            }

            for (int i = 0; i < 5; i++)
            {
                colors[i] = b.ReadUByte();
            }

            StandAnimation = 625;//.ReadUShort();
            if (StandAnimation == 65535)
            {
                StandAnimation = -1;
            }

            StandTurnAnimation = b.ReadUShort();
            if (StandTurnAnimation == 65535)
            {
                StandTurnAnimation = -1;
            }

            WalkAnimation = b.ReadUShort();
            if (WalkAnimation == 65535)
            {
                WalkAnimation = -1;
            }

            Turn180Animation = b.ReadUShort();
            if (Turn180Animation == 65535)
            {
                Turn180Animation = -1;
            }

            TurnRightAnimation = b.ReadUShort();
            if (TurnRightAnimation == 65535)
            {
                TurnRightAnimation = -1;
            }

            TurnLeftAnimation = b.ReadUShort();
            if (TurnLeftAnimation == 65535)
            {
                TurnLeftAnimation = -1;
            }

            RunAnimation = b.ReadUShort();
            if (RunAnimation == 65535)
            {
                RunAnimation = -1;
            }

            this.Name        = StringUtils.Format(StringUtils.LongToString(b.ReadLong()));
            this.CombatLevel = (short)b.ReadUByte();
            b.ReadUShort();
            b.ReadUShort();

            this.Visible  = true;
            this.ModelUid = 0L;

            for (int i = 0; i < 12; i++)
            {
                this.ModelUid <<= 4;
                if (EquipmentIndices[i] >= 256)
                {
                    this.ModelUid += EquipmentIndices[i] - 256;
                }
            }

            if (EquipmentIndices[0] >= 256)
            {
                this.ModelUid += EquipmentIndices[0] - 256 >> 4;
            }

            if (EquipmentIndices[1] >= 256)
            {
                this.ModelUid += EquipmentIndices[1] - 256 >> 8;
            }

            for (int i = 0; i < 5; i++)
            {
                this.ModelUid <<= 3;
                this.ModelUid  += colors[i];
            }

            this.ModelUid <<= 1;
            this.ModelUid  += Gender;

            UnityObject.name = "Player " + Name;
            Dirty            = true;
            UpdateObjectScenePos();
        }
Example #2
0
        public LoginResponse WriteAuthBlock(string username, string password)
        {
            var stream = client.GetStream();

            stream.ReadTimeout = 5000;

            var nameHash = StringUtils.StringToLong(username);
            var i        = (int)(nameHash >> 16 & 31L);

            var @out = new DefaultJagexBuffer(5000);

            @out.Position(0);
            @out.WriteByte(14);
            @out.WriteByte(i);
            stream.Write(@out.Array(), 0, @out.Position());
            @out.Position(0);
            stream.Flush();
            for (var j = 0; j < 8; j++)
            {
                stream.ReadByte();
            }

            int response = stream.ReadByte();

            if (response == 0)
            {
                InBuffer.Position(0);
                stream.Read(InBuffer.Array(), 0, 8);
                var serverSeed = InBuffer.ReadLong();

                var seed = new int[4];
                var rand = new System.Random();

                seed[0] = (int)(rand.NextDouble() * 9.9999999E7D);
                seed[1] = (int)(rand.NextDouble() * 9.9999999E7D);
                seed[2] = (int)(serverSeed >> 32);
                seed[3] = (int)(serverSeed);

                @out.Position(0);
                @out.WriteByte(10);
                @out.WriteInt(seed[0]);
                @out.WriteInt(seed[1]);
                @out.WriteInt(seed[2]);
                @out.WriteInt(seed[3]);
                @out.WriteInt(350 >> 2240);
                @out.WriteString(username, 10);
                @out.WriteString(password, 10);
                @out.WriteShort(222);
                @out.WriteByte(0);
                @out.RSA(GameConstants.LoginRsaExp, GameConstants.LoginRsaMod);

                wrapperBuffer.Position(0);
                wrapperBuffer.WriteByte(16);
                wrapperBuffer.WriteByte(@out.Position() + 36 + 1 + 2);
                wrapperBuffer.WriteByte(255);
                wrapperBuffer.WriteShort(13);
                wrapperBuffer.WriteByte(1);
                for (var j = 0; j < 9; j++)
                {
                    wrapperBuffer.WriteInt(0);
                }

                GameContext.OutCipher = new ISAACCipher(seed);
                for (var j = 0; j < seed.Length; j++)
                {
                    seed[j] += 50;
                }
                GameContext.InCipher = new ISAACCipher(seed);

                wrapperBuffer.WriteBytes(@out.Array(), 0, @out.Position());
                stream.Write(wrapperBuffer.Array(), 0, wrapperBuffer.Position());
                stream.Flush();

                response = stream.ReadByte();
                @out.Position(0);

                if (response == 2)
                {
                    GameContext.LocalRights = stream.ReadByte();
                    stream.ReadByte();
                    Connected = true;
                    return(LoginResponse.SuccessfulLogin);
                }
            }
            return(LoginResponse.Unknown);
        }