Esempio n. 1
0
 public static void SaveMail(Character_mail mailItem)
 {
     Database.SaveObject(mailItem);
 }
Esempio n. 2
0
 public void AddMail(Character_mail Mail)
 {
     _Mails.Add(Mail);
     SendMailCounts();
 }
Esempio n. 3
0
        public void BuildMail(PacketIn packet)
        {
            Player Plr = GetPlayer();
            if (Plr == null)
                return;

            if (nextSend >= TCPServer.GetTimeStamp())
            {
                SendResult(GameData.MailResult.TEXT_MAIL_RESULT6);
                return;
            }

            // Recipient read
            packet.Skip(1);
            byte NameSize = packet.GetUint8();
            string Name = packet.GetString(NameSize);

            Character Receiver = CharMgr.GetCharacter(Name);

            if (Receiver == null)
            {
                SendResult(GameData.MailResult.TEXT_MAIL_RESULT7);
                return;
            }

            if (Receiver.Name == Plr.Name) // You cannot mail yourself
            {
                Plr.SendLocalizeString("", GameData.Localized_text.TEXT_PLAYER_CANT_MAIL_YOURSELF);
                return;
            }

            // Subject
            byte SubjectSize = packet.GetUint8();
            packet.Skip(1);
            string Subject = packet.GetString(SubjectSize);

            // Message
            byte MessageSize = packet.GetUint8();
            packet.Skip(1);
            string Message = packet.GetString(MessageSize);

            // Money
            UInt32 money = ByteOperations.ByteSwap.Swap(packet.GetUint32());

            // COD?
            byte cr = packet.GetUint8();

            // Item
            byte itemcounts = packet.GetUint8();

            if (!Plr.RemoveMoney((cr == 0 ? money : 0) + MAIL_PRICE))
            {
                SendResult(MailResult.TEXT_MAIL_RESULT8);
                return;
            }

            // Make a Mail
            Character_mail CMail = new Character_mail();
            CMail.Guid = CharMgr.GenerateMailGUID();
            CMail.CharacterId = Receiver.CharacterId;
            CMail.CharacterIdSender = Plr._Info.CharacterId;
            CMail.SenderName = Plr._Info.Name;
            CMail.ReceiverName = Name;
            CMail.Title = Subject;
            CMail.Content = Message;
            CMail.Money = money;
            CMail.Cr = true;
            CMail.Opened = false;

            Log.Debug("Mail", "Itemcount: " + itemcounts + "");

            for (byte i = 0; i < itemcounts; ++i)
            {
                UInt16 itmslot = ByteOperations.ByteSwap.Swap(packet.GetUint16());
                packet.Skip(2);

                ByteOperations.ByteSwap.Swap(itmslot);

                Item itm = Plr.ItmInterface.GetItemInSlot(itmslot);
                if (itm != null)
                {
                    CMail.ItemsReqInfo.Add(itm.CharItem);
                    Plr.ItmInterface.DeleteItem(itmslot, itm.CharItem.Counts, false);
                    itm.Owner = null;
                }

            }

            SendResult(MailResult.TEXT_MAIL_RESULT4);
            CharMgr.Database.AddObject(CMail);

            //If player exists let them know they have mail.
            Player mailToPlayer = Player.GetPlayer(Name);
            if (mailToPlayer != null)
                mailToPlayer.MlInterface.AddMail(CMail);

            nextSend = (uint)TCPServer.GetTimeStamp() + 5;
        }
Esempio n. 4
0
        public void SendMailUpdate(Character_mail Mail)
        {
            if (Mail == null)
                return;

            PacketOut Out = new PacketOut((byte)Opcodes.F_MAIL);
            Out.WriteByte(0x0B);
            Out.WriteByte(0);
            BuildPreMail(Out, Mail);
            GetPlayer().SendPacket(Out);
        }
Esempio n. 5
0
        public void SendMail(Character_mail Mail)
        {
            if (Mail == null)
                return;

            PacketOut Out = new PacketOut((byte)Opcodes.F_MAIL);
            Out.WriteByte(0x0D);
            Out.WriteByte(0);
            BuildPreMail(Out, Mail);
            Out.WriteUInt16((ushort)(Mail.Content.Length + 1));
            Out.WriteStringBytes(Mail.Content);
            Out.WriteByte(0);
            Out.WriteByte((byte)Mail.ItemsReqInfo.Count);
            foreach (Character_items item in Mail.ItemsReqInfo)
            {
                Item_Info Req = WorldMgr.GetItem_Info(item.Entry);
                Item.BuildItem(ref Out, null, Req, 0, item.Counts);
            }
            GetPlayer().SendPacket(Out);
        }
Esempio n. 6
0
 public void RemoveMail(Character_mail Mail)
 {
     _Mails.Remove(Mail);
     CharMgr.Database.DeleteObject(Mail);
     SendResult(MailResult.TEXT_MAIL_RESULT12);
 }
Esempio n. 7
0
        public void BuildPreMail(PacketOut Out, Character_mail Mail)
        {
            if (Mail == null)
                return;

            Out.WriteUInt32(0);
            Out.WriteUInt32((UInt32)Mail.Guid);
            Out.WriteUInt16((UInt16)(Mail.Opened ? 1 : 0));
            Out.WriteByte(0x64); // Icon ID

            Out.WriteUInt32(0xFFE4D486); // Time
            Out.WriteUInt32(0xFFE4D486); // Sent time

            Out.WriteUInt32((UInt32)Mail.CharacterIdSender); // Sender ID
            Out.WriteByte(0); // 1 = localized name

            Out.WriteByte(0);
            Out.WriteStringToZero(Mail.SenderName);

            Out.WriteByte(0);
            Out.WriteStringToZero(Mail.ReceiverName);

            Out.WriteByte(0);
            Out.WriteStringToZero(Mail.Title);

            Out.WriteUInt32(0);

            Out.WriteUInt32(Mail.Money);
            Out.WriteUInt16((ushort)Mail.ItemsReqInfo.Count);
            if(Mail.ItemsReqInfo.Count > 0)
                Out.WriteByte(0);
            if(Mail.ItemsReqInfo.Count > 8)
                Out.WriteByte(0);

            foreach(Character_items item in Mail.ItemsReqInfo)
            {
                Out.WriteUInt32(item.ModelId);
            }
        }
Esempio n. 8
0
        public void BuildPreMail(PacketOut Out, Character_mail Mail)
        {
            if (Mail == null)
                return;

            Out.WriteUInt32(0);
            Out.WriteUInt32((UInt32)Mail.Guid);
            Out.WriteUInt16((UInt16)(Mail.Opened ? 1 : 0));
            Out.WriteByte((byte)(Mail.AuctionType == 0 ? 100 : 0)); // Icon ID

            Out.WriteUInt32(Mail.SendDate); // Time
            Out.WriteUInt32(Mail.SendDate); // Sent time

            Out.WriteUInt32((UInt32)Mail.CharacterIdSender); // Sender ID

            Out.WriteByte(0); // 1 = localized name

            Out.WriteByte(0);
            Out.WriteStringToZero(Mail.SenderName);

            Out.WriteByte(0);
            Out.WriteStringToZero(Mail.ReceiverName);

            Out.WriteByte(0);
            Out.WriteStringToZero(Mail.Title);
            Out.WriteUInt32(0);

            Out.WriteUInt32(Mail.Money);
            Out.WriteUInt16((ushort)Mail.Items.Count);
            if (Mail.Items.Count > 0)
                Out.WriteByte(0);
            if (Mail.Items.Count > 8)
                Out.WriteByte(0);

            foreach (KeyValuePair<uint, ushort> item in Mail.Items)
            {
                Out.WriteUInt32(WorldMgr.GetItem_Info(item.Key).ModelId);
            }
        }