Beispiel #1
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);
        }
Beispiel #2
0
 public static void ProcessLiveCheck(Client pClient, PacketReader pPacket)
 {
     var timeStamp = pPacket.ReadInt32();
     PacketWriter pResponseLiveCheck = new PacketWriter(Operation.MatchAgentResponseLiveCheck, CryptFlags.Encrypt);
     pResponseLiveCheck.Write(timeStamp);
     pClient.Send(pResponseLiveCheck);
 }
Beispiel #3
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);
        }
Beispiel #4
0
        public static void ProcessBuyItem(Client pClient, PacketReader pPacket)
        {
            var uid = pPacket.ReadUInt64();
            var itemid = pPacket.ReadInt32();
            Item item = null;
            var result = Results.Accepted;

            item = Program.mItems.Find(i => i.nItemID == itemid);
            if (item == null)
                result = Results.ShopItemNonExistant;
            else if (item.nPrice > pClient.mCharacter.nBP)
                result = Results.ShopInsufficientBounty;
            else
            {
                Item temp = new Item();
                temp.nItemID = item.nItemID;
                temp.nLevel = item.nLevel;
                temp.nMaxWT = item.nMaxWT;
                temp.nWeight = item.nWeight;
                temp.nPrice = item.nPrice;
                Database.Execute(string.Format("INSERT INTO CharacterItem (CID,ItemID,RegDate) VALUES ({0},{1},GetDate())", pClient.mCharacter.nCID, item.nItemID));
                temp.nItemCID = Database.GetIdentity(string.Format("select @@identity"));
                pClient.mCharacter.nItems.Add(temp);

                pClient.mCharacter.nBP -= item.nPrice;
                Database.Execute(string.Format("UPDATE Character SET BP={0} WHERE CID={1}", pClient.mCharacter.nBP, pClient.mCharacter.nCID));
            }

            PacketWriter pResponseBuyItem = new PacketWriter(Operation.MatchResponseBuyItem, CryptFlags.Decrypt);
            pResponseBuyItem.Write((Int32)result);
            pClient.Send(pResponseBuyItem);
        }
Beispiel #5
0
        public static void ProcessGameTimeSync(Client client, PacketReader pPacket)
        {
            var nTime = pPacket.ReadInt32();

            PacketWriter packet = new PacketWriter(Operation.GameResponseTimeSync, CryptFlags.Encrypt);
            packet.Write(nTime);
            packet.Write(Program.timeGetTime());
            client.Send(packet);
        }
Beispiel #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);
        }
Beispiel #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);
        }
Beispiel #8
0
        public static void ProcessSellItem(Client pClient, PacketReader pPacket)
        {
            var uidChar = pPacket.ReadUInt64();
            var low = pPacket.ReadInt32();
            var high = pPacket.ReadInt32();
            var result = Results.Accepted;

            var item = pClient.mCharacter.nItems.Find (i => i.nItemCID == high);
            if (item == null)
                result = Results.ShopItemNonExistant;
            else
            {
                Database.Execute(string.Format("DELETE FROM CharacterItem WHERE CIID={0}", item.nItemCID));
                pClient.mCharacter.nBP += item.nPrice;
                Database.Execute(string.Format("UPDATE Character SET BP={0} WHERE CID={1}", pClient.mCharacter.nBP, pClient.mCharacter.nCID));
                pClient.mCharacter.nItems.Remove(item);
            }

            PacketWriter pResponseSellItem = new PacketWriter(Operation.MatchResponseSellItem, CryptFlags.Decrypt);
            pResponseSellItem.Write((Int32)result);
            pClient.Send(pResponseSellItem);
        }
Beispiel #9
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;
        }
Beispiel #10
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();
        }
Beispiel #11
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);
        }
Beispiel #12
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);
        }
Beispiel #13
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);
        }