本文整理汇总了C++中AuctionEntry::GetAuctionOutBid方法的典型用法代码示例。如果您正苦于以下问题:C++ AuctionEntry::GetAuctionOutBid方法的具体用法?C++ AuctionEntry::GetAuctionOutBid怎么用?C++ AuctionEntry::GetAuctionOutBid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AuctionEntry
的用法示例。
在下文中一共展示了AuctionEntry::GetAuctionOutBid方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: HandleAuctionPlaceBid
//this function is called when client bids or buys out auction
void WorldSession::HandleAuctionPlaceBid(WorldPacket & recv_data)
{
uint64 auctioneer;
uint32 auctionId;
uint64 price;
recv_data >> auctioneer;
recv_data >> auctionId >> price;
if (!auctionId || !price)
return; //check for cheaters
Creature *pCreature = GetPlayer()->GetNPCIfCanInteractWith(auctioneer, UNIT_NPC_FLAG_AUCTIONEER);
if (!pCreature)
{
sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: HandleAuctionPlaceBid - Unit (GUID: %u) not found or you can't interact with him.", uint32(GUID_LOPART(auctioneer)));
return;
}
// remove fake death
if (GetPlayer()->HasUnitState(UNIT_STAT_DIED))
GetPlayer()->RemoveAurasByType(SPELL_AURA_FEIGN_DEATH);
AuctionHouseObject *auctionHouse = sAuctionMgr->GetAuctionsMap(pCreature->getFaction());
AuctionEntry *auction = auctionHouse->GetAuction(auctionId);
Player *pl = GetPlayer();
if (!auction || auction->owner == pl->GetGUIDLow())
{
//you cannot bid your own auction:
SendAuctionCommandResult(0, AUCTION_PLACE_BID, CANNOT_BID_YOUR_AUCTION_ERROR);
return;
}
// impossible have online own another character (use this for speedup check in case online owner)
Player* auction_owner = sObjectMgr->GetPlayer(MAKE_NEW_GUID(auction->owner, 0, HIGHGUID_PLAYER));
if (!auction_owner && sObjectMgr->GetPlayerAccountIdByGUID(MAKE_NEW_GUID(auction->owner, 0, HIGHGUID_PLAYER)) == pl->GetSession()->GetAccountId())
{
//you cannot bid your another character auction:
SendAuctionCommandResult(0, AUCTION_PLACE_BID, CANNOT_BID_YOUR_AUCTION_ERROR);
return;
}
// cheating
if (price <= auction->bid || price < auction->startbid)
return;
// price too low for next bid if not buyout
if ((price < auction->buyout || auction->buyout == 0) &&
price < auction->bid + auction->GetAuctionOutBid())
{
//auction has already higher bid, client tests it!
return;
}
if (!pl->HasEnoughMoney((uint32)price))
{
//you don't have enought money!, client tests!
//SendAuctionCommandResult(auction->auctionId, AUCTION_PLACE_BID, ???);
return;
}
SQLTransaction trans = CharacterDatabase.BeginTransaction();
if (price < auction->buyout || auction->buyout == 0)
{
if (auction->bidder > 0)
{
if (auction->bidder == pl->GetGUIDLow())
pl->ModifyMoney(-int32(price - auction->bid));
else
{
// mail to last bidder and return money
sAuctionMgr->SendAuctionOutbiddedMail(auction, price, GetPlayer(), trans);
pl->ModifyMoney(-int32(price));
}
}
else
pl->ModifyMoney(-int32(price));
auction->bidder = pl->GetGUIDLow();
auction->bid = price;
GetPlayer()->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_AUCTION_BID, price);
trans->PAppend("UPDATE auctionhouse SET buyguid = '%u', lastbid = '%u' WHERE id = '%u'", auction->bidder, auction->bid, auction->Id);
SendAuctionCommandResult(auction->Id, AUCTION_PLACE_BID, AUCTION_OK, 0);
}
else
{
//buyout:
if (pl->GetGUIDLow() == auction->bidder)
pl->ModifyMoney(-int32(auction->buyout - auction->bid));
else
{
pl->ModifyMoney(-int32(auction->buyout));
if (auction->bidder) //buyout for bidded auction ..
sAuctionMgr->SendAuctionOutbiddedMail(auction, auction->buyout, GetPlayer(), trans);
}
//.........这里部分代码省略.........
示例2: HandleAuctionPlaceBid
//this function is called when client bids or buys out auction
void WorldSession::HandleAuctionPlaceBid(WorldPacket& recvData)
{
TC_LOG_DEBUG("network", "WORLD: Received CMSG_AUCTION_PLACE_BID");
ObjectGuid auctioneer;
uint32 auctionId;
uint32 price;
recvData >> auctioneer;
recvData >> auctionId >> price;
if (!auctionId || !price)
return; //check for cheaters
Creature* creature = GetPlayer()->GetNPCIfCanInteractWith(auctioneer, UNIT_NPC_FLAG_AUCTIONEER);
if (!creature)
{
TC_LOG_DEBUG("network", "WORLD: HandleAuctionPlaceBid - %s not found or you can't interact with him.", auctioneer.ToString().c_str());
return;
}
// remove fake death
if (GetPlayer()->HasUnitState(UNIT_STATE_DIED))
GetPlayer()->RemoveAurasByType(SPELL_AURA_FEIGN_DEATH);
AuctionHouseObject* auctionHouse = sAuctionMgr->GetAuctionsMap(creature->getFaction());
AuctionEntry* auction = auctionHouse->GetAuction(auctionId);
Player* player = GetPlayer();
if (!auction || auction->owner == player->GetGUID().GetCounter())
{
//you cannot bid your own auction:
SendAuctionCommandResult(0, AUCTION_PLACE_BID, ERR_AUCTION_BID_OWN);
return;
}
// impossible have online own another character (use this for speedup check in case online owner)
ObjectGuid ownerGuid(HighGuid::Player, auction->owner);
Player* auction_owner = ObjectAccessor::FindPlayer(ownerGuid);
if (!auction_owner && sObjectMgr->GetPlayerAccountIdByGUID(ownerGuid) == player->GetSession()->GetAccountId())
{
//you cannot bid your another character auction:
SendAuctionCommandResult(0, AUCTION_PLACE_BID, ERR_AUCTION_BID_OWN);
return;
}
// cheating
if (price <= auction->bid || price < auction->startbid)
return;
// price too low for next bid if not buyout
if ((price < auction->buyout || auction->buyout == 0) &&
price < auction->bid + auction->GetAuctionOutBid())
{
//auction has already higher bid, client tests it!
return;
}
if (!player->HasEnoughMoney(price))
{
//you don't have enought money!, client tests!
//SendAuctionCommandResult(auction->auctionId, AUCTION_PLACE_BID, ???);
return;
}
SQLTransaction trans = CharacterDatabase.BeginTransaction();
if (price < auction->buyout || auction->buyout == 0)
{
if (auction->bidder > 0)
{
if (auction->bidder == player->GetGUID().GetCounter())
player->ModifyMoney(-int32(price - auction->bid));
else
{
// mail to last bidder and return money
sAuctionMgr->SendAuctionOutbiddedMail(auction, price, GetPlayer(), trans);
player->ModifyMoney(-int32(price));
}
}
else
player->ModifyMoney(-int32(price));
auction->bidder = player->GetGUID().GetCounter();
auction->bid = price;
GetPlayer()->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_AUCTION_BID, price);
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_AUCTION_BID);
stmt->setUInt32(0, auction->bidder);
stmt->setUInt32(1, auction->bid);
stmt->setUInt32(2, auction->Id);
trans->Append(stmt);
SendAuctionCommandResult(auction->Id, AUCTION_PLACE_BID, ERR_AUCTION_OK, 0);
}
else
{
//buyout:
if (player->GetGUID().GetCounter() == auction->bidder)
//.........这里部分代码省略.........
示例3: HandleAuctionPlaceBid
//this function is called when client bids or buys out auction
void WorldSession::HandleAuctionPlaceBid( WorldPacket & recv_data )
{
CHECK_PACKET_SIZE(recv_data,8+4+4);
uint64 auctioneer;
uint32 auctionId;
uint32 price;
recv_data >> auctioneer;
recv_data >> auctionId >> price;
if (!auctionId || !price)
return; //check for cheaters
Creature *pCreature = GetPlayer()->GetNPCIfCanInteractWith(auctioneer,UNIT_NPC_FLAG_AUCTIONEER);
if (!pCreature)
{
sLog.outDebug( "WORLD: HandleAuctionPlaceBid - Unit (GUID: %u) not found or you can't interact with him.", uint32(GUID_LOPART(auctioneer)) );
return;
}
// remove fake death
if(GetPlayer()->hasUnitState(UNIT_STAT_DIED))
GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH);
AuctionHouseObject* auctionHouse = auctionmgr.GetAuctionsMap( pCreature->getFaction() );
AuctionEntry *auction = auctionHouse->GetAuction(auctionId);
Player *pl = GetPlayer();
if( !auction || auction->owner == pl->GetGUIDLow() )
{
//you cannot bid your own auction:
SendAuctionCommandResult( 0, AUCTION_PLACE_BID, CANNOT_BID_YOUR_AUCTION_ERROR );
return;
}
// impossible have online own another character (use this for speedup check in case online owner)
Player* auction_owner = objmgr.GetPlayer(MAKE_NEW_GUID(auction->owner, 0, HIGHGUID_PLAYER));
if( !auction_owner && objmgr.GetPlayerAccountIdByGUID(MAKE_NEW_GUID(auction->owner, 0, HIGHGUID_PLAYER)) == pl->GetSession()->GetAccountId())
{
//you cannot bid your another character auction:
SendAuctionCommandResult( 0, AUCTION_PLACE_BID, CANNOT_BID_YOUR_AUCTION_ERROR );
return;
}
// cheating
if(price <= auction->bid)
return;
// price too low for next bid if not buyout
if ((price < auction->buyout || auction->buyout == 0) &&
price < auction->bid + auction->GetAuctionOutBid())
{
//auction has already higher bid, client tests it!
return;
}
if (price > pl->GetMoney())
{
//you don't have enought money!, client tests!
//SendAuctionCommandResult(auction->auctionId, AUCTION_PLACE_BID, ???);
return;
}
if ((price < auction->buyout) || (auction->buyout == 0))
{
if (auction->bidder > 0)
{
if ( auction->bidder == pl->GetGUIDLow() )
{
pl->ModifyMoney( -int32(price - auction->bid));
}
else
{
// mail to last bidder and return money
SendAuctionOutbiddedMail( auction , price );
pl->ModifyMoney( -int32(price) );
}
}
else
{
pl->ModifyMoney( -int32(price) );
}
auction->bidder = pl->GetGUIDLow();
auction->bid = price;
GetPlayer()->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_AUCTION_BID, price);
// after this update we should save player's money ...
CharacterDatabase.PExecute("UPDATE auctionhouse SET buyguid = '%u',lastbid = '%u' WHERE id = '%u'", auction->bidder, auction->bid, auction->Id);
SendAuctionCommandResult(auction->Id, AUCTION_PLACE_BID, AUCTION_OK, 0 );
}
else
{
//buyout:
if (pl->GetGUIDLow() == auction->bidder )
{
pl->ModifyMoney(-int32(auction->buyout - auction->bid));
}
//.........这里部分代码省略.........
示例4: BuyAndBidItems
// Tries to bid and buy items based on their prices and chances set in configs
void AuctionBotBuyer::BuyAndBidItems(BuyerConfiguration& config)
{
time_t now = time(nullptr);
AuctionHouseObject* auctionHouse = sAuctionMgr->GetAuctionsMap(config.GetHouseType());
CheckEntryMap& items = config.EligibleItems;
// Max amount of items to buy or bid
uint32 cycles = sAuctionBotConfig->GetItemPerCycleNormal();
if (items.size() > sAuctionBotConfig->GetItemPerCycleBoost())
{
// set more cycles if there is a huge influx of items
cycles = sAuctionBotConfig->GetItemPerCycleBoost();
TC_LOG_DEBUG("ahbot", "AHBot: Boost value used for Buyer! (if this happens often adjust both ItemsPerCycle in worldserver.conf)");
}
// Process items eligible to be bidded or bought
CheckEntryMap::iterator itr = items.begin();
while (cycles && itr != items.end())
{
AuctionEntry* auction = auctionHouse->GetAuction(itr->second.AuctionId);
if (!auction)
{
TC_LOG_DEBUG("ahbot", "AHBot: Entry %u doesn't exists, perhaps bought already?", itr->second.AuctionId);
items.erase(itr++);
continue;
}
// Check if the item has been checked once before
// If it has been checked and it was recently, skip it
if (itr->second.LastChecked && (now - itr->second.LastChecked) <= _checkInterval)
{
TC_LOG_DEBUG("ahbot", "AHBot: In time interval wait for entry %u!", auction->Id);
++itr;
continue;
}
Item* item = sAuctionMgr->GetAItem(auction->itemGUIDLow);
if (!item)
{
// auction item not accessible, possible auction in payment pending mode
items.erase(itr++);
continue;
}
// price to bid if bidding
uint32 bidPrice;
if (auction->bid >= auction->startbid)
{
// get bid price to outbid previous bidder
bidPrice = auction->bid + auction->GetAuctionOutBid();
}
else
{
// no previous bidders - use starting bid
bidPrice = auction->startbid;
}
const BuyerItemInfo* ahInfo = nullptr;
BuyerItemInfoMap::const_iterator sameItemItr = config.SameItemInfo.find(item->GetEntry());
if (sameItemItr != config.SameItemInfo.end())
ahInfo = &sameItemItr->second;
TC_LOG_DEBUG("ahbot", "AHBot: Rolling for AHentry %u:", auction->Id);
// Roll buy and bid chances
bool successBuy = RollBuyChance(ahInfo, item, auction, bidPrice);
bool successBid = RollBidChance(ahInfo, item, auction, bidPrice);
// If roll bidding succesfully and bid price is above buyout -> buyout
// If roll for buying was successful but not for bid, buyout directly
// If roll bidding was also successful, buy the entry with 20% chance
// - Better bid than buy since the item is bought by bot if no player bids after
// Otherwise bid if roll for bid was successful
if ((auction->buyout && successBid && bidPrice >= auction->buyout) ||
(successBuy && (!successBid || urand(1, 5) == 1)))
BuyEntry(auction, auctionHouse); // buyout
else if (successBid)
PlaceBidToEntry(auction, bidPrice); // bid
itr->second.LastChecked = now;
--cycles;
++itr;
}
// Clear not needed entries
config.SameItemInfo.clear();
}
示例5: HandleAuctionPlaceBid
// this function is called when client bids or buys out auction
void WorldSession::HandleAuctionPlaceBid(WorldPacket& recv_data)
{
DEBUG_LOG("WORLD: HandleAuctionPlaceBid");
ObjectGuid auctioneerGuid;
uint32 auctionId;
uint32 price;
recv_data >> auctioneerGuid;
recv_data >> auctionId >> price;
if (!auctionId || !price)
return; // check for cheaters
AuctionHouseEntry const* auctionHouseEntry = GetCheckedAuctionHouseForAuctioneer(auctioneerGuid);
if (!auctionHouseEntry)
return;
// always return pointer
AuctionHouseObject* auctionHouse = sAuctionMgr.GetAuctionsMap(auctionHouseEntry);
// remove fake death
if (GetPlayer()->hasUnitState(UNIT_STAT_DIED))
GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH);
AuctionEntry* auction = auctionHouse->GetAuction(auctionId);
Player* pl = GetPlayer();
if (!auction || auction->owner == pl->GetGUIDLow())
{
// you cannot bid your own auction:
SendAuctionCommandResult(NULL, AUCTION_BID_PLACED, AUCTION_ERR_BID_OWN);
return;
}
ObjectGuid ownerGuid = ObjectGuid(HIGHGUID_PLAYER, auction->owner);
// impossible have online own another character (use this for speedup check in case online owner)
Player* auction_owner = sObjectMgr.GetPlayer(ownerGuid);
if (!auction_owner && sObjectMgr.GetPlayerAccountIdByGUID(ownerGuid) == pl->GetSession()->GetAccountId())
{
// you cannot bid your another character auction:
SendAuctionCommandResult(NULL, AUCTION_BID_PLACED, AUCTION_ERR_BID_OWN);
return;
}
// cheating or client lags
if (price <= auction->bid)
{
// client test but possible in result lags
SendAuctionCommandResult(auction, AUCTION_BID_PLACED, AUCTION_ERR_HIGHER_BID);
return;
}
// price too low for next bid if not buyout
if ((price < auction->buyout || auction->buyout == 0) &&
price < auction->bid + auction->GetAuctionOutBid())
{
// client test but possible in result lags
SendAuctionCommandResult(auction, AUCTION_BID_PLACED, AUCTION_ERR_BID_INCREMENT);
return;
}
if (price > pl->GetMoney())
{
// you don't have enough money!, client tests!
// SendAuctionCommandResult(auction->auctionId, AUCTION_ERR_INVENTORY, EQUIP_ERR_NOT_ENOUGH_MONEY);
return;
}
// cheating
if (price < auction->startbid)
return;
SendAuctionCommandResult(auction, AUCTION_BID_PLACED, AUCTION_OK);
auction->UpdateBid(price, pl);
}
示例6: HandleAuctionPlaceBid
// this function is called when client bids or buys out auction
void WorldSession::HandleAuctionPlaceBid(WorldPacket& recvData)
{
sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Received CMSG_AUCTION_PLACE_BID");
ObjectGuid auctioneer;
uint32 auctionId;
uint64 price;
recvData >> price;
recvData >> auctionId;
auctioneer[2] = recvData.ReadBit();
auctioneer[5] = recvData.ReadBit();
auctioneer[4] = recvData.ReadBit();
auctioneer[1] = recvData.ReadBit();
auctioneer[0] = recvData.ReadBit();
auctioneer[3] = recvData.ReadBit();
auctioneer[6] = recvData.ReadBit();
auctioneer[7] = recvData.ReadBit();
recvData.FlushBits();
recvData.ReadByteSeq(auctioneer[4]);
recvData.ReadByteSeq(auctioneer[7]);
recvData.ReadByteSeq(auctioneer[5]);
recvData.ReadByteSeq(auctioneer[3]);
recvData.ReadByteSeq(auctioneer[6]);
recvData.ReadByteSeq(auctioneer[2]);
recvData.ReadByteSeq(auctioneer[1]);
recvData.ReadByteSeq(auctioneer[0]);
if (!auctionId || !price)
return; // check for cheaters
Creature* creature = GetPlayer()->GetNPCIfCanInteractWith(auctioneer, UNIT_NPC_FLAG_AUCTIONEER);
if (!creature)
{
sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: HandleAuctionPlaceBid - Unit (GUID: %u) not found or you can't interact with him.", uint32(GUID_LOPART(auctioneer)));
return;
}
// remove fake death
if (GetPlayer()->HasUnitState(UNIT_STATE_DIED))
GetPlayer()->RemoveAurasByType(SPELL_AURA_FEIGN_DEATH);
AuctionHouseObject* auctionHouse = sAuctionMgr->GetAuctionsMap(creature->getFaction());
AuctionEntry* auction = auctionHouse->GetAuction(auctionId);
Player* player = GetPlayer();
if (!auction || auction->owner == player->GetGUIDLow())
{
//you cannot bid your own auction:
SendAuctionCommandResult(NULL, AUCTION_PLACE_BID, 0, ERR_AUCTION_BID_OWN);
return;
}
// cheating
if (price <= auction->bid || price < auction->startbid)
return;
// price too low for next bid if not buyout
if ((price < auction->buyout || auction->buyout == 0) &&
price < auction->bid + auction->GetAuctionOutBid())
{
// client already test it but just in case ...
SendAuctionCommandResult(auction, AUCTION_PLACE_BID, 0, ERR_AUCTION_HIGHER_BID);
return;
}
if (!player->HasEnoughMoney(price))
{
// client already test it but just in case ...
SendAuctionCommandResult(auction, AUCTION_PLACE_BID, 0, ERR_AUCTION_NOT_ENOUGH_MONEY);
return;
}
SQLTransaction trans = CharacterDatabase.BeginTransaction();
if (price < auction->buyout || auction->buyout == 0)
{
if (auction->bidder > 0)
{
if (auction->bidder == player->GetGUIDLow())
player->ModifyMoney(-int64(price - auction->bid));
else
{
// mail to last bidder and return money
sAuctionMgr->SendAuctionOutbiddedMail(auction, price, GetPlayer(), trans);
player->ModifyMoney(-int64(price));
}
}
else
player->ModifyMoney(-int64(price));
auction->bidder = player->GetGUIDLow();
auction->bid = price;
GetPlayer()->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_AUCTION_BID, price);
//.........这里部分代码省略.........
示例7: HandleAuctionPlaceBid
// this function is called when client bids or buys out auction
void WorldSession::HandleAuctionPlaceBid( WorldPacket & recv_data )
{
DEBUG_LOG("WORLD: HandleAuctionPlaceBid");
ObjectGuid auctioneerGuid;
uint32 auctionId;
uint32 price;
recv_data >> auctioneerGuid;
recv_data >> auctionId >> price;
if (!auctionId || !price)
return; // check for cheaters
AuctionHouseEntry const* auctionHouseEntry = GetCheckedAuctionHouseForAuctioneer(auctioneerGuid);
if (!auctionHouseEntry)
return;
// always return pointer
AuctionHouseObject* auctionHouse = sAuctionMgr.GetAuctionsMap(auctionHouseEntry);
// remove fake death
if(GetPlayer()->hasUnitState(UNIT_STAT_DIED))
GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH);
AuctionEntry *auction = auctionHouse->GetAuction(auctionId);
Player *pl = GetPlayer();
if( !auction || auction->owner == pl->GetGUIDLow() )
{
// you cannot bid your own auction:
SendAuctionCommandResult( NULL, AUCTION_BID_PLACED, AUCTION_ERR_BID_OWN );
return;
}
ObjectGuid ownerGuid = ObjectGuid(HIGHGUID_PLAYER, auction->owner);
// impossible have online own another character (use this for speedup check in case online owner)
Player* auction_owner = sObjectMgr.GetPlayer(ownerGuid);
if (!auction_owner && sObjectMgr.GetPlayerAccountIdByGUID(ownerGuid) == pl->GetSession()->GetAccountId())
{
// you cannot bid your another character auction:
SendAuctionCommandResult( NULL, AUCTION_BID_PLACED, AUCTION_ERR_BID_OWN );
return;
}
// cheating
if(price <= auction->bid || price < auction->startbid)
return;
// price too low for next bid if not buyout
if ((price < auction->buyout || auction->buyout == 0) &&
price < auction->bid + auction->GetAuctionOutBid())
{
// auction has already higher bid, client tests it!
return;
}
if (price > pl->GetMoney())
{
// you don't have enough money!, client tests!
// SendAuctionCommandResult(auction->auctionId, AUCTION_ERR_INVENTORY, EQUIP_ERR_NOT_ENOUGH_MONEY);
return;
}
if ((price < auction->buyout) || (auction->buyout == 0))// bid
{
if (pl->GetGUIDLow() == auction->bidder)
{
pl->ModifyMoney(-int32(price - auction->bid));
}
else
{
pl->ModifyMoney(-int32(price));
if (auction->bidder) // return money to old bidder if present
SendAuctionOutbiddedMail(auction);
}
auction->bidder = pl->GetGUIDLow();
auction->bid = price;
if(auction_owner)
auction_owner->GetSession()->SendAuctionOwnerNotification(auction);
GetPlayer()->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_AUCTION_BID, price);
// after this update we should save player's money ...
CharacterDatabase.PExecute("UPDATE auction SET buyguid = '%u', lastbid = '%u' WHERE id = '%u'", auction->bidder, auction->bid, auction->Id);
SendAuctionCommandResult(auction, AUCTION_BID_PLACED, AUCTION_OK);
}
else // buyout
{
if (pl->GetGUIDLow() == auction->bidder)
{
pl->ModifyMoney(-int32(auction->buyout - auction->bid));
}
else
{
pl->ModifyMoney(-int32(auction->buyout));
//.........这里部分代码省略.........
示例8: AddNewAuctionBuyerBotBid
void AuctionBotBuyer::AddNewAuctionBuyerBotBid(BuyerConfiguration& config)
{
AuctionHouseObject* auctionHouse = sAuctionMgr->GetAuctionsMap(config.GetHouseType());
PrepareListOfEntry(config);
time_t now = time(nullptr);
uint32 buyCycles;
if (config.CheckedEntry.size() > sAuctionBotConfig->GetItemPerCycleBoost())
{
buyCycles = sAuctionBotConfig->GetItemPerCycleBoost();
TC_LOG_DEBUG("ahbot", "AHBot: Boost value used for Buyer! (if this happens often adjust both ItemsPerCycle in worldserver.conf)");
}
else
buyCycles = sAuctionBotConfig->GetItemPerCycleNormal();
for (CheckEntryMap::iterator itr = config.CheckedEntry.begin(); itr != config.CheckedEntry.end();)
{
AuctionEntry* auction = auctionHouse->GetAuction(itr->second.AuctionId);
if (!auction) // is auction not active now
{
TC_LOG_DEBUG("ahbot", "AHBot: Entry %u doesn't exists, perhaps bought already?",
itr->second.AuctionId);
config.CheckedEntry.erase(itr++);
continue;
}
if (itr->second.LastChecked != 0 && (now - itr->second.LastChecked) <= _checkInterval)
{
TC_LOG_DEBUG("ahbot", "AHBot: In time interval wait for entry %u!", auction->Id);
++itr;
continue;
}
if (buyCycles == 0)
break;
uint32 maxChance = 5000;
Item* item = sAuctionMgr->GetAItem(auction->itemGUIDLow);
if (!item) // auction item not accessible, possible auction in payment pending mode
{
config.CheckedEntry.erase(itr++);
continue;
}
ItemTemplate const* prototype = item->GetTemplate();
uint32 basePrice = sAuctionBotConfig->GetConfig(CONFIG_AHBOT_BUYPRICE_BUYER) ? prototype->BuyPrice : prototype->SellPrice;
basePrice *= item->GetCount();
uint32 maxBuyablePrice = (basePrice * config.BuyerPriceRatio) / 100;
BuyerItemInfoMap::iterator sameItemItr = config.SameItemInfo.find(item->GetEntry());
uint32 buyoutPrice = auction->buyout / item->GetCount();
uint32 bidPrice;
uint32 bidPriceByItem;
uint32 minBidPrice;
uint32 minBuyPrice;
if (auction->bid >= auction->startbid)
{
bidPrice = auction->GetAuctionOutBid();
bidPriceByItem = auction->bid / item->GetCount();
}
else
{
bidPrice = auction->startbid;
bidPriceByItem = auction->startbid / item->GetCount();
}
double inGameBuyPrice;
double inGameBidPrice;
if (sameItemItr == config.SameItemInfo.end())
{
inGameBuyPrice = 0;
inGameBidPrice = 0;
minBidPrice = 0;
minBuyPrice = 0;
}
else
{
if (sameItemItr->second.ItemCount == 1)
maxBuyablePrice = maxBuyablePrice * 5; // if only one item exist can be bought if the price is high too.
inGameBuyPrice = sameItemItr->second.BuyPrice / sameItemItr->second.ItemCount;
inGameBidPrice = sameItemItr->second.BidPrice / sameItemItr->second.ItemCount;
minBidPrice = sameItemItr->second.MinBidPrice;
minBuyPrice = sameItemItr->second.MinBuyPrice;
}
uint32 maxBidablePrice = maxBuyablePrice - (maxBuyablePrice / 30); // Max Bidable price defined to 70% of max buyable price
TC_LOG_DEBUG("ahbot", "AHBot: Auction added with data:");
TC_LOG_DEBUG("ahbot", "AHBot: MaxPrice of Entry %u is %.1fg.", itr->second.AuctionId, double(maxBuyablePrice) / 10000.0);
TC_LOG_DEBUG("ahbot", "AHBot: GamePrice buy=%.1fg, bid=%.1fg.", inGameBuyPrice / 10000, inGameBidPrice / 10000);
TC_LOG_DEBUG("ahbot", "AHBot: Minimal price see in AH Buy=%ug, Bid=%ug.",
minBuyPrice / 10000, minBidPrice / 10000);
TC_LOG_DEBUG("ahbot", "AHBot: Actual Entry price, Buy=%ug, Bid=%ug.", buyoutPrice / 10000, bidPrice / 10000);
if (!auction->owner) // Original auction owner
//.........这里部分代码省略.........
示例9: HandleAuctionPlaceBid
// this function is called when client bids or buys out auction
void WorldSession::HandleAuctionPlaceBid(WorldPackets::AuctionHouse::AuctionPlaceBid& packet)
{
if (!packet.AuctionItemID || !packet.BidAmount)
return; // check for cheaters
Creature* creature = GetPlayer()->GetNPCIfCanInteractWith(packet.Auctioneer, UNIT_NPC_FLAG_AUCTIONEER);
if (!creature)
{
TC_LOG_DEBUG("network", "WORLD: HandleAuctionPlaceBid - %s not found or you can't interact with him.", packet.Auctioneer.ToString().c_str());
return;
}
// remove fake death
if (GetPlayer()->HasUnitState(UNIT_STATE_DIED))
GetPlayer()->RemoveAurasByType(SPELL_AURA_FEIGN_DEATH);
AuctionHouseObject* auctionHouse = sAuctionMgr->GetAuctionsMap(creature->getFaction());
AuctionEntry* auction = auctionHouse->GetAuction(packet.AuctionItemID);
Player* player = GetPlayer();
if (!auction || auction->owner == player->GetGUID().GetCounter())
{
//you cannot bid your own auction:
SendAuctionCommandResult(NULL, AUCTION_PLACE_BID, ERR_AUCTION_BID_OWN);
return;
}
// impossible have online own another character (use this for speedup check in case online owner)
ObjectGuid ownerGuid = ObjectGuid::Create<HighGuid::Player>(auction->owner);
Player* auction_owner = ObjectAccessor::FindPlayer(ownerGuid);
if (!auction_owner && ObjectMgr::GetPlayerAccountIdByGUID(ownerGuid) == player->GetSession()->GetAccountId())
{
//you cannot bid your another character auction:
SendAuctionCommandResult(NULL, AUCTION_PLACE_BID, ERR_AUCTION_BID_OWN);
return;
}
// cheating
if (packet.BidAmount <= auction->bid || packet.BidAmount < auction->startbid)
return;
// price too low for next bid if not buyout
if ((packet.BidAmount < auction->buyout || auction->buyout == 0) &&
packet.BidAmount < auction->bid + auction->GetAuctionOutBid())
{
// client already test it but just in case ...
SendAuctionCommandResult(auction, AUCTION_PLACE_BID, ERR_AUCTION_HIGHER_BID);
return;
}
if (!player->HasEnoughMoney(packet.BidAmount))
{
// client already test it but just in case ...
SendAuctionCommandResult(auction, AUCTION_PLACE_BID, ERR_AUCTION_NOT_ENOUGHT_MONEY);
return;
}
SQLTransaction trans = CharacterDatabase.BeginTransaction();
if (packet.BidAmount < auction->buyout || auction->buyout == 0)
{
if (auction->bidder)
{
if (auction->bidder == player->GetGUID().GetCounter())
player->ModifyMoney(-int64(packet.BidAmount - auction->bid));
else
{
// mail to last bidder and return money
sAuctionMgr->SendAuctionOutbiddedMail(auction, packet.BidAmount, GetPlayer(), trans);
player->ModifyMoney(-int64(packet.BidAmount));
}
}
else
player->ModifyMoney(-int64(packet.BidAmount));
auction->bidder = player->GetGUID().GetCounter();
auction->bid = packet.BidAmount;
GetPlayer()->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_AUCTION_BID, packet.BidAmount);
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_AUCTION_BID);
stmt->setUInt64(0, auction->bidder);
stmt->setUInt32(1, auction->bid);
stmt->setUInt32(2, auction->Id);
trans->Append(stmt);
SendAuctionCommandResult(auction, AUCTION_PLACE_BID, ERR_AUCTION_OK);
// Not sure if we must send this now.
Player* owner = sObjectAccessor->FindConnectedPlayer(ObjectGuid::Create<HighGuid::Player>(auction->owner));
Item* item = sAuctionMgr->GetAItem(auction->itemGUIDLow);
if (owner && item)
owner->GetSession()->SendAuctionOwnerBidNotification(auction, item);
}
else
{
//buyout:
if (player->GetGUID().GetCounter() == auction->bidder)
player->ModifyMoney(-int64(auction->buyout - auction->bid));
//.........这里部分代码省略.........