public static void CheckAuctionExpiry(object arg)
        {
            int removeCount = 0;

            long expireTimeStart = TCPManager.GetTimeStamp() - (60 * 60 * 24 * 30);

            lock (Auctions)
            {
                for (int i = 0; i < Auctions.Count; ++i)
                {
                    if (Auctions[i].StartTime >= expireTimeStart)
                    {
                        continue;
                    }

                    Auction auction = Auctions[i];

                    if (auction.Item == null)
                    {
                        auction.Item = ItemService.GetItem_Info(auction.ItemId);
                    }

                    if (auction.Item != null)
                    {
                        // return item to lister
                        Character_mail expireMail = new Character_mail
                        {
                            Guid         = CharMgr.GenerateMailGuid(),
                            CharacterId  = auction.SellerId,
                            ReceiverName = auction.Seller.Name,
                            SendDate     = (uint)TCPManager.GetTimeStamp(),
                            AuctionType  = 3,
                            Content      = auction.Item.Name,
                            Money        = 0,
                            Opened       = false
                        };

                        expireMail.Items.Add(new MailItem(auction.ItemId, auction._Talismans, auction.PrimaryDye, auction.SecondaryDye, auction.Count));

                        CharMgr.AddMail(expireMail);
                    }

                    CharMgr.Database.DeleteObject(auction);
                    Auctions.RemoveAt(i);

                    ++removeCount;

                    --i;
                }

                Log.Info("Auction House", $"Removed {removeCount} expired {(removeCount == 1 ? "auction": "auctions")}.");
            }
        }
示例#2
0
        public override void SendInteract(Player player, InteractMenu menu)
        {
            uint itemid = 0;

            switch (Bannertyp)
            {
            case 0: itemid = (uint)(RealmStandard == Realms.REALMS_REALM_DESTRUCTION ? 187704 : 187701); break;

            case 1: itemid = (uint)(RealmStandard == Realms.REALMS_REALM_DESTRUCTION ? 187705 : 187702); break;

            case 2: itemid = (uint)(RealmStandard == Realms.REALMS_REALM_DESTRUCTION ? 187706 : 187703); break;
            }


            if (player == Owner)
            {
                if (player.ItmInterface.GetItemInSlot(14) == null)
                {
                    player.ItmInterface.CreateItem(ItemService.GetItem_Info(itemid), 1, 14);
                    player.ItmInterface.SendEquipped(player);
                    player.ItmInterface.SendEquipped(null);
                }
                else
                {
                    player.ItmInterface.CreateItem(ItemService.GetItem_Info(itemid), 1);
                }
            }
            else if (player.Realm == RealmStandard)
            {
                Character_mail Mail = new Character_mail();
                Mail.Guid              = CharMgr.GenerateMailGuid();
                Mail.CharacterId       = Owner.CharacterId;
                Mail.CharacterIdSender = player.CharacterId;
                Mail.SenderName        = player.Name;
                Mail.ReceiverName      = Owner.Name;
                Mail.SendDate          = (uint)TCPManager.GetTimeStamp();
                Mail.Title             = "Guild Standard";
                Mail.Content           = "Found your Guild Standard";
                Mail.Money             = 0;
                Mail.Opened            = false;
                Mail.Items.Add(new MailItem(itemid, 1));
                CharMgr.AddMail(Mail);
            }
            else
            {
                player.AddRenown(600, false);
            }


            player.PlantedStandard = null;
            Dispose();
        }
        /// <summary>
        /// Returns an expired mail to its sender.
        /// </summary>
        private static MailResult ReturnMail(Character_mail mail)
        {
            // Can't return auction mail.
            if (mail.AuctionType != 0)
            {
                return(MailResult.TEXT_MAIL_RESULT11);
            }

            Character receiver = CharMgr.GetCharacter(mail.SenderName, false);

            // No one to return mail to.
            if (receiver == null)
            {
                return(MailResult.TEXT_MAIL_RESULT11);
            }

            // If mail is COD, remove the COD requirement and remove the money.
            if (mail.Cr)
            {
                mail.Cr    = false;
                mail.Money = 0;
            }

            CharMgr.DeleteMail(mail);

            Character_mail returnMail = new Character_mail
            {
                // Sender -> Reciever, Reciever -> Sender
                Guid              = CharMgr.GenerateMailGuid(),
                CharacterId       = mail.CharacterIdSender,
                CharacterIdSender = mail.CharacterId,
                SenderName        = mail.ReceiverName,
                ReceiverName      = mail.SenderName,
                Content           = "Your mail expired and has been returned to you.",
                ReadDate          = 0,
                SendDate          = (uint)TCPManager.GetTimeStamp(),
                Opened            = false
            };

            CharMgr.AddMail(returnMail);

            return(MailResult.TEXT_MAIL_UNK);
        }
        public override void Dispose()
        {
            if (IsDisposed)
            {
                return;
            }

            try
            {
                foreach (KeyValuePair <uint, GoldBag> loot in _lootBags)
                {
                    Character_mail mail = new Character_mail
                    {
                        Guid         = CharMgr.GenerateMailGuid(),
                        CharacterId  = loot.Key,
                        SenderName   = "Public Quest",
                        ReceiverName = loot.Value.plrName,
                        SendDate     = (uint)TCPManager.GetTimeStamp(),
                        Title        = "Public Quest Loot",
                        Content      = "You won a Public Quest Loot Bag",
                        Money        = 0,
                        Opened       = false
                    };

                    //Mail.CharacterIdSender = plr.CharacterId;
                    MailItem item = GenerateBag(loot.Key);
                    if (item != null)
                    {
                        mail.Items.Add(item);
                        CharMgr.AddMail(mail);
                    }
                }
            }
            catch (NullReferenceException)
            {
                Log.Error("GoldChest", "Failed to mail loot.");
            }

            _lootBags = new Dictionary <uint, GoldBag>();

            base.Dispose();
        }
        public void SendMail(Character receiver, string subject, string message, uint money, bool cashOnDelivery, List <ushort> itemSlots = null)
        {
            Player sender = (Player)_Owner;

            Character_mail cMail = new Character_mail
            {
                Guid              = CharMgr.GenerateMailGuid(),
                CharacterId       = receiver.CharacterId,
                CharacterIdSender = sender.CharacterId,
                SenderName        = sender.Info.Name,
                ReceiverName      = receiver.Name,
                SendDate          = (uint)TCPManager.GetTimeStamp(),
                Title             = subject,
                Content           = message,
                Money             = money,
                Cr     = cashOnDelivery,
                Opened = false
            };

            if (itemSlots != null)
            {
                foreach (ushort itmslot in itemSlots)
                {
                    Item itm = sender.ItmInterface.GetItemInSlot(itmslot);
                    // This should never happen, double check.
                    if (itm != null && itm.Info != null)
                    {
                        cMail.Items.Add(new MailItem(itm.Info.Entry, itm.GetTalismans(), itm.GetPrimaryDye(), itm.GetSecondaryDye(), itm.Count));
                        sender.ItmInterface.DeleteItem(itmslot, itm.Count);
                        itm.Owner = null;
                    }
                }
            }

            SendResult(MailResult.TEXT_MAIL_RESULT4);

            CharMgr.AddMail(cMail);

            _nextSend = (uint)TCPManager.GetTimeStamp() + 5;
        }
        public static void BuyOutAuction(Player buyer, ulong auctionId, uint price)
        {
            Auction auction;

            bool cancel = false;

            lock (Auctions)
                auction = Auctions.Find(info => info.AuctionId == auctionId);

            if (auction == null)
            {
                buyer.SendLocalizeString(auctionId.ToString(), ChatLogFilters.CHATLOGFILTERS_USER_ERROR, GameData.Localized_text.TEXT_AUCTION_ITEM_NO_LONGER_EXISTS);
                return;
            }

            if (auction.SellPrice != price)
            {
                if (price == 0 && auction.SellerId == buyer.CharacterId) // cancel?
                {
                    cancel = true;
                }
                else
                {
                    buyer.SendLocalizeString("", ChatLogFilters.CHATLOGFILTERS_USER_ERROR, GameData.Localized_text.TEXT_AUCTION_UNKNOWN_ERROR);
                    return;
                }
            }
            else if (!buyer.RemoveMoney(auction.SellPrice))
            {
                buyer.SendLocalizeString("", ChatLogFilters.CHATLOGFILTERS_USER_ERROR, GameData.Localized_text.TEXT_AUCTION_NOT_ENOUGH_MONEY);
                return;
            }

            // Remove live auction
            lock (Auctions)
                Auctions.Remove(auction);
            auction.Dirty = true;
            CharMgr.Database.DeleteObject(auction);

            // SendMail to seller
            if (!cancel) // seller dosent need this if hes canceling
            {
                if (auction.Seller != null)
                {
                    Character_mail sellerMail = new Character_mail
                    {
                        Guid         = CharMgr.GenerateMailGuid(),
                        CharacterId  = auction.SellerId,
                        ReceiverName = auction.Seller.Name,
                        SendDate     = (uint)TCPManager.GetTimeStamp(),
                        AuctionType  = 2,
                        Content      = auction.Item.Name,
                        Money        = (uint)(auction.SellPrice * AUCTION_HOUSE_TAX_MULT),
                        Opened       = false
                    };
                    // Complete

                    CharMgr.AddMail(sellerMail);
                }
            }

            // SendMail to buyer
            Character_mail buyerMail = new Character_mail
            {
                Guid         = CharMgr.GenerateMailGuid(),
                CharacterId  = buyer.CharacterId,
                ReceiverName = buyer.Name,
                SendDate     = (uint)TCPManager.GetTimeStamp(),
                AuctionType  = cancel ? (byte)3 : (byte)5,
                Content      = auction.Item.Name,
                Money        = 0,
                Opened       = false
            };

            buyerMail.Items.Add(new MailItem(auction.ItemId, auction._Talismans, auction.PrimaryDye, auction.SecondaryDye, auction.Count));

            CharMgr.AddMail(buyerMail);

            // Send a list
            if (cancel)
            {
                SendAuctions(buyer, "", buyer.Name, 0, 0, 0, 0, new List <byte>(), new List <byte>(), 0);
                buyer.SendLocalizeString("", ChatLogFilters.CHATLOGFILTERS_SAY, GameData.Localized_text.TEXT_AUCTION_CANCEL_SUCCESSFUL);
            }
            else
            {
                SendAuctions(buyer, "", "", 0, 0, 0, 0, new List <byte>(), new List <byte>(), 0);
                buyer.SendLocalizeString("", ChatLogFilters.CHATLOGFILTERS_SAY, GameData.Localized_text.TEXT_AUCTION_BUYOUT_SUCCESSFUL);
            }
        }