本文整理汇总了C++中AuctionHouseObject类的典型用法代码示例。如果您正苦于以下问题:C++ AuctionHouseObject类的具体用法?C++ AuctionHouseObject怎么用?C++ AuctionHouseObject使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了AuctionHouseObject类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SendAuctionCommandResult
//.........这里部分代码省略.........
item->GetTemplate()->Flags & ITEM_PROTO_FLAG_CONJURED || item->GetUInt32Value(ITEM_FIELD_DURATION) ||
item->GetCount() < count[i])
{
SendAuctionCommandResult(0, AUCTION_SELL_ITEM, AUCTION_INTERNAL_ERROR);
return;
}
items[i] = item;
finalCount += count[i];
}
if (!finalCount)
{
SendAuctionCommandResult(0, AUCTION_SELL_ITEM, AUCTION_INTERNAL_ERROR);
return;
}
for (uint32 i = 0; i < itemsCount; ++i)
{
Item* item = items[i];
if (item->GetMaxStackCount() < finalCount)
{
SendAuctionCommandResult(0, AUCTION_SELL_ITEM, AUCTION_INTERNAL_ERROR);
return;
}
}
for (uint32 i = 0; i < itemsCount; ++i)
{
Item* item = items[i];
uint32 auctionTime = uint32(etime * sWorld->getRate(RATE_AUCTION_TIME));
AuctionHouseObject* auctionHouse = sAuctionMgr->GetAuctionsMap(creature->getFaction());
uint32 deposit = sAuctionMgr->GetAuctionDeposit(auctionHouseEntry, etime, item, finalCount);
if (!_player->HasEnoughMoney(deposit))
{
SendAuctionCommandResult(0, AUCTION_SELL_ITEM, AUCTION_NOT_ENOUGHT_MONEY);
return;
}
_player->ModifyMoney(-int32(deposit));
AuctionEntry* AH = new AuctionEntry;
AH->Id = sObjectMgr->GenerateAuctionID();
if (sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_AUCTION))
AH->auctioneer = 23442;
else
AH->auctioneer = GUID_LOPART(auctioneer);
// Required stack size of auction matches to current item stack size, just move item to auctionhouse
if (itemsCount == 1 && item->GetCount() == count[i])
{
if (GetSecurity() > SEC_PLAYER && sWorld->getBoolConfig(CONFIG_GM_LOG_TRADE))
{
sLog->outCommand(GetAccountId(), "GM %s (Account: %u) create auction: %s (Entry: %u Count: %u)",
GetPlayerName(), GetAccountId(), item->GetTemplate()->Name1.c_str(), item->GetEntry(), item->GetCount());
}
AH->item_guidlow = item->GetGUIDLow();
AH->item_template = item->GetEntry();
AH->itemCount = item->GetCount();
AH->owner = _player->GetGUIDLow();
AH->startbid = bid;
示例2: GetPlayer
//this function is called when client bids or buys out auction
void WorldSession::HandleAuctionPlaceBid(WorldPacket & recv_data)
{
sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Received CMSG_AUCTION_PLACE_BID");
uint64 auctioneer;
uint32 auctionId;
uint32 price;
recv_data >> auctioneer;
recv_data >> auctionId >> price;
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(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 = ObjectAccessor::FindPlayer(MAKE_NEW_GUID(auction->owner, 0, HIGHGUID_PLAYER));
if (!auction_owner && sObjectMgr->GetPlayerAccountIdByGUID(MAKE_NEW_GUID(auction->owner, 0, HIGHGUID_PLAYER)) == player->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 (!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->GetGUIDLow())
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->GetGUIDLow();
auction->bid = price;
GetPlayer()->GetAchievementMgr().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, AUCTION_OK, 0);
}
else
{
//buyout:
if (player->GetGUIDLow() == auction->bidder)
player->ModifyMoney(-int32(auction->buyout - auction->bid));
//.........这里部分代码省略.........
示例3: DEBUG_LOG
// 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 && ownerGuid && 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);
if (auction->UpdateBid(price, pl))
pl->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_AUCTION_BID, price);
else
pl->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_AUCTION_BID, auction->buyout);
}
示例4: time
// Collects information about item counts and minimum prices to SameItemInfo and updates EligibleItems - a list with new items eligible for bot to buy and bid
// Returns count of items in AH that were eligible for being bought or bidded on by ahbot buyer (EligibleItems size)
uint32 AuctionBotBuyer::GetItemInformation(BuyerConfiguration& config)
{
config.SameItemInfo.clear();
time_t now = time(nullptr);
uint32 count = 0;
AuctionHouseObject* house = sAuctionMgr->GetAuctionsMap(config.GetHouseType());
for (AuctionHouseObject::AuctionEntryMap::const_iterator itr = house->GetAuctionsBegin(); itr != house->GetAuctionsEnd(); ++itr)
{
AuctionEntry* entry = itr->second;
if (!entry->owner)
continue; // Skip auctions owned by AHBot
Item* item = sAuctionMgr->GetAItem(entry->itemGUIDLow);
if (!item)
continue;
BuyerItemInfo& itemInfo = config.SameItemInfo[item->GetEntry()];
// Update item entry's count and total bid prices
// This can be used later to determine the prices and chances to bid
uint32 itemBidPrice = entry->startbid / item->GetCount();
itemInfo.TotalBidPrice = itemInfo.TotalBidPrice + itemBidPrice;
itemInfo.BidItemCount++;
// Set minimum bid price
if (!itemInfo.MinBidPrice)
itemInfo.MinBidPrice = itemBidPrice;
else
itemBidPrice = std::min(itemInfo.MinBidPrice, itemBidPrice);
// Set minimum buyout price if item has buyout
if (entry->buyout)
{
// Update item entry's count and total buyout prices
// This can be used later to determine the prices and chances to buyout
uint32 itemBuyPrice = entry->buyout / item->GetCount();
itemInfo.TotalBuyPrice = itemInfo.TotalBuyPrice + itemBuyPrice;
itemInfo.BuyItemCount++;
if (!itemInfo.MinBuyPrice)
itemInfo.MinBuyPrice = itemBuyPrice;
else
itemInfo.MinBuyPrice = std::min(itemInfo.MinBuyPrice, itemBuyPrice);
}
// Add/update EligibleItems if:
// * no bid
// * bid from player
if (!entry->bid || entry->bidder)
{
config.EligibleItems[entry->Id].LastExist = now;
config.EligibleItems[entry->Id].AuctionId = entry->Id;
++count;
}
}
TC_LOG_DEBUG("ahbot", "AHBot: %u items added to buyable/biddable vector for ah type: %u", count, config.GetHouseType());
TC_LOG_DEBUG("ahbot", "AHBot: SameItemInfo size = %u", (uint32)config.SameItemInfo.size());
return count;
}
示例5: CHECK_PACKET_SIZE
//this void is called when auction_owner cancels his auction
void WorldSession::HandleAuctionRemoveItem( WorldPacket & recv_data )
{
CHECK_PACKET_SIZE(recv_data,8+4);
uint64 auctioneer;
uint32 auctionId;
recv_data >> auctioneer;
recv_data >> auctionId;
//sLog.outDebug( "Cancel AUCTION AuctionID: %u", auctionId);
Creature *pCreature = ObjectAccessor::GetNPCIfCanInteractWith(*_player, auctioneer,UNIT_NPC_FLAG_AUCTIONEER);
if (!pCreature)
{
sLog.outDebug( "WORLD: HandleAuctionRemoveItem - 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);
uint32 location = AuctioneerFactionToLocation(pCreature->getFaction());
AuctionHouseObject * mAuctions;
mAuctions = objmgr.GetAuctionsMap( location );
AuctionEntry *auction = mAuctions->GetAuction(auctionId);
Player *pl = GetPlayer();
if (auction && auction->owner == pl->GetGUIDLow())
{
Item *pItem = objmgr.GetAItem(auction->item_guidlow);
if (pItem)
{
if (auction->bidder > 0) // If we have a bidder, we have to send him the money he paid
{
uint32 auctionCut = objmgr.GetAuctionCut( auction->location, auction->bid);
if ( pl->GetMoney() < auctionCut ) //player doesn't have enough money, maybe message needed
return;
//some auctionBidderNotification would be needed, but don't know that parts..
SendAuctionCancelledToBidderMail( auction );
pl->ModifyMoney( -int32(auctionCut) );
}
// Return the item by mail
std::ostringstream msgAuctionCanceledOwner;
msgAuctionCanceledOwner << auction->item_template << ":0:" << AUCTION_CANCELED;
MailItemsInfo mi;
mi.AddItem(auction->item_guidlow, auction->item_template, pItem);
// item will deleted or added to received mail list
WorldSession::SendMailTo(pl, MAIL_AUCTION, MAIL_STATIONERY_AUCTION, auction->location, pl->GetGUIDLow(), msgAuctionCanceledOwner.str(), 0, &mi, 0, 0, MAIL_CHECK_MASK_NONE);
}
else
{
sLog.outError("Auction id: %u has non-existed item (item guid : %u)!!!", auction->Id, auction->item_guidlow);
SendAuctionCommandResult( 0, AUCTION_CANCEL, AUCTION_INTERNAL_ERROR );
return;
}
}
else
{
SendAuctionCommandResult( 0, AUCTION_CANCEL, AUCTION_INTERNAL_ERROR );
//this code isn't possible ... maybe there should be assert
sLog.outError("CHEATER : %u, he tried to cancel auction (id: %u) of another player, or auction is NULL", pl->GetGUIDLow(), auctionId );
return;
}
//inform player, that auction is removed
SendAuctionCommandResult( auction->Id, AUCTION_CANCEL, AUCTION_OK );
// Now remove the auction
CharacterDatabase.BeginTransaction();
CharacterDatabase.PExecute("DELETE FROM auctionhouse WHERE id = '%u'",auction->Id);
pl->SaveInventoryAndGoldToDB();
CharacterDatabase.CommitTransaction();
objmgr.RemoveAItem( auction->item_guidlow );
mAuctions->RemoveAuction( auction->Id );
delete auction;
}
示例6: TC_LOG_DEBUG
//this void is called when player clicks on search button
void WorldSession::HandleAuctionListItems(WorldPacket& recvData)
{
TC_LOG_DEBUG("network", "WORLD: Received CMSG_AUCTION_LIST_ITEMS");
std::string searchedname;
uint8 levelmin, levelmax, usable, getAll;
uint32 listfrom, auctionSlotID, auctionMainCategory, auctionSubCategory, quality;
ObjectGuid guid;
recvData >> guid;
recvData >> listfrom; // start, used for page control listing by 50 elements
recvData >> searchedname;
recvData >> levelmin >> levelmax;
recvData >> auctionSlotID >> auctionMainCategory >> auctionSubCategory;
recvData >> quality >> usable;
recvData >> getAll;
// this block looks like it uses some lame byte packing or similar...
uint8 unkCnt;
recvData >> unkCnt;
for (uint8 i = 0; i < unkCnt; i++)
{
recvData.read_skip<uint8>();
recvData.read_skip<uint8>();
}
Creature* creature = GetPlayer()->GetNPCIfCanInteractWith(guid, UNIT_NPC_FLAG_AUCTIONEER);
if (!creature)
{
TC_LOG_DEBUG("network", "WORLD: HandleAuctionListItems - %s not found or you can't interact with him.", guid.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());
TC_LOG_DEBUG("auctionHouse", "Auctionhouse search (%s) list from: %u, searchedname: %s, levelmin: %u, levelmax: %u, auctionSlotID: %u, auctionMainCategory: %u, auctionSubCategory: %u, quality: %u, usable: %u",
guid.ToString().c_str(), listfrom, searchedname.c_str(), levelmin, levelmax, auctionSlotID, auctionMainCategory, auctionSubCategory, quality, usable);
WorldPacket data(SMSG_AUCTION_LIST_RESULT, (4+4+4));
uint32 count = 0;
uint32 totalcount = 0;
data << (uint32) 0;
// converting string that we try to find to lower case
std::wstring wsearchedname;
if (!Utf8toWStr(searchedname, wsearchedname))
return;
wstrToLower(wsearchedname);
auctionHouse->BuildListAuctionItems(data, _player,
wsearchedname, listfrom, levelmin, levelmax, usable,
auctionSlotID, auctionMainCategory, auctionSubCategory, quality,
count, totalcount, (getAll != 0 && sWorld->getIntConfig(CONFIG_AUCTION_GETALL_DELAY) != 0));
data.put<uint32>(0, count);
data << (uint32) totalcount;
data << (uint32) sWorld->getIntConfig(CONFIG_AUCTION_SEARCH_DELAY);
SendPacket(&data);
}
示例7: GetPlayer
//this function is called when client bids or buys out auction
void WorldSession::HandleAuctionPlaceBid(WorldPacket & recv_data)
{
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()->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 (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));
else
{
pl->ModifyMoney(-int32(auction->buyout));
if (auction->bidder) //buyout for bidded auction ..
SendAuctionOutbiddedMail(auction, auction->buyout);
}
auction->bidder = pl->GetGUIDLow();
//.........这里部分代码省略.........
示例8: DEBUG_LOG
// this void is called when player clicks on search button
void WorldSession::HandleAuctionListItems(WorldPacket& recv_data)
{
DEBUG_LOG("WORLD: CMSG_AUCTION_LIST_ITEMS");
ObjectGuid auctioneerGuid;
std::string searchedname;
uint8 levelmin, levelmax, usable, isFull, sortCount, unk;
uint32 listfrom, auctionSlotID, auctionMainCategory, auctionSubCategory, quality;
recv_data >> auctioneerGuid;
recv_data >> listfrom; // start, used for page control listing by 50 elements
recv_data >> searchedname;
recv_data >> levelmin >> levelmax;
recv_data >> auctionSlotID >> auctionMainCategory >> auctionSubCategory >> quality;
recv_data >> usable >> isFull >> unk >> sortCount;
if (sortCount >= MAX_AUCTION_SORT)
return;
uint8 Sort[MAX_AUCTION_SORT];
memset(Sort, MAX_AUCTION_SORT, MAX_AUCTION_SORT);
// auction columns sorting
for (uint32 i = 0; i < sortCount; ++i)
{
uint8 column, reversed;
recv_data >> column;
if (column >= MAX_AUCTION_SORT)
return;
recv_data >> reversed;
Sort[i] = (reversed > 0) ? (column |= AUCTION_SORT_REVERSED) : column;
}
AuctionHouseEntry const* auctionHouseEntry = GetCheckedAuctionHouseForAuctioneer(auctioneerGuid);
if (!auctionHouseEntry)
return;
// always return pointer
AuctionHouseObject* auctionHouse = sAuctionMgr.GetAuctionsMap(auctionHouseEntry);
// Sort
AuctionHouseObject::AuctionEntryMap const& aucs = auctionHouse->GetAuctions();
std::vector<AuctionEntry*> auctions;
auctions.reserve(aucs.size());
for (AuctionHouseObject::AuctionEntryMap::const_iterator itr = aucs.begin(); itr != aucs.end(); ++itr)
auctions.push_back(itr->second);
AuctionSorter sorter(Sort, GetPlayer());
std::sort(auctions.begin(), auctions.end(), sorter);
// remove fake death
if (GetPlayer()->hasUnitState(UNIT_STAT_DIED))
GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH);
// DEBUG_LOG("Auctionhouse search %s list from: %u, searchedname: %s, levelmin: %u, levelmax: %u, auctionSlotID: %u, auctionMainCategory: %u, auctionSubCategory: %u, quality: %u, usable: %u",
// auctioneerGuid.GetString().c_str(), listfrom, searchedname.c_str(), levelmin, levelmax, auctionSlotID, auctionMainCategory, auctionSubCategory, quality, usable);
WorldPacket data(SMSG_AUCTION_LIST_RESULT, (4 + 4 + 4));
uint32 count = 0;
uint32 totalcount = 0;
data << uint32(0);
// converting string that we try to find to lower case
std::wstring wsearchedname;
if (!Utf8toWStr(searchedname, wsearchedname))
return;
wstrToLower(wsearchedname);
BuildListAuctionItems(auctions, data, wsearchedname, listfrom, levelmin, levelmax, usable,
auctionSlotID, auctionMainCategory, auctionSubCategory, quality, count, totalcount, isFull);
data.put<uint32>(0, count);
data << uint32(totalcount);
data << uint32(300); // 2.3.0 delay for next isFull request?
SendPacket(&data);
DEBUG_LOG("WORLD: Sent SMSG_AUCTION_LIST_RESULT");
}
示例9: DEBUG_LOG
// this void creates new auction and adds auction to some auctionhouse
void WorldSession::HandleAuctionSellItem(WorldPacket& recv_data)
{
DEBUG_LOG("WORLD: HandleAuctionSellItem");
ObjectGuid auctioneerGuid;
ObjectGuid itemGuid;
uint32 etime, bid, buyout;
recv_data >> auctioneerGuid;
recv_data >> itemGuid;
recv_data >> bid;
recv_data >> buyout;
recv_data >> etime;
if (!bid || !etime)
return; // check for cheaters
Player* pl = GetPlayer();
AuctionHouseEntry const* auctionHouseEntry = GetCheckedAuctionHouseForAuctioneer(auctioneerGuid);
if (!auctionHouseEntry)
return;
// always return pointer
AuctionHouseObject* auctionHouse = sAuctionMgr.GetAuctionsMap(auctionHouseEntry);
// client send time in minutes, convert to common used sec time
etime *= MINUTE;
// client understand only 3 auction time
switch (etime)
{
case 1*MIN_AUCTION_TIME:
case 2*MIN_AUCTION_TIME:
case 4*MIN_AUCTION_TIME:
break;
default:
return;
}
// remove fake death
if (GetPlayer()->hasUnitState(UNIT_STAT_DIED))
GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH);
if (!itemGuid)
return;
Item* it = pl->GetItemByGuid(itemGuid);
// do not allow to sell already auctioned items
if (sAuctionMgr.GetAItem(itemGuid.GetCounter()))
{
sLog.outError("AuctionError, %s is sending %s, but item is already in another auction", pl->GetGuidStr().c_str(), itemGuid.GetString().c_str());
SendAuctionCommandResult(NULL, AUCTION_STARTED, AUCTION_ERR_INVENTORY, EQUIP_ERR_ITEM_NOT_FOUND);
return;
}
// prevent sending bag with items (cheat: can be placed in bag after adding equipped empty bag to auction)
if (!it)
{
SendAuctionCommandResult(NULL, AUCTION_STARTED, AUCTION_ERR_INVENTORY, EQUIP_ERR_ITEM_NOT_FOUND);
return;
}
if (!it->CanBeTraded())
{
SendAuctionCommandResult(NULL, AUCTION_STARTED, AUCTION_ERR_INVENTORY, EQUIP_ERR_CANNOT_TRADE_THAT);
return;
}
if ((it->GetProto()->Flags & ITEM_FLAG_CONJURED) || it->GetUInt32Value(ITEM_FIELD_DURATION))
{
SendAuctionCommandResult(NULL, AUCTION_STARTED, AUCTION_ERR_INVENTORY, EQUIP_ERR_CANNOT_TRADE_THAT);
return;
}
// check money for deposit
uint32 deposit = AuctionHouseMgr::GetAuctionDeposit(auctionHouseEntry, etime, it);
if (pl->GetMoney() < deposit)
{
SendAuctionCommandResult(NULL, AUCTION_STARTED, AUCTION_ERR_NOT_ENOUGH_MONEY);
return;
}
if (GetSecurity() > SEC_PLAYER && sWorld.getConfig(CONFIG_BOOL_GM_LOG_TRADE))
{
sLog.outCommand(GetAccountId(), "GM %s (Account: %u) create auction: %s (Entry: %u Count: %u)",
GetPlayerName(), GetAccountId(), it->GetProto()->Name1, it->GetEntry(), it->GetCount());
}
pl->ModifyMoney(-int32(deposit));
AuctionEntry* AH = auctionHouse->AddAuction(auctionHouseEntry, it, etime, bid, buyout, deposit, pl);
DETAIL_LOG("selling %s to auctioneer %s with initial bid %u with buyout %u and with time %u (in sec) in auctionhouse %u",
itemGuid.GetString().c_str(), auctioneerGuid.GetString().c_str(), bid, buyout, etime, auctionHouseEntry->houseId);
SendAuctionCommandResult(AH, AUCTION_STARTED, AUCTION_OK);
}
示例10: GetPlayer
//this function is called when client bids or buys out auction
void WorldSession::HandleAuctionPlaceBid(WorldPacket & recv_data)
{
sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Received CMSG_AUCTION_PLACE_BID");
uint64 auctioneer;
uint32 auctionId;
uint32 priceTmp;
uint64 price;
recv_data >> auctioneer;
recv_data >> auctionId >> priceTmp;
price = priceTmp;
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_STAT_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(0, AUCTION_PLACE_BID, ERR_AUCTION_DATABASE_ERROR);
return;
}
// impossible have online own another character (use this for speedup check in case online owner)
Player* auction_owner = ObjectAccessor::FindPlayer(MAKE_NEW_GUID(auction->owner, 0, HIGHGUID_PLAYER));
if (!auction_owner && sObjectMgr->GetPlayerAccountIdByGUID(MAKE_NEW_GUID(auction->owner, 0, HIGHGUID_PLAYER)) == 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->GetGUIDLow())
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->GetGUIDLow();
auction->bid = (price >> 32);
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 (player->GetGUIDLow() == auction->bidder)
示例11: DEBUG_LOG
// this void creates new auction and adds auction to some auctionhouse
void WorldSession::HandleAuctionSellItem( WorldPacket & recv_data )
{
DEBUG_LOG("WORLD: HandleAuctionSellItem");
ObjectGuid auctioneerGuid;
uint64 item;
uint32 etime, bid, buyout;
recv_data >> auctioneerGuid;
recv_data.read_skip<uint32>(); // const 1?
recv_data >> item;
recv_data.read_skip<uint32>(); // stack size
recv_data >> bid;
recv_data >> buyout;
recv_data >> etime;
if (!item || !bid || !etime)
return; // check for cheaters
Player *pl = GetPlayer();
AuctionHouseEntry const* auctionHouseEntry = GetCheckedAuctionHouseForAuctioneer(auctioneerGuid);
if (!auctionHouseEntry)
return;
// always return pointer
AuctionHouseObject* auctionHouse = sAuctionMgr.GetAuctionsMap(auctionHouseEntry);
// client send time in minutes, convert to common used sec time
etime *= MINUTE;
// client understand only 3 auction time
switch(etime)
{
case 1*MIN_AUCTION_TIME:
case 2*MIN_AUCTION_TIME:
case 4*MIN_AUCTION_TIME:
break;
default:
return;
}
// remove fake death
if(GetPlayer()->hasUnitState(UNIT_STAT_DIED))
GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH);
Item *it = pl->GetItemByGuid( item );
// do not allow to sell already auctioned items
if(sAuctionMgr.GetAItem(GUID_LOPART(item)))
{
sLog.outError("AuctionError, player %s is sending item id: %u, but item is already in another auction", pl->GetName(), GUID_LOPART(item));
SendAuctionCommandResult(0, AUCTION_SELL_ITEM, AUCTION_INTERNAL_ERROR);
return;
}
// prevent sending bag with items (cheat: can be placed in bag after adding equipped empty bag to auction)
if(!it)
{
SendAuctionCommandResult(0, AUCTION_SELL_ITEM, AUCTION_ITEM_NOT_FOUND);
return;
}
if(!it->CanBeTraded())
{
SendAuctionCommandResult(0, AUCTION_SELL_ITEM, AUCTION_INTERNAL_ERROR);
return;
}
if (it->HasFlag(ITEM_FIELD_FLAGS, ITEM_FLAGS_CONJURED) || it->GetUInt32Value(ITEM_FIELD_DURATION))
{
SendAuctionCommandResult(0, AUCTION_SELL_ITEM, AUCTION_INTERNAL_ERROR);
return;
}
//we have to take deposit :
uint32 deposit = AuctionHouseMgr::GetAuctionDeposit( auctionHouseEntry, etime, it );
if ( pl->GetMoney() < deposit )
{
SendAuctionCommandResult(0, AUCTION_SELL_ITEM, AUCTION_NOT_ENOUGHT_MONEY);
return;
}
if( GetSecurity() > SEC_PLAYER && sWorld.getConfig(CONFIG_BOOL_GM_LOG_TRADE) )
{
sLog.outCommand(GetAccountId(),"GM %s (Account: %u) create auction: %s (Entry: %u Count: %u)",
GetPlayerName(), GetAccountId(), it->GetProto()->Name1, it->GetEntry(), it->GetCount());
}
pl->ModifyMoney( -int32(deposit) );
uint32 auction_time = uint32(etime * sWorld.getConfig(CONFIG_FLOAT_RATE_AUCTION_TIME));
AuctionEntry *AH = new AuctionEntry;
AH->Id = sObjectMgr.GenerateAuctionID();
AH->item_guidlow = GUID_LOPART(item);
AH->item_template = it->GetEntry();
AH->owner = pl->GetGUIDLow();
AH->startbid = bid;
AH->bidder = 0;
AH->bid = 0;
AH->buyout = buyout;
//.........这里部分代码省略.........
示例12: GetPlayer
// this void creates new auction and adds auction to some auctionhouse
void WorldSession::HandleAuctionSellItem(WorldPacket & recv_data)
{
uint64 auctioneer, item;
uint64 bid, buyout;
uint32 etime, count;
uint32 unk = 1;
recv_data >> auctioneer; // uint64
recv_data >> unk; // 1
recv_data >> item; // uint64
recv_data >> count; // 3.2.2, number of items being auctioned
recv_data >> bid; // uint64, 4.0.6
recv_data >> buyout; // uint64, 4.0.6
recv_data >> etime; // uint32
Player *pl = GetPlayer();
if (!item || !bid || !etime)
return; //check for cheaters
Creature *pCreature = GetPlayer()->GetNPCIfCanInteractWith(auctioneer, UNIT_NPC_FLAG_AUCTIONEER);
if (!pCreature)
{
sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: HandleAuctionSellItem - Unit (GUID: %u) not found or you can't interact with him.", uint32(GUID_LOPART(auctioneer)));
return;
}
AuctionHouseEntry const* auctionHouseEntry = AuctionHouseMgr::GetAuctionHouseEntry(pCreature->getFaction());
if (!auctionHouseEntry)
{
sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: HandleAuctionSellItem - Unit (GUID: %u) has wrong faction.", uint32(GUID_LOPART(auctioneer)));
return;
}
sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: HandleAuctionSellItem - ETIME: %u", etime);
// client send time in minutes, convert to common used sec time
etime *= MINUTE;
sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: HandleAuctionSellItem - ETIME: %u", etime);
// client understand only 3 auction time
switch(etime)
{
case 1*MIN_AUCTION_TIME:
case 2*MIN_AUCTION_TIME:
case 4*MIN_AUCTION_TIME:
break;
default:
return;
}
// remove fake death
if (GetPlayer()->HasUnitState(UNIT_STAT_DIED))
GetPlayer()->RemoveAurasByType(SPELL_AURA_FEIGN_DEATH);
Item *it = pl->GetItemByGuid(item);
//do not allow to sell already auctioned items
if (sAuctionMgr->GetAItem(GUID_LOPART(item)))
{
sLog->outError("AuctionError, player %s is sending item id: %u, but item is already in another auction", pl->GetName(), GUID_LOPART(item));
SendAuctionCommandResult(0, AUCTION_SELL_ITEM, AUCTION_INTERNAL_ERROR);
return;
}
// prevent sending bag with items (cheat: can be placed in bag after adding equiped empty bag to auction)
if (!it)
{
SendAuctionCommandResult(0, AUCTION_SELL_ITEM, AUCTION_ITEM_NOT_FOUND);
return;
}
if (!it->CanBeTraded())
{
SendAuctionCommandResult(0, AUCTION_SELL_ITEM, AUCTION_INTERNAL_ERROR);
return;
}
if (it->GetProto()->Flags & ITEM_PROTO_FLAG_CONJURED || it->GetUInt32Value(ITEM_FIELD_DURATION))
{
SendAuctionCommandResult(0, AUCTION_SELL_ITEM, AUCTION_INTERNAL_ERROR);
return;
}
if (it->IsBag() && !((Bag*)it)->IsEmpty())
{
SendAuctionCommandResult(0, AUCTION_SELL_ITEM, AUCTION_INTERNAL_ERROR);
return;
}
AuctionHouseObject* auctionHouse = sAuctionMgr->GetAuctionsMap(pCreature->getFaction());
//we have to take deposit :
uint32 deposit = sAuctionMgr->GetAuctionDeposit(auctionHouseEntry, etime, it, count);
if (!pl->HasEnoughMoney(deposit))
{
SendAuctionCommandResult(0, AUCTION_SELL_ITEM, AUCTION_NOT_ENOUGHT_MONEY);
return;
}
//.........这里部分代码省略.........
示例13: memset
//.........这里部分代码省略.........
if (!finalCount)
{
SendAuctionCommandResult(0, AUCTION_SELL_ITEM, ERR_AUCTION_DATABASE_ERROR);
return;
}
// check if there are 2 identical guids, in this case user is most likely cheating
for (uint32 i = 0; i < itemsCount - 1; ++i)
{
for (uint32 j = i + 1; j < itemsCount; ++j)
{
if (itemGUIDs[i] == itemGUIDs[j])
{
SendAuctionCommandResult(0, AUCTION_SELL_ITEM, ERR_AUCTION_DATABASE_ERROR);
return;
}
}
}
for (uint32 i = 0; i < itemsCount; ++i)
{
Item* item = items[i];
if (item->GetMaxStackCount() < finalCount)
{
SendAuctionCommandResult(0, AUCTION_SELL_ITEM, ERR_AUCTION_DATABASE_ERROR);
return;
}
}
Item* item = items[0];
uint32 auctionTime = uint32(etime * sWorld->getRate(RATE_AUCTION_TIME));
AuctionHouseObject* auctionHouse = sAuctionMgr->GetAuctionsMap(creature->getFaction());
uint32 deposit = sAuctionMgr->GetAuctionDeposit(auctionHouseEntry, etime, item, finalCount);
if (!_player->HasEnoughMoney(deposit))
{
SendAuctionCommandResult(0, AUCTION_SELL_ITEM, ERR_AUCTION_NOT_ENOUGHT_MONEY);
return;
}
AuctionEntry* AH = new AuctionEntry();
if (sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_AUCTION))
AH->auctioneer = 23442; ///@TODO - HARDCODED DB GUID, BAD BAD BAD
else
AH->auctioneer = auctioneer.GetCounter();
// Required stack size of auction matches to current item stack size, just move item to auctionhouse
if (itemsCount == 1 && item->GetCount() == count[0])
{
if (HasPermission(rbac::RBAC_PERM_LOG_GM_TRADE))
{
sLog->outCommand(GetAccountId(), "GM %s (Account: %u) create auction: %s (Entry: %u Count: %u)",
GetPlayerName().c_str(), GetAccountId(), item->GetTemplate()->Name1.c_str(), item->GetEntry(), item->GetCount());
}
AH->Id = sObjectMgr->GenerateAuctionID();
AH->itemGUIDLow = item->GetGUIDLow();
AH->itemEntry = item->GetEntry();
AH->itemCount = item->GetCount();
AH->owner = _player->GetGUIDLow();
AH->startbid = bid;
AH->bidder = 0;
AH->bid = 0;