void AuctionHouse::UpdateOwner(uint32 oldGuid, uint32 newGuid)
{
	auctionLock.AcquireWriteLock();
	HM_NAMESPACE::hash_map<uint32, Auction*>::iterator itr = auctions.begin();
	Auction * auction;
	for(; itr != auctions.end(); ++itr)
	{
		auction = itr->second;
		if(auction->Owner == oldGuid)
			auction->Owner = newGuid;
		if(auction->HighestBidder == oldGuid)
		{
			auction->HighestBidder = newGuid;
			auction->UpdateInDB();
		}
	}
	auctionLock.ReleaseWriteLock();
}
Beispiel #2
0
void AuctionHouse::UpdateItemOwnerships(uint32 oldGuid, uint32 newGuid)
{

	Auction * auct;
	auctionLock.AcquireWriteLock();
	HM_NAMESPACE::hash_map<uint32, Auction*>::iterator itr = auctions.begin();
	for(; itr != auctions.end(); itr++)
	{
		auct = itr->second;
		if(auct->Owner == oldGuid)
		{
			auct->Owner = newGuid;
			// Don't save, we take care of this in char rename all at once. Less queries.
		}

		if(auct->HighestBidder == oldGuid)
		{
			auct->HighestBidder = newGuid;
			auct->UpdateInDB();
		}
	}
	auctionLock.ReleaseWriteLock();
}
void WorldSession::HandleAuctionPlaceBid( WorldPacket & recv_data )
{
	if(!_player->IsInWorld())
	{ 
		return;
	}

	uint64 guid;
	recv_data >> guid;

	uint32 auction_id, price;
	recv_data >> auction_id >> price;

	Creature * pCreature = _player->GetMapMgr()->GetCreature( guid );
	if(!pCreature || !pCreature->auctionHouse)
	{ 
		return;
	}

	// Find Item
	AuctionHouse * ah = pCreature->auctionHouse;
	Auction * auct = ah->GetAuction(auction_id);
	if(auct == 0 || !auct->Owner || !_player)
	{
		SendAuctionPlaceBidResultPacket(0, AUCTION_ERROR_INTERNAL);
		return;
	}

	if(auct->Owner == _player->GetGUID())
	{
		SendAuctionPlaceBidResultPacket(0, AUCTION_ERROR_BID_OWN_AUCTION);
		return;
	}
	if(auct->HighestBid > price && price != auct->BuyoutPrice)
	{
		//HACK: Don't know the correct error code... 
		SendAuctionPlaceBidResultPacket(0, AUCTION_ERROR_INTERNAL);
		return;
	}

	if(_player->GetGold() < price)
	{
		SendAuctionPlaceBidResultPacket(0, AUCTION_ERROR_MONEY);
		return;
	}

	_player->ModGold( -((int32)price));
	if(auct->HighestBidder != 0)
	{
		// Return the money to the last highest bidder.
		char subject[100];
		snprintf(subject, 100, "%u:0:0", (int)auct->pItem->GetEntry());
		sMailSystem.SendAutomatedMessage(AUCTION, ah->GetID(), auct->HighestBidder, subject, "", auct->HighestBid, 0, 0, MAIL_STATIONERY_AUCTION );

		// Do not send out bid notification, when current highest bidder and new bidder are the same player..
		if(auct->HighestBidder != (uint32)_player->GetLowGUID())
			ah->SendAuctionOutBidNotificationPacket(auct, _player->GetGUID(), price);
	}

	if(auct->BuyoutPrice == price)
	{
		auct->HighestBidder = _player->GetLowGUID();
		auct->HighestBid = price;

		// we used buyout on the item.
		ah->QueueDeletion(auct, AUCTION_REMOVE_WON);

		SendAuctionPlaceBidResultPacket(auct->Id, AUCTION_ERROR_NONE);
		ah->SendAuctionBuyOutNotificationPacket(auct);
	}
	else
	{
		// update most recent bid
		auct->HighestBidder = _player->GetLowGUID();
		auct->HighestBid = price;
		auct->UpdateInDB();

		SendAuctionPlaceBidResultPacket(auct->Id, AUCTION_ERROR_NONE);
	}
}
Beispiel #4
0
void WorldSession::HandleAuctionPlaceBid( WorldPacket & recv_data )
{
	CHECK_INWORLD_RETURN;

	uint64 guid;
	recv_data >> guid;

	uint32 auction_id, price;
	recv_data >> auction_id >> price;

	Creature* pCreature = _player->GetMapMgr()->GetCreature(GET_LOWGUID_PART(guid));
	if(!pCreature || !pCreature->auctionHouse || price == 0)
		return;

	// Find Item
	AuctionHouse * ah = pCreature->auctionHouse;
	Auction * auct = ah->GetAuction(auction_id);
	if(auct == 0 || !auct->Owner || !_player || auct->Owner == _player->GetGUID())
		return;

	if(auct->HighestBid > price && price != auct->BuyoutPrice)
		return;

	if(_player->GetUInt32Value(PLAYER_FIELD_COINAGE) < price)
		return;

	_player->ModUnsigned32Value(PLAYER_FIELD_COINAGE, -((int32)price));
	if(auct->HighestBidder != 0)
	{
		// Return the money to the last highest bidder.
		char subject[100];
		snprintf(subject, 100, "%u:0:0", (int)auct->pItem->GetEntry());
		sMailSystem.DeliverMessage(MAILTYPE_AUCTION, ah->GetID(), auct->HighestBidder, subject, "", auct->HighestBid, 0, 0, STATIONERY_AUCTION, true);

	}

	if(auct->BuyoutPrice == price)
	{
		auct->HighestBidder = _player->GetLowGUID();
		auct->HighestBid = price;

		// we used buyout on the item.
		ah->QueueDeletion(auct, AUCTION_REMOVE_WON);

		// send response packet
		WorldPacket data(SMSG_AUCTION_COMMAND_RESULT, 12);
		data << auct->Id << uint32(AUCTION_BID) << uint32(0);
		SendPacket(&data);
	}
	else
	{
		// update most recent bid
		auct->HighestBidder = _player->GetLowGUID();
		auct->HighestBid = price;
		auct->UpdateInDB();

		// send response packet
		WorldPacket data(SMSG_AUCTION_COMMAND_RESULT, 12);
		data << auct->Id << uint32(AUCTION_BID) << uint32(0);
		SendPacket(&data);
	}
}