Beispiel #1
0
        public static void SendMailsListResponse(IRealmClient client, IEnumerable <Asda2MailMessage> mailMsgs)
        {
            var msgs = new Asda2MailMessage[10];
            var ii   = 0;

            foreach (var m in mailMsgs)
            {
                if (m.DeleteTime < DateTime.Now)
                {
                    client.ActiveCharacter.MailMessages.Remove(m.Guid);
                    m.DeleteLater();
                }
                else
                {
                    msgs[ii] = m;
                }
                ii++;
            }
            using (var packet = new RealmPacketOut(RealmServerOpCode.MailsList)) //6619
            {
                packet.WriteByte(0);                                             //{page}default value : 1 Len : 1
                for (int i = 0; i < 10; i += 1)
                {
                    var msg = msgs[i];
                    packet.WriteInt32((int)(msg == null?-1:msg.Guid));                                        //{guidRec}default value : 379808 Len : 4
                    packet.WriteByte(msg == null?0:msg.IsReaded?1:0);                                         //{taked}default value : 0 Len : 1
                    packet.WriteInt32((int)(msg == null ? 0 : (msg.DeleteTime - DateTime.Now).TotalMinutes)); //{timeTodeletemins}default value : 10061 Len : 4
                    packet.WriteFixedAsciiString(msg == null?"":msg.SenderName, 20);                          //{senderName}default value :  Len : 20
                    packet.WriteFixedAsciiString(msg == null ? "" : msg.Subject, 32);                         //{title}default value :  Len : 32
                }
                client.Send(packet, addEnd: true);
            }
        }
Beispiel #2
0
 public static void SendMailMessageInfoResponse(IRealmClient client, ShowMailMessageStatus status,
                                                Asda2MailMessage msg)
 {
     using (RealmPacketOut packet = new RealmPacketOut(RealmServerOpCode.MailMessageInfo))
     {
         packet.WriteByte((byte)status);
         packet.WriteInt32(msg == null ? 0 : (int)msg.Guid);
         packet.WriteInt32(msg == null ? 0U : msg.Gold);
         Asda2InventoryHandler.WriteItemInfoToPacket(packet, msg == null ? (Asda2Item)null : msg.Item, true);
         packet.WriteFixedAsciiString(msg == null ? "" : msg.Body, 128, Locale.Start);
         client.Send(packet, true);
     }
 }
Beispiel #3
0
        public static void DeleteMailMessageRequest(IRealmClient client, RealmPacketIn packet)
        {
            int msgGuid = packet.ReadInt32();

            if (client.ActiveCharacter.MailMessages.ContainsKey((long)msgGuid))
            {
                Asda2MailMessage mailMessage = client.ActiveCharacter.MailMessages[(long)msgGuid];
                if (mailMessage != null)
                {
                    client.ActiveCharacter.MailMessages.Remove((long)msgGuid);
                    mailMessage.DeleteLater();
                }
            }

            Asda2MailHandler.SendMailMessageDeletedResponse(client, msgGuid);
        }
Beispiel #4
0
        public static void TakeMailItemRequest(IRealmClient client, RealmPacketIn packet)
        {
            int num1 = packet.ReadInt32();

            if (!client.ActiveCharacter.MailMessages.ContainsKey((long)num1))
            {
                client.ActiveCharacter.YouAreFuckingCheater("Try to take not existing mail message.", 50);
                Asda2MailHandler.SendMailItemTakedResponse(client, Asda2MailItemTakedStatus.WrongInfo,
                                                           (Asda2Item)null);
            }
            else
            {
                Asda2MailMessage mailMessage = client.ActiveCharacter.MailMessages[(long)num1];
                if (mailMessage == null)
                {
                    Asda2MailHandler.SendMailItemTakedResponse(client, Asda2MailItemTakedStatus.WrongInfo,
                                                               (Asda2Item)null);
                }
                else
                {
                    Asda2Item itemToCopyStats = mailMessage.Item;
                    Asda2Item asda2Item       = (Asda2Item)null;
                    if (itemToCopyStats != null)
                    {
                        int num2 = (int)client.ActiveCharacter.Asda2Inventory.TryAdd(itemToCopyStats.ItemId,
                                                                                     itemToCopyStats.Amount, true, ref asda2Item, new Asda2InventoryType?(), itemToCopyStats);
                        Log.Create(Log.Types.ItemOperations, LogSourceType.Character, client.ActiveCharacter.EntryId)
                        .AddAttribute("source", 0.0, "taked_from_mail")
                        .AddAttribute("message_id", (double)mailMessage.Guid, "").AddItemAttributes(asda2Item, "")
                        .Write();
                        mailMessage.ItemGuid = 0L;
                        mailMessage.Item     = (Asda2Item)null;
                        itemToCopyStats.Destroy();
                    }

                    client.ActiveCharacter.AddMoney(mailMessage.Gold);
                    mailMessage.Gold = 0U;
                    mailMessage.UpdateLater();
                    Asda2MailHandler.SendMailItemTakedResponse(client, Asda2MailItemTakedStatus.Ok, asda2Item);
                    client.ActiveCharacter.SendMoneyUpdate();
                }
            }
        }
Beispiel #5
0
        public static void ShowMailMsgRequest(IRealmClient client, RealmPacketIn packet)
        {
            int num = packet.ReadInt32();

            if (!client.ActiveCharacter.MailMessages.ContainsKey((long)num))
            {
                client.ActiveCharacter.YouAreFuckingCheater("Try to view not existing mail message.", 30);
                Asda2MailHandler.SendMailMessageInfoResponse(client, ShowMailMessageStatus.Fail,
                                                             (Asda2MailMessage)null);
            }
            else
            {
                Asda2MailMessage mailMessage = client.ActiveCharacter.MailMessages[(long)num];
                if (mailMessage != null)
                {
                    mailMessage.IsReaded = true;
                }
                Asda2MailHandler.SendMailMessageInfoResponse(client, ShowMailMessageStatus.Ok, mailMessage);
            }
        }
Beispiel #6
0
        public static void SendMailsListResponse(IRealmClient client, IEnumerable <Asda2MailMessage> mailMsgs)
        {
            Asda2MailMessage[] asda2MailMessageArray = new Asda2MailMessage[10];
            int index1 = 0;

            foreach (Asda2MailMessage mailMsg in mailMsgs)
            {
                if (mailMsg.DeleteTime < DateTime.Now)
                {
                    client.ActiveCharacter.MailMessages.Remove(mailMsg.Guid);
                    mailMsg.DeleteLater();
                }
                else
                {
                    asda2MailMessageArray[index1] = mailMsg;
                }

                ++index1;
            }

            using (RealmPacketOut packet = new RealmPacketOut(RealmServerOpCode.MailsList))
            {
                packet.WriteByte(0);
                for (int index2 = 0; index2 < 10; ++index2)
                {
                    Asda2MailMessage asda2MailMessage = asda2MailMessageArray[index2];
                    packet.WriteInt32(asda2MailMessage == null ? -1 : (int)asda2MailMessage.Guid);
                    packet.WriteByte(asda2MailMessage == null ? 0 : (asda2MailMessage.IsReaded ? 1 : 0));
                    packet.WriteInt32(asda2MailMessage == null
            ? 0
            : (int)(asda2MailMessage.DeleteTime - DateTime.Now).TotalMinutes);
                    packet.WriteFixedAsciiString(asda2MailMessage == null ? "" : asda2MailMessage.SenderName, 20,
                                                 Locale.Start);
                    packet.WriteFixedAsciiString(asda2MailMessage == null ? "" : asda2MailMessage.Subject, 32,
                                                 Locale.Start);
                }

                client.Send(packet, true);
            }
        }
Beispiel #7
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);
                    }
                }
            }
        }
Beispiel #8
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);
        }
Beispiel #9
0
 public static void SendMailMessageInfoResponse(IRealmClient client, ShowMailMessageStatus status, Asda2MailMessage msg)
 {
     using (var packet = new RealmPacketOut(RealmServerOpCode.MailMessageInfo)) //6623
     {
         packet.WriteByte((byte)status);                                        //{status}default value : 1 Len : 1
         packet.WriteInt32((int)(msg == null?0:msg.Guid));                      //{msgGuid}default value : 379808 Len : 4
         packet.WriteInt32(msg == null ? 0 : msg.Gold);                         //{goldAmount}default value : 5600 Len : 4
         Asda2InventoryHandler.WriteItemInfoToPacket(packet, msg == null ? null:msg.Item, true);
         packet.WriteFixedAsciiString(msg == null ?"":msg.Body, 128);           //{message}default value :  Len : 128
         client.Send(packet, addEnd: true);
     }
 }