Пример #1
0
        public CGConnect(byte[] bytes)
        {
            Stream stream = new MemoryStream(bytes);

            // read packet id
            this.ID = (PacketID)ReadUInt16(stream);

            // read size
            this.BodySize = ReadUInt32(stream);

            // read timestamp
            this.TimeStamp = ReadUInt32(stream);

            // check packet id
            if (this.ID == PacketID.CGConnect)
            {
                // read authkey
                this.AuthKey = ReadInt32(stream);

                // read PCType
                this.PCType = (PCType)stream.ReadByte();

                // read szPCName
                this.PCName = ReadString(stream);

                // read MacAddress
                this.MacAddress = ReadMacAddress(stream);

                _binit = true;
            }
        }
Пример #2
0
        public CLCreatePC(Stream stream)
        {
            // read size
            this.BodySize = ReadUInt32(stream);

            // read timestamp
            this.TimeStamp = ReadUInt32(stream);

            // read Name
            this.Name = ReadString(stream);

            // read Slot
            this.Slot = (Slot)stream.ReadByte();

            // read BitSet
            this.BitSet = (byte)stream.ReadByte();

            // read Colors
            this.ColorHair = ReadUInt16(stream);
            this.ColorSkin = ReadUInt16(stream);
            this.ColorShirt = ReadUInt16(stream);
            this.ColorShirt2 = ReadUInt16(stream);
            this.ColorJeans = ReadUInt16(stream);
            this.ColorJeans2 = ReadUInt16(stream);

            // read STR DEX & INT
            this.STR = ReadUInt16(stream);
            this.DEX = ReadUInt16(stream);
            this.INT = ReadUInt16(stream);

            // read PCType
            this.PCType = (PCType)stream.ReadByte();
        }
Пример #3
0
        public CLCreatePC(Stream stream)
        {
            // read size
            this.BodySize = ReadUInt32(stream);

            // read timestamp
            this.TimeStamp = ReadUInt32(stream);

            // read Name
            this.Name = ReadString(stream);

            // read Slot
            this.Slot = (Slot)stream.ReadByte();

            // read BitSet
            this.BitSet = (byte)stream.ReadByte();

            // read Colors
            this.ColorHair   = ReadUInt16(stream);
            this.ColorSkin   = ReadUInt16(stream);
            this.ColorShirt  = ReadUInt16(stream);
            this.ColorShirt2 = ReadUInt16(stream);
            this.ColorJeans  = ReadUInt16(stream);
            this.ColorJeans2 = ReadUInt16(stream);

            // read STR DEX & INT
            this.STR = ReadUInt16(stream);
            this.DEX = ReadUInt16(stream);
            this.INT = ReadUInt16(stream);

            // read PCType
            this.PCType = (PCType)stream.ReadByte();
        }
Пример #4
0
        public CGConnect(byte[] bytes)
        {
            Stream stream = new MemoryStream(bytes);

            // read packet id
            this.ID = (PacketID)ReadUInt16(stream);

            // read size
            this.BodySize = ReadUInt32(stream);

            // read timestamp
            this.TimeStamp = ReadUInt32(stream);

            // check packet id
            if (this.ID == PacketID.CGConnect)
            {
                // read authkey
                this.AuthKey = ReadInt32(stream);

                // read PCType
                this.PCType = (PCType)stream.ReadByte();

                // read szPCName
                this.PCName = ReadString(stream);

                // read MacAddress
                this.MacAddress = ReadMacAddress(stream);

                _binit = true;
            }
        }
Пример #5
0
        public CLSelectPC(Stream stream)
        {
            // read size
            this.BodySize = ReadUInt32(stream);

            // read timestamp
            this.TimeStamp = ReadUInt32(stream);

            // read name
            this.Name = ReadString(stream);

            // read pctype
            this.PCType = (PCType)stream.ReadByte();
        }
Пример #6
0
        public CLSelectPC(Stream stream)
        {
            // read size
            this.BodySize = ReadUInt32(stream);

            // read timestamp
            this.TimeStamp = ReadUInt32(stream);

            // read name
            this.Name = ReadString(stream);

            // read pctype
            this.PCType = (PCType)stream.ReadByte();
        }
Пример #7
0
        public static ErrorID CreatePC(string name, PCType race)
        {
            ErrorID result = ErrorID.None;

            // check if pc exists
            if (CheckPCExists(name))
            {
                return(ErrorID.AlreadyRegisteredId);
            }

            // build query string
            string cmdstr = String.Format("INSERT INTO PlayerChar (Name, Race) VALUES ('{0}', '{1}')", name, Enum.GetName(typeof(PCType), race));

            // execute query
            MySqlCommand cmd    = new MySqlCommand(cmdstr, mysqlconn);
            int          cmdres = cmd.ExecuteNonQuery();

            // return result
            return(result);
        }
Пример #8
0
        public static PCType GetPCType(string pcname)
        {
            PCType result = PCType.NONE;

            //build query string
            string cmdstr = String.Format(@"SELECT Race FROM PlayerChar WHERE Name = '{0}'", pcname);

            //execute query
            MySqlCommand    cmd        = new MySqlCommand(cmdstr, mysqlconn);
            MySqlDataReader datareader = cmd.ExecuteReader();

            //read data
            if (datareader.HasRows)
            {
                datareader.Read();

                result = (PCType)Enum.Parse(typeof(PCType), datareader.GetString(0));
            }

            datareader.Close();

            //return result
            return(result);
        }
Пример #9
0
        public static PCInfo[] GetPCInfoList(string userid)
        {
            PCInfo[] result = new PCInfo[3];

            // build query string
            string cmdstr = String.Format(@"SELECT SLOT1, SLOT2, SLOT3 FROM Player WHERE UserID = '{0}'", userid);

            // execute query
            MySqlCommand    cmd        = new MySqlCommand(cmdstr, mysqlconn);
            MySqlDataReader datareader = cmd.ExecuteReader();

            // read data
            if (datareader.HasRows)
            {
                datareader.Read();


                string name1 = null;
                string name2 = null;
                string name3 = null;

                if (!datareader.IsDBNull(0))
                {
                    name1 = datareader.GetString(0);
                }
                if (!datareader.IsDBNull(1))
                {
                    name2 = datareader.GetString(1);
                }
                if (!datareader.IsDBNull(2))
                {
                    name3 = datareader.GetString(2);
                }

                datareader.Close();

                if (name1 != null)
                {
                    PCType pctype = GetPCType(name1);
                    if (pctype == PCType.SLAYER)
                    {
                        PCSlayerInfo pc = GetPCSlayerInfo(name1);
                        pc.Slot = Slot.SLOT1;

                        result[0] = pc;
                    }
                    else if (pctype == PCType.VAMPIRE)
                    {
                        PCVampireInfo pc = GetPCVampireInfo(name1);
                        pc.Slot = Slot.SLOT1;

                        result[0] = pc;
                    }
                    else if (pctype == PCType.OUSTER)
                    {
                        PCOusterInfo pc = GetPCOusterInfo(name1);
                        pc.Slot = Slot.SLOT1;

                        result[0] = pc;
                    }
                }

                if (name2 != null)
                {
                    PCType pctype = GetPCType(name2);
                    if (pctype == PCType.SLAYER)
                    {
                        PCSlayerInfo pc = GetPCSlayerInfo(name2);
                        pc.Slot = Slot.SLOT2;

                        result[1] = pc;
                    }
                    else if (pctype == PCType.VAMPIRE)
                    {
                        PCVampireInfo pc = GetPCVampireInfo(name2);
                        pc.Slot = Slot.SLOT2;

                        result[1] = pc;
                    }
                    else if (pctype == PCType.OUSTER)
                    {
                        PCOusterInfo pc = GetPCOusterInfo(name2);
                        pc.Slot = Slot.SLOT2;

                        result[1] = pc;
                    }
                }

                if (name3 != null)
                {
                    PCType pctype = GetPCType(name3);
                    if (pctype == PCType.SLAYER)
                    {
                        PCSlayerInfo pc = GetPCSlayerInfo(name3);
                        pc.Slot = Slot.SLOT3;

                        result[2] = pc;
                    }
                    else if (pctype == PCType.VAMPIRE)
                    {
                        PCVampireInfo pc = GetPCVampireInfo(name3);
                        pc.Slot = Slot.SLOT3;

                        result[2] = pc;
                    }
                    else if (pctype == PCType.OUSTER)
                    {
                        PCOusterInfo pc = GetPCOusterInfo(name3);
                        pc.Slot = Slot.SLOT3;

                        result[2] = pc;
                    }
                }
            }

            // return result
            return(result);
        }
Пример #10
0
        public static ErrorID CreatePC(string name, PCType race)
        {
            ErrorID result = ErrorID.None;

            // check if pc exists
            if (CheckPCExists(name)) return ErrorID.AlreadyRegisteredId;

            // build query string
            string cmdstr = String.Format("INSERT INTO PlayerChar (Name, Race) VALUES ('{0}', '{1}')", name, Enum.GetName(typeof(PCType), race));

            // execute query
            MySqlCommand cmd = new MySqlCommand(cmdstr, mysqlconn);
            int cmdres = cmd.ExecuteNonQuery();

            // return result
            return result;
        }