Exemplo n.º 1
0
		public void RemoveAuction(Auction auction)
		{
			if (auction == null)
				return;
            if (!auctions.ContainsKey(auction.AuctionId))
                return;
			auctions.Remove(auction.ItemLowId);
			items.Remove(auction.ItemLowId);
            AuctionMgr mgr = AuctionMgr.Instance;
            ItemRecord record = null;
            if (mgr.AuctionItems.ContainsKey(auction.ItemLowId)) 
            {
                record = mgr.AuctionItems[auction.ItemLowId];
                mgr.AuctionItems.Remove(auction.ItemLowId);
            }
            
            
            //remove from database
            RealmServer.IOQueue.AddMessage(() => {
                if (record != null) {
                    record.IsAuctioned = false;
					RealmWorldDBMgr.DatabaseProvider.SaveOrUpdate(record);
                }
				RealmWorldDBMgr.DatabaseProvider.Delete(auction); });
		}
Exemplo n.º 2
0
		public void AddAuction(Auction newAuction)
		{
			if (newAuction == null)
				return;
			auctions.Add(newAuction.ItemLowId, newAuction);
			items.Add(newAuction.ItemLowId);
			//if this is a new one created by player, it should be save in database
			if (newAuction.IsNew) 
            {
				RealmWorldDBMgr.DatabaseProvider.Save(newAuction);
            }
		}
Exemplo n.º 3
0
		public bool TryGetAuction(uint auctionId, out Auction auction)
		{
			return auctions.TryGetValue(auctionId, out auction);
		}
Exemplo n.º 4
0
		public static bool BuildAuctionPacket(Auction auction, RealmPacketOut packet)
		{
			var item = AuctionMgr.Instance.AuctionItems[auction.ItemLowId];

			if (item == null)
				return false;

			var timeleft = auction.TimeEnds - DateTime.Now;
			if (timeleft.TotalMilliseconds < 0)
				return false;

			packet.Write(auction.ItemLowId);
			packet.Write(item.Template.Id);

			for (var i = 0; i < 7; i++)
			{
				if (item.EnchantIds != null)
				{
					packet.Write(item.EnchantIds[i]);
					packet.Write(i);					// enchant duration
					packet.Write(item.GetEnchant((EnchantSlot)i).Charges);	// TODO: Fix enchant charges
				}
				else
				{
					packet.Write(0);
					packet.Write(0);
					packet.Write(0);
				}
			}

			packet.Write(item.RandomProperty);
			packet.Write(item.RandomSuffix);
			packet.Write(item.Amount);
			packet.Write((uint)item.Charges);
            packet.WriteUInt(0);                    //Unknown
            packet.WriteULong(auction.OwnerLowId);
            packet.Write(auction.CurrentBid);       //auction start bid
		    packet.WriteUInt(AuctionMgr.GetMinimumNewBidIncrement(auction));                    //amount required to outbid
            packet.Write(auction.BuyoutPrice);
            packet.Write((int)timeleft.TotalMilliseconds);
            packet.WriteULong(auction.BidderLowId);
            packet.Write(auction.CurrentBid);
		    return true;
		}
Exemplo n.º 5
0
		public static void SendAuctionListItems(IPacketReceiver client, Auction[] auctions)
		{
			if (auctions == null || auctions.Length < 1)
				return;
			var packet = new RealmPacketOut(RealmServerOpCode.SMSG_AUCTION_LIST_RESULT, 7000);
            var count = 0;
            packet.Write(auctions.Length);
			foreach (var auction in auctions)
			{
				if(BuildAuctionPacket(auction, packet))
                    count++;
			}
            //packet.InsertIntAt(count, 0, true);
			packet.Write(count);
			packet.Write(300);
			client.Send(packet);
			packet.Close();

		}
Exemplo n.º 6
0
		public static void SendAuctionListBidderItems(IPacketReceiver client, Auction[] auctions)
		{
			if (auctions == null || auctions.Length < 1)
				return;

			//can not use "using" block if a ref parameter in there.
			var packet = new RealmPacketOut(RealmServerOpCode.SMSG_AUCTION_BIDDER_LIST_RESULT, 1024);
			packet.Write(auctions.Length);

			foreach (var auction in auctions)
			{
				BuildAuctionPacket(auction, packet);
			}
			packet.Write(auctions.Length);
			packet.Write(0);
			client.Send(packet);
			packet.Close();
		}
Exemplo n.º 7
0
		public static void SendAuctionOutbidNotification(IPacketReceiver client, Auction auction, uint newBid, uint minBidInc)
		{
			if (auction == null)
				return;

			using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_AUCTION_BIDDER_NOTIFICATION, 8 * 4))
			{
				packet.Write((uint)auction.HouseFaction);
				packet.Write(auction.ItemLowId);
				packet.Write(auction.BidderLowId);
				packet.Write(newBid);
				packet.Write(minBidInc);
				packet.Write(auction.ItemTemplateId);
				packet.Write(0u);

				client.Send(packet);
			}
		}
Exemplo n.º 8
0
		public static void SendAuctionCommandResult(IPacketReceiver client, Auction auction, AuctionAction action, AuctionError error)
		{
			using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_AUCTION_COMMAND_RESULT, 12))
			{
				if (auction != null)
				{
					packet.Write(auction.ItemLowId);
				}
				else
				{
					packet.Write(0u);
				}
				packet.Write((uint)action);
				packet.Write((uint)error);

				client.Send(packet);
			}
		}