当前位置: 首页>>代码示例>>C#>>正文


C# PacketReader.ReadUInt16方法代码示例

本文整理汇总了C#中Framework.Network.Packets.PacketReader.ReadUInt16方法的典型用法代码示例。如果您正苦于以下问题:C# PacketReader.ReadUInt16方法的具体用法?C# PacketReader.ReadUInt16怎么用?C# PacketReader.ReadUInt16使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Framework.Network.Packets.PacketReader的用法示例。


在下文中一共展示了PacketReader.ReadUInt16方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: HandleLearnTalents

        //[Opcode(ClientMessage.LearnTalents, "16357")]
        public static void HandleLearnTalents(ref PacketReader packet, ref WorldClass session)
        {
            var pChar = session.Character;
            var talentSpells = new List<uint>();

            BitUnpack BitUnpack = new BitUnpack(packet);

            uint talentCount = BitUnpack.GetBits<uint>(25);

            for (int i = 0; i < talentCount; i++)
            {
                var talentId = packet.ReadUInt16();
                SpecializationMgr.AddTalent(pChar, pChar.ActiveSpecGroup, talentId, true);

                talentSpells.Add(DBCStorage.TalentStorage.LookupByKey(talentId).SpellId);
            }

            HandleTalentUpdate(ref session);

            pChar.SetUpdateField<Int32>((int)PlayerFields.SpellCritPercentage + 0, SpecializationMgr.GetUnspentTalentRowCount(pChar), 0);
            ObjectHandler.HandleUpdateObjectValues(ref session);

            // we need to send a single packet for every talent spell - stupid blizz
            foreach (var talentSpell in talentSpells)
                SpellHandler.HandleLearnedSpells(ref session, new List<uint>(1) { talentSpell });

            Log.Message(LogType.DEBUG, "Character (Guid: {0}) learned {1} talents.", pChar.Guid, talentCount);
        }
开发者ID:Krogonos,项目名称:Arctium,代码行数:29,代码来源:SpecializationHandler.cs

示例2: HandleAuthLogonChallenge

        public void HandleAuthLogonChallenge(RealmClass session, PacketReader data)
        {
            Log.Message(LogType.NORMAL, "AuthLogonChallenge");

            data.Skip(10);
            ushort ClientBuild = data.ReadUInt16();
            data.Skip(8);
            account.Language = data.ReadStringFromBytes(4);
            data.Skip(4);

            account.IP = data.ReadIPAddress();
            account.Name = data.ReadAccountName();

            SQLResult result = DB.Realms.Select("SELECT id, name, password, expansion, gmlevel, securityFlags FROM accounts WHERE name = '{0}'", account.Name);
            var res = result.Read("id", "name", "password", "expansion", "securityFlags");

            PacketWriter logonChallenge = new PacketWriter();
            logonChallenge.WriteUInt8((byte)ClientLink.CMD_AUTH_LOGON_CHALLENGE);
            logonChallenge.WriteUInt8(0);

            if (result.Count != 0)
            {
                account.Id = result.Read<Int32>("id");
                account.Expansion = result.Read<Byte>("expansion");
                account.SecurityFlags = result.Read<Byte>("securityFlags");

                DB.Realms.Execute("UPDATE accounts SET ip = '{0}', language = '{1}' WHERE id = {2}", account.IP, account.Language, account.Id);

                byte[] username = Encoding.UTF8.GetBytes(result.Read<String>("name").ToUpper());
                byte[] password = Encoding.UTF8.GetBytes(result.Read<String>("password").ToUpper());

                // WoW 5.1.0.16309 (5.1.0)
                if (ClientBuild == 16309)
                {
                    session.SecureRemotePassword.CalculateX(username, password);
                    byte[] buf = new byte[0x10];
                    SRP6.RAND_bytes(buf, 0x10);

                    logonChallenge.WriteUInt8((byte)AuthResults.WOW_SUCCESS);
                    logonChallenge.WriteBytes(session.SecureRemotePassword.B);
                    logonChallenge.WriteUInt8(1);
                    logonChallenge.WriteUInt8(session.SecureRemotePassword.g[0]);
                    logonChallenge.WriteUInt8(0x20);
                    logonChallenge.WriteBytes(session.SecureRemotePassword.N);
                    logonChallenge.WriteBytes(session.SecureRemotePassword.salt);
                    logonChallenge.WriteBytes(buf);

                    // Security flags
                    logonChallenge.WriteUInt8(account.SecurityFlags);

                    // Enable authenticator
                    if ((account.SecurityFlags & 4) != 0)
                        logonChallenge.WriteUInt8(1);
                }
            }
            else
                logonChallenge.WriteUInt8((byte)AuthResults.WOW_FAIL_UNKNOWN_ACCOUNT);

            session.Send(logonChallenge);
        }
开发者ID:concept45,项目名称:Arctium-RT,代码行数:60,代码来源:RealmClass.cs

示例3: HandleAuthLogonChallenge

        public void HandleAuthLogonChallenge(PacketReader data)
        {
            Log.Message(LogType.NORMAL, "AuthLogonChallenge");

            data.Skip(10);
            ushort ClientBuild = data.ReadUInt16();
            data.Skip(8);
            account.Language = data.ReadStringFromBytes(4);
            data.Skip(4);

            account.IP = data.ReadIPAddress();
            account.Name = data.ReadAccountName();

            SQLResult result = DB.Realms.Select("SELECT id, name, password, expansion, gmlevel, securityFlags, online FROM accounts WHERE name = ?", account.Name);

            using (var logonChallenge = new PacketWriter())
            {
                logonChallenge.WriteUInt8((byte)ClientLink.CMD_AUTH_LOGON_CHALLENGE);
                logonChallenge.WriteUInt8(0);

                if (result.Count != 0)
                {
                    if (result.Read<bool>(0, "online"))
                    {
                        logonChallenge.WriteUInt8((byte)AuthResults.WOW_FAIL_ALREADY_ONLINE);
                        Send(logonChallenge);
                        return;
                    }

                    account.Id = result.Read<Int32>(0, "id");
                    account.Expansion = result.Read<Byte>(0, "expansion");
                    account.SecurityFlags = result.Read<Byte>(0, "securityFlags");

                    DB.Realms.Execute("UPDATE accounts SET ip = ?, language = ? WHERE id = ?", account.IP, account.Language, account.Id);

                    byte[] username = UTF8Encoding.UTF8.GetBytes(result.Read<String>(0, "name").ToUpperInvariant());
                    byte[] password = UTF8Encoding.UTF8.GetBytes(result.Read<String>(0, "password").ToUpperInvariant());

                    // WoW 5.1.0.16357 (5.1.0a)
                    if (ClientBuild == 16357)
                    {
                        SecureRemotePassword.CalculateX(username, password);
                        byte[] buf = new byte[0x10];
                        NativeMethods.RAND_bytes(buf, 0x10);

                        logonChallenge.WriteUInt8((byte)AuthResults.WOW_SUCCESS);
                        logonChallenge.WriteBytes(SecureRemotePassword.B);
                        logonChallenge.WriteUInt8(1);
                        logonChallenge.WriteUInt8(SecureRemotePassword.g[0]);
                        logonChallenge.WriteUInt8(0x20);
                        logonChallenge.WriteBytes(SecureRemotePassword.N);
                        logonChallenge.WriteBytes(SecureRemotePassword.salt);
                        logonChallenge.WriteBytes(buf);

                        // Security flags
                        logonChallenge.WriteUInt8(account.SecurityFlags);

                        // Enable authenticator
                        if ((account.SecurityFlags & 4) != 0)
                            logonChallenge.WriteUInt8(1);
                    }
                }
                else
                    logonChallenge.WriteUInt8((byte)AuthResults.WOW_FAIL_UNKNOWN_ACCOUNT);

                Send(logonChallenge);
            }
        }
开发者ID:Krogonos,项目名称:Mop-5.1.0-Core,代码行数:68,代码来源:RealmClass.cs


注:本文中的Framework.Network.Packets.PacketReader.ReadUInt16方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。