Example #1
0
        public static void ResponseChannelList(Client pClient, PacketReader pPacket)
        {
            var uid = pPacket.ReadUInt64();
            var type = pPacket.ReadInt32();

            if (!Enum.IsDefined(typeof(MMatchChannelType), (byte)type))
            {
                pClient.Disconnect();
                return;
            }

            List<MMatchChannel> channels = Program.mChannels.FindAll (c => c.nChannelType == (MMatchChannelType)type);
            if (channels == null || channels.Count == 0)
                return;

            PacketWriter pChannelList = new PacketWriter(Operation.ChannelList, CryptFlags.Encrypt);
            pChannelList.Write(channels.Count, 88);
            Int16 index = 0;

            foreach (MMatchChannel c in channels)
            {
                pChannelList.Write(c.uidChannel);
                pChannelList.Write(++index);
                pChannelList.Write((Int16)c.lClients.Count);
                pChannelList.Write((Int16)c.nMaxUsers);
                pChannelList.Write((Int16)c.nMinLevel);
                pChannelList.Write((Int16)c.nMaxLevel);
                pChannelList.Write((byte)c.nChannelType);
                pChannelList.Write(c.szName, 64);
                pChannelList.Write(false);
                pChannelList.Write((Int32)0);
            }
            pClient.Send(pChannelList);
        }
Example #2
0
        public static void ResponseChannelJoinFromName(Client pClient, PacketReader pPacket)
        {
            var uid = pPacket.ReadUInt64();
            var type = pPacket.ReadInt32();
            var name = pPacket.ReadString();

            if (!Enum.IsDefined(typeof(MMatchChannelType), (byte)type))
            {
                pClient.Disconnect();
                return;
            }

            MMatchChannel channel = Program.mChannels.Find(c => c.nChannelType == (MMatchChannelType)type && c.szName.Equals(name));
            if (channel == null)
            {
                channel = new MMatchChannel();
                channel.szName = name;
                channel.lClients = new List<Client>();
                channel.nChannelRule = MMatchChannelRule.Elite;
                channel.nChannelType = (MMatchChannelType)type;
                channel.nMaxLevel = 100;
                channel.nMinLevel = 0;
                channel.nMaxUsers = 200;
                channel.uidChannel = (UInt64)Program.mChannels.Count;
                lock (Program.mChannels)
                    Program.mChannels.Add(channel);
            }
            ChannelMgr.Join(pClient, channel);
        }
Example #3
0
        public static void ResponseChannelChat(Client pClient, PacketReader pPacket)
        {
            var uidChar = pPacket.ReadUInt64();
            var uidChan = pPacket.ReadUInt64();
            var message = pPacket.ReadString();

            if (uidChar != pClient.mClientUID || uidChan != pClient.mChannel.uidChannel || message.Length > 127)
            {
                pClient.Disconnect();
                return;
            }

            ChannelMgr.Chat(pClient, message);
        }
Example #4
0
        public static void ResponseChannelJoin(Client pClient, PacketReader pPacket)
        {
            var uidChar = pPacket.ReadUInt64();
            var uidChan = pPacket.ReadUInt64();

            if (uidChar != pClient.mClientUID)
            {
                pClient.Disconnect();
                return;
            }

            MMatchChannel channel = Program.mChannels.Find(c => c.uidChannel == uidChan);
            if (channel != null)
                ChannelMgr.Join(pClient, channel);
        }
Example #5
0
        public static void ProcessCharInfo(Client pClient, PacketReader pReader)
        {
            var index = pReader.ReadByte();

            if (index < 0 || index > 4)
            {
                pClient.Disconnect();
                return;
            }

            pClient.mCharacter.nCharNum = index;
            Database.GetCharacter(pClient.mAccount.nAID, index, pClient.mCharacter);
            pClient.mCharacter.nUGradeID = pClient.mAccount.nUGradeID;

            PacketWriter pCharInfoResponse = new PacketWriter(Operation.MatchResponseAccountCharInfo, CryptFlags.Encrypt);
            pCharInfoResponse.Write(index);
            pCharInfoResponse.Write(pClient.mCharacter);
            pClient.Send(pCharInfoResponse);
        }
Example #6
0
        public static void ResponsePlayerList(Client pClient, PacketReader pPacket)
        {
            var uidChar = pPacket.ReadUInt64();
            var uidChan = pPacket.ReadUInt64();
            var page = pPacket.ReadInt32();

            if (uidChar != pClient.mClientUID || uidChan != pClient.mChannel.uidChannel)
            {
                pClient.Disconnect();
                return;
            }

            pClient.mChannelPage = page;
            ChannelMgr.PlayerList(pClient);
        }
Example #7
0
        public static void ProcessTakeOffItem(Client pClient, PacketReader pPacket)
        {
            var uidChar = pPacket.ReadUInt64();
            var nItemSlot = pPacket.ReadInt32();

            if (!Enum.IsDefined(typeof(MMatchItemSlotType), nItemSlot))
            {
                pClient.Disconnect();
                return;
            }
            pClient.mCharacter.nEquippedItems[nItemSlot].nItemCID = 0;
            pClient.mCharacter.nEquippedItems[nItemSlot].nItemID = 0;
            Database.Execute(string.Format("UPDATE Character SET {0}={1} WHERE CID={2}", (MMatchItemSlotType)nItemSlot, 0, pClient.mCharacter.nCID));

            PacketWriter pResponseTakeOffItem = new PacketWriter(Operation.MatchResponseTakeOffItem, CryptFlags.Decrypt);
            pResponseTakeOffItem.Write((Int32)0);
            pClient.Send(pResponseTakeOffItem);

            ProcessCharItemList(pClient, null);
        }
Example #8
0
        public static void ProcessSelectChar(Client pClient, PacketReader pPacket)
        {
            var uid = pPacket.ReadUInt64();
            var index = pPacket.ReadInt32();

            if (uid != pClient.mClientUID || index < 0 || index > 4)
            {
                pClient.Disconnect();
                return;
            }

            PacketWriter pResponseSelectChar = new PacketWriter(Operation.MatchResponseSelectChar, CryptFlags.Encrypt);
            pResponseSelectChar.Write((Int32)0);
            pResponseSelectChar.Write(pClient.mCharacter);
            pResponseSelectChar.Write(1, 1);
            pResponseSelectChar.Write((byte)0x3E);
            pClient.Send(pResponseSelectChar);

            pClient.mClientFlags = PacketFlags.Character;
        }
Example #9
0
        public static void ProcessLogin(Client client, PacketReader pPacket)
        {
            /* @ARGS
             * UserID - string
             * Password - string
             * CommandVersion - int
             * Checksum - int
             * MD5 - Blob
             */

            var UserID = pPacket.ReadString();
            var Password = pPacket.ReadString();
            var CommandID = pPacket.ReadInt32();
            var Checksum = pPacket.ReadInt32();
            var totalSize = pPacket.ReadInt32();
            var blobSize = pPacket.ReadInt32();
            var count = pPacket.ReadInt32();
            Results result = Results.Accepted;

            if (blobSize > 32)
            {
                client.Disconnect();
                return;
            }

            if (!Program.mRegex.IsMatch(UserID) || !Program.mRegex.IsMatch(Password))
                result = Results.LoginIncorrectPassword;
            else
            {
                Log.Write("Login: {0} {1}", UserID, Password);
                Database.GetAccount(UserID, Password, ref client.mAccount);
                if (client.mAccount.nAID == 0)
                    result = Results.LoginIncorrectPassword;
                else if (client.mAccount.nUGradeID == MMatchUserGradeID.Banned || client.mAccount.nUGradeID == MMatchUserGradeID.Penalty)
                    result = Results.LoginBannedID;
                else if (client.mAccount.nAID > 0)
                    client.mClientFlags = PacketFlags.Login;
            }
            PacketWriter pLoginResponse = new PacketWriter(Operation.MatchLoginResponse, CryptFlags.Encrypt);
            pLoginResponse.Write((Int32)result);
            pLoginResponse.Write("Lol Emu Test");
            pLoginResponse.Write((byte)2);//Moode
            pLoginResponse.Write(UserID);
            pLoginResponse.Write((byte)client.mAccount.nUGradeID);
            pLoginResponse.Write((byte)client.mAccount.nPGradeID);
            pLoginResponse.Write(client.mClientUID);
            pLoginResponse.Write(false);
            pLoginResponse.Write(1, 20);
            pLoginResponse.WriteSkip(20);
            client.Send(pLoginResponse);

            if (client.mAccount.nUGradeID == MMatchUserGradeID.Banned || client.mAccount.nUGradeID == MMatchUserGradeID.Penalty)
                client. Disconnect();
        }
Example #10
0
        public static void ProcessEquipItem(Client pClient, PacketReader pPacket)
        {
            var uidChar = pPacket.ReadUInt64();
            var nItemLow = pPacket.ReadInt32();
            var nItemHigh = pPacket.ReadInt32();
            var nItemSlot = pPacket.ReadInt32();
            Results result = Results.Accepted;

            if (!Enum.IsDefined(typeof(MMatchItemSlotType), nItemSlot))
            {
                pClient.Disconnect();
                return;
            }

            Item nItem = pClient.mCharacter.nItems.Find(i => i.nItemCID == nItemHigh);
            if (nItem == null)
                result = Results.ShopItemNonExistant;
            else
            {
                pClient.mCharacter.nEquippedItems[nItemSlot].nItemCID = nItemHigh;
                pClient.mCharacter.nEquippedItems[nItemSlot].nItemID = nItem.nItemID;
                Database.Execute(string.Format("UPDATE Character SET {0}={1} WHERE CID={2}", (MMatchItemSlotType)nItemSlot, nItemHigh, pClient.mCharacter.nCID));
            }
            PacketWriter pResponseEquipItem = new PacketWriter(Operation.MatchResponseEquipItem, CryptFlags.Decrypt);
            pResponseEquipItem.Write((Int32)result);
            pClient.Send(pResponseEquipItem);

            ProcessCharItemList(pClient, pPacket);
        }
Example #11
0
        public static void ProcessDeleteChar(Client pClient, PacketReader pPacket)
        {
            var uid = pPacket.ReadUInt64();
            var index = pPacket.ReadInt32();
            var name = pPacket.ReadString();
            var result = Results.Accepted;

            if (uid != pClient.mClientUID || !Program.mRegex.IsMatch(name) || index < 0 || index > 4)
            {
                pClient.Disconnect();
                return;
            }

            var cid = Database.GetQuery(string.Format("SELECT CID FROM Character WHERE CharNum={0} AND AID={1}", index, pClient.mAccount.nAID));
            if (cid == 0) result = Results.CharacterDeleteDisabled;
            else
            {
                Database.Execute("DELETE FROM CharacterItem WHERE CID=" + cid);
                Database.Execute("DELETE FROM Character WHERE CID=" + cid);
                Database.UpdateIndexes(pClient.mAccount.nAID);
            }

            PacketWriter pResponseDeleteChar = new PacketWriter(Operation.MatchResponseDeleteChar, CryptFlags.Encrypt);
            pResponseDeleteChar.Write((Int32)result);
            pClient.Send(pResponseDeleteChar);
        }
Example #12
0
        public static void ProcessCreateChar(Client pClient, PacketReader pPacket)
        {
            var uid = pPacket.ReadUInt64();
            var index = pPacket.ReadInt32();
            var name = pPacket.ReadString();
            var sex = pPacket.ReadInt32();
            var hair = pPacket.ReadInt32();
            var face = pPacket.ReadInt32();
            var costume = pPacket.ReadInt32();
            var result = Results.Accepted;

            if (uid != pClient.mClientUID || index < 0 || index > 4 || sex < 0 || sex > 1)
            {
                pClient.Disconnect();
                return;
            }

            if (!Program.mRegex.IsMatch(name))
                result = Results.CharacterEnterName;
            else if (Database.GetQuery("SELECT COUNT(AID) FROM Character WHERE AID=" + pClient.mAccount.nAID) >= 4)
                result = Results.CharacterInvalidName;
            else if (Database.GetQuery("SELECT COUNT(Name) FROM Character WHERE Name='" + name + "'") > 0)
                result = Results.CharacterNameInUse;
            else if (!Database.CreateCharacter(pClient.mAccount.nAID, (byte)index, name, sex, hair, face, costume))
                result = Results.CharacterInvalidName;

            PacketWriter pResponseCreateChar = new PacketWriter(Operation.MatchResponseCreateChar, CryptFlags.Encrypt);
            pResponseCreateChar.Write((Int32)result);
            pResponseCreateChar.Write(name);
            pClient.Send(pResponseCreateChar);
        }