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


C# PacketReader.Byte方法代码示例

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


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

示例1: GuildPermissions

        /////////////////////////////////////////////////////////////////////////
        //Guild Permissions
        /////////////////////////////////////////////////////////////////////////
        void GuildPermissions()
        {
            try
            {
                PacketReader Reader = new PacketReader(PacketInformation.buffer);
                Reader.Byte();
                int memberid = Reader.Int32();

                byte permissions = (byte)Reader.Int32();

                char[] bits = new char[8];

                for (int i = 0; i < 8; ++i) bits[i] = (char)0;
                bits = Convert.ToString(permissions, 2).ToCharArray();

                Reader.Close();

                // set the amount to the target player :)
                int targetindex = Character.Network.Guild.MembersInfo.FindIndex(i => i.MemberID == memberid);
                if (Character.Network.Guild.MembersInfo[targetindex].Online)
                {
                    Systems member = GetPlayerMainid(memberid);

                    // so here we can set chars right
                    member.Character.Network.Guild.joinRight = bits[4] == '1' ? true : false;
                    member.Character.Network.Guild.withdrawRight = bits[3] == '1' ? true : false;
                    member.Character.Network.Guild.unionRight = bits[2] == '1' ? true : false;
                    member.Character.Network.Guild.guildstorageRight = bits[0] == '1' ? true : false;
                    member.Character.Network.Guild.noticeeditRight = bits[1] == '1' ? true : false;
                }

                // set new amount to every guild members guild class
                foreach (int m in Character.Network.Guild.Members)
                {
                    int index = Character.Network.Guild.MembersInfo.FindIndex(i => i.MemberID == m);
                    if (Character.Network.Guild.MembersInfo[index].Online)
                    {
                        Systems sys = Helpers.GetInformation.GetPlayerMainid(m);

                        // here comes the messy way
                        Global.guild_player mygp = new Global.guild_player();
                        int myindex = 0;
                        foreach (Global.guild_player gp in sys.Character.Network.Guild.MembersInfo)
                        {
                            if (gp.MemberID == memberid)
                            {
                                mygp = gp; //
                                mygp.joinRight = bits[4] == '1' ? true : false;
                                mygp.withdrawRight = bits[3] == '1' ? true : false;
                                mygp.unionRight = bits[2] == '1' ? true : false;
                                mygp.guildstorageRight = bits[0] == '1' ? true : false;
                                mygp.noticeeditRight = bits[1] == '1' ? true : false;
                                break;
                            }
                            myindex++;
                        }
                        sys.Character.Network.Guild.MembersInfo[myindex] = mygp;
                    }
                }

                DB.query("UPDATE guild_members SET guild_perm_join='" + bits[4] + "',guild_perm_withdraw='" + bits[3] + "',guild_perm_union='" + bits[2] + "',guild_perm_storage='" + bits[0] + "',guild_perm_notice='" + bits[1] + "' WHERE guild_member_id='" + memberid + "'");
                Character.Network.Guild.Send(Packet.GuildUpdate(Character, 4, 0, permissions, 0));
            }
            catch (Exception ex)
            {
                Console.WriteLine("Guild permission error: {0}", ex);
                Log.Exception(ex);
            }
        }
开发者ID:ManhHaHY,项目名称:ClowenEmulationOpenSourceProject,代码行数:72,代码来源:Guild.cs

示例2: Connect

        public void Connect()
        {
            try
            {
                PacketReader Reader = new PacketReader(PacketInformation.buffer);

                if (Reader.Byte() == 18)
                {
                    string ID = Reader.Text();
                    string PW = Reader.Text();
                    byte ukn = Reader.Byte(); // 0xff
                    UInt16 ServerID = Reader.UInt16();
                    int lResult = 99;

                    //Console.WriteLine("Id:{0} Pass:{1} ServerID:{2}",ID,PW,ServerID);

                    SRX_Serverinfo SSI = GSList[ServerID];
                    if (SSI != null)
                    {
                        UInt16 myKey = 0;
                        string sReason = "";
                        lock (Program.IPCResultList)
                        {
                            myKey = Program.IPCNewId++;
                        }
                        byte[] rqp = Program.IPCServer.PacketRequestLogin(Program.IPCPort, ID, PW, myKey);
                        Servers.IPCenCode(ref rqp, SSI.code);
                        lock (Program.IPCResultList)
                        {
                            Program.IPCResultList.Add(myKey, new IPCItem());
                            Program.IPCResultList[myKey].resultCode = 0x8000;
                        }
                        Program.IPCServer.Send(SSI.ip, SSI.ipcport, rqp);
                        DateTime tOut = DateTime.Now.AddSeconds(30);
                        while ((tOut >= DateTime.Now) && (Program.IPCResultList[myKey].resultCode == 0x8000) && (client.clientSocket.Connected))
                        {
                            System.Threading.Thread.Sleep(10);
                        }
                        lResult = Program.IPCResultList[myKey].resultCode;
                        sReason = Program.IPCResultList[myKey].banReason;
                        lock (Program.IPCResultList)
                        {
                            Program.IPCResultList[myKey] = null;
                            Program.IPCResultList.Remove(myKey);
                        }
                        rqp = null;
                        //Console.WriteLine("Resultado de login: {0}",lResult);
                        switch (lResult)
                        {
                            case 0:
                                if (SSI.lan_wan)
                                {
                                    client.Send(ConnectSucces(SSI.wan, SSI.port, 1));
                                }
                                else
                                {
                                    client.Send(ConnectSucces(SSI.ip, SSI.port, 1));
                                }
                                return;
                            case 1:
                                if (WrongPassword < 3)
                                {
                                    client.Send(WrongInformation());
                                    WrongPassword++;
                                    return;
                                }
                                else
                                {
                                    client.Disconnect(PacketInformation.Client);
                                    return;
                                }
                            case 2:
                                client.Send(ServerIsFull());
                                client.Disconnect(PacketInformation.Client);
                                return;
                            case 3:
                                client.Send(AllreadyConnected());
                                client.Disconnect(PacketInformation.Client);
                                return;
                            case 4:
                                client.Send(BannedUser(sReason));
                                client.Disconnect(PacketInformation.Client);
                                return;
                            default:
                                if (lResult == 0x8000)
                                {
                                    Console.WriteLine("[IPC] Timeout");
                                }
                                else
                                {
                                    Console.WriteLine("[IPC] Result unknown {0}", lResult);
                                }
                                return;
                        }
                    }
                    else
                    {
                        Console.WriteLine("Fuck No fun.. SSI");
                    }
                }
//.........这里部分代码省略.........
开发者ID:CarlosX,项目名称:DarkEmu,代码行数:101,代码来源:Function_Connect.cs

示例3: HandleRegisterIcon

        void HandleRegisterIcon()
        {
            try
            {
                PacketReader reader = new PacketReader(PacketInformation.buffer);
                byte type = reader.Byte();
                int iconlenght = reader.Int32();
                string icon = reader.Text();
                reader.Close();

                string convertedicon = ConvertToHex(icon);
                //Save output to .dat file in hex formatting.

            }
            catch (Exception ex)
            {
                Console.WriteLine("Guild icon register error {0}", ex);
            }
        }
开发者ID:ManhHaHY,项目名称:ClowenEmulationOpenSourceProject,代码行数:19,代码来源:Guild.cs


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