Exemplo n.º 1
0
        public static void WriteAddonInfo(this IAuthHandler authHandler, IPacketReader inPacket, IPacketWriter outPacket, int size)
        {
            int count = 0x100; // arbitrary number

            if (Authenticator.ClientBuild >= 9464)
            {
                count = inPacket.ReadInt32(); // addon count
            }
            int i = 0;

            while (inPacket.Position < size && i < count)
            {
                string addonName   = inPacket.ReadString();
                bool   enabled     = inPacket.ReadBool();
                uint   filecrc     = inPacket.ReadUInt32();
                uint   urlcrc      = inPacket.ReadUInt32();
                bool   requireskey = filecrc != 0x1C776D01u && filecrc != 0x4C1C776Du; // offical crcs

                outPacket.WriteUInt8(2);                                               // blizzard
                outPacket.WriteBool(true);                                             // enabled
                outPacket.WriteBool(requireskey);
                if (requireskey)
                {
                    outPacket.Write(AddonPublicKey);
                }
                outPacket.WriteUInt32(0); // use addon url file
                outPacket.WriteUInt8(0);  // addon url filename, cstring

                i++;
            }

            outPacket.WriteUInt32(0); // banned addon count
        }
Exemplo n.º 2
0
        public void ReadFromPacket(IPacketReader reader)
        {
            _ = reader.ReadByte(); // FieldKey

            _ = reader.ReadInt();  // dr0
            _ = reader.ReadInt();  // dr1

            var attackInfo = reader.ReadByte();

            DamagePerMob = attackInfo >> 0 & 0xF;
            MobCount     = attackInfo >> 4 & 0xF;

            _ = reader.ReadInt(); // dr2
            _ = reader.ReadInt(); // dr3

            SkillID = reader.ReadInt();
            _       = reader.ReadBool(); // unk

            _ = reader.ReadInt();        // dr rand
            _ = reader.ReadInt();        // crc

            _ = reader.ReadInt();        // skillLevel crc
            _ = reader.ReadInt();        // skillLevel crc

            Keydown = 0;                 // TODO keydownskill check - int keydown

            var skillFlags = reader.ReadByte();

            IsFinalAfterSlashBlast = (skillFlags & 0x0) > 0;
            IsShadowPartner        = (skillFlags & 8) > 0;
            IsSerialAttack         = (skillFlags & 32) > 0;

            var actionInfo = reader.ReadShort();

            Action       = actionInfo & 0x7FFF;
            IsFacingLeft = (actionInfo >> 15 & 1) > 0;

            _ = reader.ReadInt(); // action crc?

            ActionType  = reader.ReadByte();
            ActionSpeed = reader.ReadByte();
            ActionTime  = reader.ReadInt();

            Phase = reader.ReadInt(); // BattleMage?

            for (var i = 0; i < MobCount; i++)
            {
                Mobs.Add(reader.Read(new ClientAttackMobInfo(DamagePerMob)));
            }

            _ = reader.ReadPoint2D(); // unk

            // TODO grenade readpoint2d
        }
Exemplo n.º 3
0
        public override async Task Handle(LoginStageUser user, IPacketReader packet)
        {
            var cancel = !packet.ReadBool();

            if (cancel)
            {
                await user.Disconnect();

                return;
            }

            var gender   = (byte)(packet.ReadBool() ? 1 : 0);
            var response = new UnstructuredOutgoingPacket(PacketSendOperations.SetAccountResult);

            user.Account.Gender = gender;

            response.WriteByte(gender);
            response.WriteBool(!cancel);

            await user.Dispatch(response);
        }
Exemplo n.º 4
0
        protected override async Task Handle(GameStageUser stageUser, IFieldObjUser user, IPacketReader packet)
        {
            var emotion      = packet.ReadInt();
            var duration     = packet.ReadInt();
            var byItemOption = packet.ReadBool();

            // TODO item option check

            var response = new UnstructuredOutgoingPacket(PacketSendOperations.UserEmotion);

            response.WriteInt(user.ID);
            response.WriteInt(emotion);
            response.WriteInt(duration);
            response.WriteBool(byItemOption);

            await user.FieldSplit.Dispatch(user, response);
        }
Exemplo n.º 5
0
        protected override async Task Handle(GameStageUser stageUser, IFieldObjUser user, IPacketReader packet)
        {
            _ = packet.ReadInt();
            var message     = packet.ReadString();
            var onlyBalloon = packet.ReadBool();

            if (message.StartsWith("!") || message.StartsWith("@")) // TODO: config?
            {
                await stageUser.Stage.CommandProcessor.Process(user, message.Substring(1));

                return;
            }

            var chatPacket1 = new UnstructuredOutgoingPacket(PacketSendOperations.UserChat);

            chatPacket1.WriteInt(user.ID);
            chatPacket1.WriteBool(user.Account.GradeCode > 0 || user.Account.SubGradeCode > 0); // TODO: proper gm chat checks
            chatPacket1.WriteString(message);
            chatPacket1.WriteBool(onlyBalloon);

            await user.FieldSplit.Dispatch(chatPacket1);

            if (onlyBalloon)
            {
                return;
            }

            var chatPacket2 = new UnstructuredOutgoingPacket(PacketSendOperations.UserChatNLCPQ);

            chatPacket2.WriteInt(user.ID);
            chatPacket2.WriteBool(user.Account.GradeCode > 0 || user.Account.SubGradeCode > 0); // TODO: proper gm chat checks
            chatPacket2.WriteString(message);
            chatPacket2.WriteBool(onlyBalloon);
            chatPacket2.WriteString(user.Character.Name);

            await Task.WhenAll(user.Field
                               .GetUsers()
                               .Except(user.FieldSplit.GetWatchers())
                               .Select(u => u.Dispatch(chatPacket2)));
        }
Exemplo n.º 6
0
 protected override void ReadData(IPacketReader reader)
 {
     _stat = reader.ReadBool();
 }