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


C# Packet.WriteUInt方法代码示例

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


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

示例1: ChangeSlot

        public static void ChangeSlot(Packet packet, Player player)
        {
            uint ItmID1 = packet.ReadUInt( );
            uint ItmID2 = packet.ReadUInt( );
            byte Slot = packet.ReadByte( );
            byte Check = packet.ReadByte( );

            byte Error = 1;

            if (Check == 0x01)
            {
                #region Parse
                if (ItmID2 != 0)
                {
                    CharItem Itm1 = player.CharData.GeneralItems.FindID(ItmID1);
                    CharItem Itm2 = player.CharData.GeneralItems.FindID(ItmID2);
                    if (Itm1.Slot == -1 || Itm2.Slot == -1)
                    {
                        Error = 0;
                    }
                    else
                    {
                        Itm1.Slot += Itm2.Slot;
                        Itm2.Slot = Itm1.Slot - Itm2.Slot;
                        Itm1.Slot -= Itm2.Slot;
                    }
                }
                else
                {
                    CharItem Itm1 = player.CharData.GeneralItems.FindID(ItmID1);
                    if (Itm1.Slot == -1)
                    {
                        Error = 0;
                    }
                    else
                    {
                        Itm1.Slot = Slot;
                    }
                }
                #endregion

                #region Response
                Packet Response = new Packet(0x0454);
                Response.WriteUInt(ItmID1);
                Response.WriteUInt(ItmID2);
                Response.WriteByte(Slot);
                Response.WriteByte(1);
                Response.WriteByte(Error);
                player.Sock.Send(Response);
                #endregion
            }
        }
开发者ID:acid1789,项目名称:DECO,代码行数:52,代码来源:ItemControl.cs

示例2: Expressing

        public static void Expressing(Packet packet, Player player)
        {
            byte Type = packet.ReadByte( );

            #region Response
            Packet Response = new Packet(0x0230);
            Response.WriteUInt(1); // Char ID ( if the char is the same it will be 1)
            Response.WriteByte(Type);
            player.Sock.Send(Response);
            #endregion

            #region Others
            Packet Others = new Packet(0x0230);
            Others.WriteUInt(player.ID);
            Others.WriteByte(Type);

            int MapIndex = Maps.MapsData.Find(player.CharData.Map);
            if (MapIndex != -1)
            {
                foreach (Player x in Maps.MapsData[MapIndex].Players)
                {
                    if (x.ID != player.ID)
                        x.Sock.Send(Others);
                }
            }
            #endregion
        }
开发者ID:acid1789,项目名称:DECO,代码行数:27,代码来源:Communication.cs

示例3: StatChange

        public static Packet StatChange(Character pCharacter, uint pFlag, short pValue, bool pSelf = false)
        {
            Packet p = new Packet();

            p.WriteShort((short)SendOpcodes.Stats_Update);
            p.WriteBool(pSelf);
            p.WriteUInt(pFlag);
            p.WriteShort(pValue);

            return p;
        }
开发者ID:DragonNeos,项目名称:serenity-maple,代码行数:11,代码来源:CharacterStatsPacket.cs

示例4: RideHorse

        public static void RideHorse(Packet packet, Player player)
        {
            Packet Response = new Packet(0x0472);
            Response.WriteByte(1);
            Response.WriteUInt(1);
            Response.WriteUInt(1);
            player.Sock.Send(Response);

            int MapIndex = Maps.MapsData.Find(player.CharData.Map);
            if (MapIndex != -1)
            {
                foreach (Player x in Maps.MapsData[MapIndex].Players)
                {
                    if (x.ID == player.ID)
                        continue;

                    Packet Others = new Packet(0x0472);
                    Others.WriteByte(1);
                    Others.WriteUInt(0);
                    Others.WriteUInt(player.ID);
                    x.Sock.Send(Response);
                }
            }
        }
开发者ID:acid1789,项目名称:DECO,代码行数:24,代码来源:Movement.cs

示例5: SpawnNPC

        public static Packet SpawnNPC(Life pNPC)
        {
            Packet p = new Packet();

            p.WriteShort((short)SendOpcodes.NPC_Spawn);
            p.WriteUInt(pNPC.SpawnID);
            p.WriteInt(pNPC.ID);
            p.WriteShort(pNPC.X);
            p.WriteShort(pNPC.Cy);
            p.WriteByte((byte)(pNPC.FacesLeft ? 0 : 1));
            p.WriteUShort(pNPC.Foothold);
            p.WriteShort(pNPC.Rx0);
            p.WriteShort(pNPC.Rx1);
            p.WriteByte((byte)(pNPC.Hide == 0 ? 1 : 0));

            return p;
        }
开发者ID:DragonNeos,项目名称:serenity-maple,代码行数:17,代码来源:MapPacket.cs

示例6: Handshake


//.........这里部分代码省略.........
                    m_security_flags = flags;
                }

                if (flags.blowfish == 1)
                {
                    m_initial_blowfish_key = packet_data.ReadUInt64();
                    m_blowfish.Initialize(BitConverter.GetBytes(m_initial_blowfish_key));
                }

                if (flags.security_bytes == 1)
                {
                    m_seed_count = packet_data.ReadUInt32();
                    m_crc_seed = packet_data.ReadUInt32();
                    SetupCountByte(m_seed_count);
                }

                if (flags.handshake == 1)
                {
                    m_handshake_blowfish_key = packet_data.ReadUInt64();
                    m_value_g = packet_data.ReadUInt32();
                    m_value_p = packet_data.ReadUInt32();
                    m_value_A = packet_data.ReadUInt32();

                    m_value_x = NextUInt32() & 0x7FFFFFFF;

                    m_value_B = G_pow_X_mod_P(m_value_p, m_value_x, m_value_g);
                    m_value_K = G_pow_X_mod_P(m_value_p, m_value_x, m_value_A);

                    ulong key_array = MAKELONGLONG_(m_value_A, m_value_B);
                    KeyTransformValue(ref key_array, m_value_K, (byte)(LOBYTE_(LOWORD_(m_value_K)) & 0x03));
                    m_blowfish.Initialize(BitConverter.GetBytes(key_array));

                    m_client_key = MAKELONGLONG_(m_value_B, m_value_A);
                    KeyTransformValue(ref m_client_key, m_value_K, (byte)(LOBYTE_(LOWORD_(m_value_B)) & 0x07));
                    byte[] tmp_bytes = m_blowfish.Encode(BitConverter.GetBytes(m_client_key));
                    m_client_key = BitConverter.ToUInt64(tmp_bytes, 0);
                }

                if (flags.handshake_response == 1)
                {
                    m_challenge_key = packet_data.ReadUInt64();

                    ulong expected_challenge_key = MAKELONGLONG_(m_value_A, m_value_B);
                    KeyTransformValue(ref expected_challenge_key, m_value_K, (byte)(LOBYTE_(LOWORD_(m_value_A)) & 0x07));
                    byte[] tmp_bytes = m_blowfish.Encode(BitConverter.GetBytes(expected_challenge_key));
                    expected_challenge_key = BitConverter.ToUInt64(tmp_bytes, 0);

                    if (m_challenge_key != expected_challenge_key)
                    {
                        throw (new Exception("[SecurityAPI::Handshake] Server signature error."));
                    }

                    KeyTransformValue(ref m_handshake_blowfish_key, m_value_K, 0x3);
                    m_blowfish.Initialize(BitConverter.GetBytes(m_handshake_blowfish_key));
                }

                // Generate the outgoing packet now
                if (flags.handshake == 1 && flags.handshake_response == 0)
                {
                    // Check to see if we already started a handshake
                    if (m_started_handshake || m_accepted_handshake)
                    {
                        throw (new Exception("[SecurityAPI::Handshake] Received an illogical handshake packet (duplicate 0x5000)."));
                    }

                    // Handshake challenge
                    Packet response = new Packet(0x5000);
                    response.WriteUInt(m_value_B);
                    response.WriteULong(m_client_key);
                    m_outgoing_packets.Insert(0, response);

                    // The handshake has started
                    m_started_handshake = true;
                }
                else
                {
                    // Check to see if we already accepted a handshake
                    if (m_accepted_handshake)
                    {
                        throw (new Exception("[SecurityAPI::Handshake] Received an illogical handshake packet (duplicate 0x5000)."));
                    }

                    // Handshake accepted
                    Packet response1 = new Packet(0x9000);

                    // Identify
                    Packet response2 = new Packet(0x2001, true, false);
                    response2.WriteAscii(m_identity_name);
                    response2.WriteByte(m_identity_flag);

                    // Insert at the front, we want 0x9000 first, then 0x2001
                    m_outgoing_packets.Insert(0, response2);
                    m_outgoing_packets.Insert(0, response1);

                    // Mark the handshake as accepted now
                    m_started_handshake = true;
                    m_accepted_handshake = true;
                }
            }
        }
开发者ID:GoneUp,项目名称:ModuleFilter,代码行数:101,代码来源:SecurityManager.cs

示例7: GenerateSecurity

        private void GenerateSecurity(SecurityFlags flags)
        {
            m_security_flag = FromSecurityFlags(flags);
            m_security_flags = flags;
            m_client_security = true;

            Packet response = new Packet(0x5000);

            response.WriteByte(m_security_flag);

            if (m_security_flags.blowfish == 1)
            {
                m_initial_blowfish_key = NextUInt64();

                m_blowfish.Initialize(BitConverter.GetBytes(m_initial_blowfish_key));

                response.WriteULong(m_initial_blowfish_key);
            }
            if (m_security_flags.security_bytes == 1)
            {
                m_seed_count = NextUInt8();
                SetupCountByte(m_seed_count);
                m_crc_seed = NextUInt8();

                response.WriteUInt(m_seed_count);
                response.WriteUInt(m_crc_seed);
            }
            if (m_security_flags.handshake == 1)
            {
                m_handshake_blowfish_key = NextUInt64();
                m_value_x = NextUInt32() & 0x7FFFFFFF;
                m_value_g = NextUInt32() & 0x7FFFFFFF;
                m_value_p = NextUInt32() & 0x7FFFFFFF;
                m_value_A = G_pow_X_mod_P(m_value_p, m_value_x, m_value_g);

                response.WriteULong(m_handshake_blowfish_key);
                response.WriteUInt(m_value_g);
                response.WriteUInt(m_value_p);
                response.WriteUInt(m_value_A);
            }

            m_outgoing_packets.Add(response);
        }
开发者ID:GoneUp,项目名称:ModuleFilter,代码行数:43,代码来源:SecurityManager.cs

示例8: Equip

        public static void Equip(Packet packet, Player player)
        {
            uint ItemID = packet.ReadUInt( );
            byte Slot = packet.ReadByte( );

            byte Error = 1;

            #region Parse
            CharItem Item = player.CharData.GeneralItems.FindID(ItemID);
            CharItem ClothesItem = player.CharData.ClothesItems.FindSlot(Slot);
            if (ClothesItem.Slot == -1)
            {
                if (Item.Slot != -1)
                {
                    player.CharData.GeneralItems.Remove(Item);
                    Item.Slot = Slot;
                    player.CharData.ClothesItems.Add(Item);
                }
                else
                {
                    Item = player.CharData.RidingItems.FindID(ItemID);
                    if (Item.Slot != -1)
                    {
                        player.CharData.RidingItems.Remove(Item);
                        Item.Slot = Slot;
                        player.CharData.ClothesItems.Add(Item);
                    }
                    else
                    {
                        Error = 2;
                    }
                }
            }
            else
            {
                if (Item.Slot != -1)
                {
                    player.CharData.GeneralItems.Remove(Item);
                    player.CharData.GeneralItems.Add(ClothesItem);
                    player.CharData.GeneralItems.Last( ).Slot = Item.Slot;

                    player.CharData.ClothesItems.Remove(ClothesItem);
                    player.CharData.ClothesItems.Add(Item);
                    player.CharData.ClothesItems.Last( ).Slot = Slot;
                }
                else
                {
                    Item = player.CharData.RidingItems.FindID(ItemID);
                    if (Item.Slot != -1)
                    {
                        player.CharData.RidingItems.Remove(Item);
                        player.CharData.RidingItems.Add(ClothesItem);
                        player.CharData.RidingItems.Last( ).Slot = Item.Slot;

                        player.CharData.ClothesItems.Remove(ClothesItem);
                        player.CharData.ClothesItems.Add(Item);
                        player.CharData.ClothesItems.Last( ).Slot = Slot;
                    }
                    else
                    {
                        Error = 2;
                    }
                }
            }
            #endregion

            if (ClothesItem.Slot == -1)
            {
                #region Response (Equip)
                Packet Response = new Packet(0x0412);
                Response.WriteUInt(ItemID);
                Response.WriteByte(Slot);
                Response.WriteByte(Error);
                Response.WriteUInt(10);
                Response.WriteUShort(20);
                Response.WriteUShort(player.CharData.PhysicalDef); // Pyshical Defense
                Response.WriteUShort(player.CharData.MagicalDef); // Magical Defense
                Response.WriteByte(30);
                Response.WriteUShort(player.CharData.AbbillityMin); // AbbillityMin
                Response.WriteUShort(player.CharData.AbbillityMax); // AbbillityMax
                Response.WriteByte(40);
                Response.WriteByte(50);
                Response.WriteUShort(player.CharData.Vitality); // Vitality
                Response.WriteUShort(player.CharData.Sympathy); // Sympathy
                Response.WriteUShort(player.CharData.Intelligence); // Intelligence
                Response.WriteUShort(60);
                Response.WriteUShort(player.CharData.Dexterity); // Dexterity

                Response.WriteUInt(player.CharData.MaxHP); // Max HP
                Response.WriteUInt(70);
                Response.WriteUInt(player.CharData.MaxMP); // Max MP
                Response.WriteByte(80);
                player.Sock.Send(Response);
                #endregion
            }
            else
            {
                #region Response (Change Equip)
                Packet Response = new Packet(0x0413);
                Response.WriteUInt(ClothesItem.ID);
//.........这里部分代码省略.........
开发者ID:acid1789,项目名称:DECO,代码行数:101,代码来源:ItemControl.cs

示例9: RemoveRoom

        public static void RemoveRoom(PVPRoom room)
        {
            #region Packet
            foreach (Player x in Players)
            {
                Packet Others = new Packet(0x0811);
                Others.WriteUInt(room.ID);
                x.Sock.Send(Others);
            }
            #endregion

            Rooms.Remove(room);
        }
开发者ID:acid1789,项目名称:DECO,代码行数:13,代码来源:PVP.cs

示例10: Open

        public static void Open(Packet packet, Player player)
        {
            if (packet.ReadByte() == 1)
            {
                player.CharData.isInPVP = true;
                AddPlayer(player);

                int MapIndex = Maps.MapsData.Find(player.CharData.Map);
                if (MapIndex != -1)
                    Maps.RemovePlayer(player, Maps.MapsData[MapIndex]);

                #region Packet
                Packet PVPInfo = new Packet(0x0804);

                PVPInfo.WriteUShort((ushort)Rooms.Count);
                PVPInfo.WriteUShort((ushort)Players.Count);

                foreach (PVPRoom x in Rooms)
                {

                    ushort Info = (ushort)((x.Password == "" ? 0 : 1) +
                        ((int)x.Mode << 1) +
                        (x.Players.Count << 7) +
                        (x.MaxParticipant << 11) +
                        ((x.isInGame ? 1 : 0) << 15));

                    PVPInfo.WriteUInt(x.ID);
                    PVPInfo.WriteString(x.Name, 40);
                    PVPInfo.WriteUShort(Info);
                    PVPInfo.WriteByte(1);
                }

                foreach (Player x in Players)
                    PVPInfo.WriteString(x.CharName, 17);

                player.Sock.Send(PVPInfo);
                #endregion
            }
        }
开发者ID:acid1789,项目名称:DECO,代码行数:39,代码来源:PVP.cs

示例11: ExitRoom

        public static void ExitRoom(Packet packet, Player player)
        {
            uint ID = packet.ReadUInt();

            player.CharData.PVPRoom.RemovePlayer(player);
            player.CharData.PVPRoom = null;
            PVP.AddPlayer(player);

            #region Packet
            Packet PVPInfo = new Packet(0x0804);

            PVPInfo.WriteUShort((ushort)Rooms.Count);
            PVPInfo.WriteUShort((ushort)Players.Count);

            foreach (PVPRoom x in Rooms)
            {
                ushort Info = (ushort)((x.Password == "" ? 0 : 1) +
                        ((int)x.Mode << 1) +
                        (x.Players.Count << 7) +
                        (x.MaxParticipant << 11) +
                        ((x.isInGame ? 1 : 0) << 15));

                PVPInfo.WriteUInt(x.ID);
                PVPInfo.WriteString(x.Name, 40);
                PVPInfo.WriteUShort(Info);
                PVPInfo.WriteByte(1);
            }

            foreach (Player x in Players)
                PVPInfo.WriteString(x.CharName, 17);

            player.Sock.Send(PVPInfo);
            #endregion
        }
开发者ID:acid1789,项目名称:DECO,代码行数:34,代码来源:PVP.cs

示例12: AddRoom

        public static void AddRoom(PVPRoom room)
        {
            Rooms.Add(room);

            #region Packet
            foreach (Player x in Players)
            {
                ushort OthersInfo = (ushort)((room.Password == "" ? 0 : 1) +
                    ((int)room.Mode << 1) +
                    (room.Players.Count << 7) +
                    (room.MaxParticipant << 11) +
                    ((room.isInGame ? 1 : 0) << 15));

                Packet Others = new Packet(0x0810);
                Others.WriteUInt(room.ID);
                Others.WriteString(room.Name, 40);
                Others.WriteUShort(OthersInfo);
                x.Sock.Send(Others);
            }
            #endregion
        }
开发者ID:acid1789,项目名称:DECO,代码行数:21,代码来源:PVP.cs


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