コード例 #1
0
        public static void SendMailMessageRequest(IRealmClient client, RealmPacketIn packet)
        {
            packet.ReadInt32();
            short slotInq = packet.ReadInt16();
            Asda2InventoryType asda2InventoryType = (Asda2InventoryType)packet.ReadByte();
            ushort             num = packet.ReadUInt16();
            uint   sendedGold      = packet.ReadUInt32();
            string str             = packet.ReadAsdaString(20, Locale.Start);
            string subject         = packet.ReadAsdaString(32, Locale.Start);
            string message         = packet.ReadAsdaString(126, Locale.Start);

            if (!Asda2EncodingHelper.IsPrueEnglish(message))
            {
                client.ActiveCharacter.SendOnlyEnglishCharactersAllowed("message");
                Asda2MailHandler.SendMailMessageSendedResponse(client, MailMessageSendedStatus.WrongInformation,
                                                               (Asda2Item)null);
            }
            else if (!Asda2EncodingHelper.IsPrueEnglish(subject))
            {
                client.ActiveCharacter.SendOnlyEnglishCharactersAllowed("subject");
                Asda2MailHandler.SendMailMessageSendedResponse(client, MailMessageSendedStatus.WrongInformation,
                                                               (Asda2Item)null);
            }
            else
            {
                Asda2Item asda2Item = asda2InventoryType == Asda2InventoryType.Shop
          ? client.ActiveCharacter.Asda2Inventory.GetShopShopItem(slotInq)
          : client.ActiveCharacter.Asda2Inventory.GetRegularItem(slotInq);
                if (client.ActiveCharacter.Money < 1001U || client.ActiveCharacter.Money - 1000U < sendedGold)
                {
                    Asda2MailHandler.SendMailMessageSendedResponse(client, MailMessageSendedStatus.IncifitientGold,
                                                                   (Asda2Item)null);
                }
                else
                {
                    Character       chr    = World.GetCharacter(str, false);
                    CharacterRecord chrRec = chr == null?CharacterRecord.GetRecordByName(str) : chr.Record;

                    if (chrRec == null)
                    {
                        Asda2MailHandler.SendMailMessageSendedResponse(client,
                                                                       MailMessageSendedStatus.RecipentNotFounded, (Asda2Item)null);
                    }
                    else
                    {
                        Asda2Item sendItem = (Asda2Item)null;
                        if (asda2Item != null)
                        {
                            if (asda2Item.IsSoulbound)
                            {
                                Asda2MailHandler.SendMailMessageSendedResponse(client,
                                                                               MailMessageSendedStatus.YouCantSendThisItem, (Asda2Item)null);
                                return;
                            }

                            if (asda2Item.Amount < (int)num)
                            {
                                client.ActiveCharacter.YouAreFuckingCheater("Tying to mail wrong item amount", 50);
                                Asda2MailHandler.SendMailMessageSendedResponse(client,
                                                                               MailMessageSendedStatus.WrongInformation, (Asda2Item)null);
                                return;
                            }

                            asda2Item.ModAmount(-(num == (ushort)0 ? 1 : (int)num));
                            sendItem = Asda2Item.CreateItem(asda2Item.Template, (Character)null,
                                                            num == (ushort)0 ? 1 : (int)num);
                            sendItem.Record.SaveLater();
                        }

                        client.ActiveCharacter.SubtractMoney(sendedGold + 1000U);
                        Log.Create(Log.Types.ItemOperations, LogSourceType.Character, client.ActiveCharacter.EntryId)
                        .AddAttribute("source", 0.0, "send_mail").AddItemAttributes(sendItem, "sent")
                        .AddItemAttributes(asda2Item, "source").AddAttribute("gold", (double)sendedGold, "")
                        .AddAttribute("receiver", (double)chrRec.EntityLowId, str).Write();
                        ServerApp <WCell.RealmServer.RealmServer> .IOQueue.AddMessage((Action)(() =>
                        {
                            Asda2MailMessage record = new Asda2MailMessage(subject, message, sendItem, sendedGold,
                                                                           chrRec.EntityLowId, client.ActiveCharacter.Name);
                            record.CreateLater();
                            if (chr == null)
                            {
                                return;
                            }
                            chr.MailMessages.Add(record.Guid, record);
                            chr.SendMailMsg(string.Format("You recieve new message from {0}. Subject {1}.",
                                                          (object)client.ActiveCharacter.Name, (object)record.Subject));
                            Asda2MailHandler.SendYouHaveNewMailResponse(chr.Client, 1);
                        }));

                        Asda2MailHandler.SendMailMessageSendedResponse(client, MailMessageSendedStatus.Ok, asda2Item);
                    }
                }
            }
        }
コード例 #2
0
        [PacketHandler(RealmServerOpCode.SendMailMessage)]//6620
        public static void SendMailMessageRequest(IRealmClient client, RealmPacketIn packet)
        {
            var sendedItemId = packet.ReadInt32();                    //default : 37823Len : 4
            var slot         = packet.ReadInt16();                    //default : 23Len : 2
            var inv          = (Asda2InventoryType)packet.ReadByte(); //default : 2Len : 1
            var amount       = packet.ReadUInt16();                   //default : 0Len : 2
            var sendedGold   = packet.ReadUInt32();                   //default : 555Len : 4
            var targetName   = packet.ReadAsdaString(20, Locale.En);  //default : Len : 18
            var subject      = packet.ReadAsdaString(32, Locale.En);  //default : Len : 32
            var message      = packet.ReadAsdaString(126, Locale.En); //default : Len : 126

            /*var prueEng = Asda2EncodingHelper.IsPrueEnglish(message);
             * if (!prueEng)
             * {
             *  client.ActiveCharacter.SendOnlyEnglishCharactersAllowed("message");
             *  SendMailMessageSendedResponse(client, MailMessageSendedStatus.WrongInformation);
             *  return;
             * }
             * prueEng = Asda2EncodingHelper.IsPrueEnglish(subject);
             * if (!prueEng)
             * {
             *  client.ActiveCharacter.SendOnlyEnglishCharactersAllowed("subject");
             *  SendMailMessageSendedResponse(client, MailMessageSendedStatus.WrongInformation);
             *  return;
             * }*/
            var item = inv == Asda2InventoryType.Shop
                           ? client.ActiveCharacter.Asda2Inventory.GetShopShopItem(slot)
                           : client.ActiveCharacter.Asda2Inventory.GetRegularItem(slot);

            if (client.ActiveCharacter.Money < 1001 || client.ActiveCharacter.Money - 1000 < sendedGold)
            {
                SendMailMessageSendedResponse(client, MailMessageSendedStatus.IncifitientGold);
                return;
            }
            var chr    = World.GetCharacter(targetName, false);
            var chrRec = chr == null?CharacterRecord.GetRecordByName(targetName) : chr.Record;

            if (chrRec == null)
            {
                SendMailMessageSendedResponse(client, MailMessageSendedStatus.RecipentNotFounded);
                return;
            }
            Asda2Item sendItem = null;

            if (item != null)
            {
                if (item.IsSoulbound)
                {
                    //todo asda2 ItemMove log MailMessage
                    SendMailMessageSendedResponse(client, MailMessageSendedStatus.YouCantSendThisItem);
                    return;
                }
                if (item.Amount < amount)
                {
                    client.ActiveCharacter.YouAreFuckingCheater("Tying to mail wrong item amount", 50);
                    SendMailMessageSendedResponse(client, MailMessageSendedStatus.WrongInformation);
                    return;
                }
                if (RealmServer.IsPreparingShutdown || RealmServer.IsShuttingDown)
                {
                    SendMailMessageSendedResponse(client, MailMessageSendedStatus.YouCantSendThisItem);
                }
                if (client.ActiveCharacter.ChatBanned)
                {
                    client.ActiveCharacter.SendInfoMsg("you are banned");
                    return;
                }
                var par1   = item.Parametr1Type;
                var par11  = item.Parametr1Value;
                var par2   = item.Parametr2Type;
                var par22  = item.Parametr2Value;
                var par3   = item.Parametr3Type;
                var par33  = item.Parametr3Value;
                var par4   = item.Parametr4Type;
                var par44  = item.Parametr4Value;
                var par5   = item.Parametr5Type;
                var par55  = item.Parametr5Value;
                var Enchat = item.Enchant;
                var sowel1 = item.Soul1Id;
                var sowel2 = item.Soul2Id;
                var sowel3 = item.Soul3Id;
                var sowel4 = item.Soul4Id;
                var Dru    = item.Durability;
                item.ModAmount(-(amount == 0 ? 1 : amount));
                sendItem = Asda2Item.CreateItem(item.Template, null, amount == 0 ? 1 : amount);
                sendItem.Record.SaveLater();
                sendItem.Parametr1Type  = par1;
                sendItem.Parametr1Value = par11;
                sendItem.Parametr2Type  = par2;
                sendItem.Parametr2Value = par22;
                sendItem.Parametr3Type  = par3;
                sendItem.Parametr3Value = par33;
                sendItem.Parametr4Type  = par4;
                sendItem.Parametr4Value = par44;
                sendItem.Parametr5Type  = par5;
                sendItem.Parametr5Value = par55;
                sendItem.Enchant        = Enchat;
                sendItem.Soul1Id        = sowel1;
                sendItem.Soul2Id        = sowel2;
                sendItem.Soul3Id        = sowel3;
                sendItem.Soul4Id        = sowel4;
                sendItem.Durability     = Dru;
                sendItem.Record.SaveLater();
            }
            client.ActiveCharacter.SubtractMoney(sendedGold + 1000);
            var resLog = Log.Create(Log.Types.ItemOperations, LogSourceType.Character, client.ActiveCharacter.EntryId)
                         .AddAttribute("source", 0, "send_mail")
                         .AddItemAttributes(sendItem, "sent")
                         .AddItemAttributes(item, "source")
                         .AddAttribute("gold", sendedGold)
                         .AddAttribute("receiver", chrRec.EntityLowId, targetName)
                         .Write();

            RealmServer.IOQueue.AddMessage(() =>
            {
                var newMessage = new Asda2MailMessage(subject, message, sendItem, sendedGold, chrRec.EntityLowId, client.ActiveCharacter.Name);
                newMessage.CreateLater();
                if (chr != null)
                {
                    chr.MailMessages.Add(newMessage.Guid, newMessage);
                    chr.SendMailMsg(string.Format("You recieve new message from {0}. Subject {1}.", client.ActiveCharacter.Name, newMessage.Subject));
                    SendYouHaveNewMailResponse(chr.Client, 1);
                }
            });
            SendMailMessageSendedResponse(client, MailMessageSendedStatus.Ok, item);
            //client.ActiveCharacter.SubtractMoney(sendedGold + 1000);
        }