本文整理汇总了C++中RemoveAItem函数的典型用法代码示例。如果您正苦于以下问题:C++ RemoveAItem函数的具体用法?C++ RemoveAItem怎么用?C++ RemoveAItem使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了RemoveAItem函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetAItem
// does not clear ram
void AuctionHouseMgr::SendAuctionExpiredMail(AuctionEntry* auction)
{
// return an item in auction to its owner by mail
Item* pItem = GetAItem(auction->itemGuidLow);
if (!pItem)
{
sLog.outError("Auction item (GUID: %u) not found, and lost.", auction->itemGuidLow);
return;
}
ObjectGuid owner_guid = ObjectGuid(HIGHGUID_PLAYER, auction->owner);
Player* owner = sObjectMgr.GetPlayer(owner_guid);
uint32 owner_accId = 0;
if (!owner)
owner_accId = sObjectMgr.GetPlayerAccountIdByGUID(owner_guid);
// owner exist
if (owner || owner_accId)
{
std::ostringstream subject;
subject << auction->itemTemplate << ":" << auction->itemRandomPropertyId << ":" << AUCTION_EXPIRED;
if (owner)
owner->GetSession()->SendAuctionOwnerNotification(auction, false);
RemoveAItem(auction->itemGuidLow); // we have to remove the item, before we delete it !!
auction->itemGuidLow = 0;
// will delete item or place to receiver mail list
MailDraft(subject.str())
.AddItem(pItem)
.SendMailTo(MailReceiver(owner, owner_guid), auction, MAIL_CHECK_MASK_COPIED);
}
// owner not found
else
{
CharacterDatabase.PExecute("DELETE FROM item_instance WHERE guid='%u'", auction->itemGuidLow);
RemoveAItem(auction->itemGuidLow); // we have to remove the item, before we delete it !!
auction->itemGuidLow = 0;
delete pItem;
}
}
示例2: GetAItem
//does not clear ram
void AuctionHouseMgr::SendAuctionExpiredMail( AuctionEntry * auction )
{ //return an item in auction to its owner by mail
Item *pItem = GetAItem(auction->item_guidlow);
if(!pItem)
{
sLog.outError("Auction item (GUID: %u) not found, and lost.",auction->item_guidlow);
return;
}
uint64 owner_guid = MAKE_NEW_GUID(auction->owner, 0, HIGHGUID_PLAYER);
Player *owner = objmgr.GetPlayer(owner_guid);
uint32 owner_accId = 0;
if(!owner)
owner_accId = objmgr.GetPlayerAccountIdByGUID(owner_guid);
// owner exist
if(owner || owner_accId)
{
std::ostringstream subject;
subject << auction->item_template << ":0:" << AUCTION_EXPIRED;
if ( owner )
owner->GetSession()->SendAuctionOwnerNotification( auction );
else
RemoveAItem(pItem->GetGUIDLow()); // we have to remove the item, before we delete it !!
MailItemsInfo mi;
mi.AddItem(auction->item_guidlow, auction->item_template, pItem);
// will delete item or place to receiver mail list
WorldSession::SendMailTo(owner, MAIL_AUCTION, MAIL_STATIONERY_AUCTION, auction->GetHouseId(), GUID_LOPART(owner_guid), subject.str(), 0, &mi, 0, 0, MAIL_CHECK_MASK_NONE);
}
// owner not found
else
{
CharacterDatabase.PExecute("DELETE FROM item_instance WHERE guid='%u'",pItem->GetGUIDLow());
RemoveAItem(pItem->GetGUIDLow()); // we have to remove the item, before we delete it !!
delete pItem;
}
}
示例3: GetAItem
//does not clear ram
void AuctionHouseMgr::SendAuctionExpiredMail( AuctionEntry * auction )
{ //return an item in auction to its owner by mail
Item *pItem = GetAItem(auction->item_guidlow);
if (!pItem)
{
sLog.outError("Auction item (GUID: %u) not found, and lost.",auction->item_guidlow);
return;
}
uint64 owner_guid = MAKE_NEW_GUID(auction->owner, 0, HIGHGUID_PLAYER);
Player *owner = sObjectMgr.GetPlayer(owner_guid);
uint32 owner_accId = 0;
if (!owner)
owner_accId = sObjectMgr.GetPlayerAccountIdByGUID(owner_guid);
// owner exist
if (owner || owner_accId)
{
std::ostringstream subject;
subject << auction->item_template << ":0:" << AUCTION_EXPIRED << ":0:0";
if ( owner )
owner->GetSession()->SendAuctionOwnerNotification( auction );
else
RemoveAItem(pItem->GetGUIDLow()); // we have to remove the item, before we delete it !!
// will delete item or place to receiver mail list
MailDraft(subject.str(), "") // TODO: fix body
.AddItem(pItem)
.SendMailTo(MailReceiver(owner,auction->owner), auction, MAIL_CHECK_MASK_COPIED);
}
// owner not found
else
{
CharacterDatabase.PExecute("DELETE FROM item_instance WHERE guid='%u'",pItem->GetGUIDLow());
RemoveAItem(pItem->GetGUIDLow()); // we have to remove the item, before we delete it !!
delete pItem;
}
}
示例4: GetAItem
// does not clear ram
void AuctionHouseMgr::SendAuctionWonMail(AuctionEntry *auction)
{
Item *pItem = GetAItem(auction->itemGuidLow);
if (!pItem)
return;
ObjectGuid bidder_guid = ObjectGuid(HIGHGUID_PLAYER, auction->bidder);
Player *bidder = sObjectMgr.GetPlayer(bidder_guid);
uint32 bidder_accId = 0;
ObjectGuid ownerGuid = ObjectGuid(HIGHGUID_PLAYER, auction->owner);
Player* auction_owner = sObjectMgr.GetPlayer(ownerGuid);
// data for gm.log
if (sWorld.getConfig(CONFIG_BOOL_GM_LOG_TRADE))
{
uint32 bidder_security = 0;
std::string bidder_name;
if (bidder)
{
bidder_accId = bidder->GetSession()->GetAccountId();
bidder_security = bidder->GetSession()->GetSecurity();
bidder_name = bidder->GetName();
}
else
{
bidder_accId = sObjectMgr.GetPlayerAccountIdByGUID(bidder_guid);
bidder_security = sAccountMgr.GetSecurity(bidder_accId);
if (bidder_security > SEC_PLAYER) // not do redundant DB requests
{
if (!sObjectMgr.GetPlayerNameByGUID(bidder_guid, bidder_name))
bidder_name = sObjectMgr.GetMangosStringForDBCLocale(LANG_UNKNOWN);
}
}
if (bidder_security > SEC_PLAYER)
{
std::string owner_name;
if (auction_owner)
owner_name = auction_owner->GetName();
else if (ownerGuid && !sObjectMgr.GetPlayerNameByGUID(ownerGuid, owner_name))
owner_name = sObjectMgr.GetMangosStringForDBCLocale(LANG_UNKNOWN);
uint32 owner_accid = ownerGuid ? sObjectMgr.GetPlayerAccountIdByGUID(ownerGuid) : 0;
sLog.outCommand(bidder_accId,"GM %s (Account: %u) won item in auction: %s (Entry: %u Count: %u) and pay money: %u. Original owner %s (Account: %u)",
bidder_name.c_str(), bidder_accId, pItem->GetProto()->Name1, pItem->GetEntry(), pItem->GetCount(), auction->bid, owner_name.c_str(), owner_accid);
}
}
else if (!bidder)
bidder_accId = sObjectMgr.GetPlayerAccountIdByGUID(bidder_guid);
if (auction_owner)
auction_owner->GetSession()->SendAuctionOwnerNotification(auction);
// receiver exist
if (bidder || bidder_accId)
{
std::ostringstream msgAuctionWonSubject;
msgAuctionWonSubject << auction->itemTemplate << ":0:" << AUCTION_WON;
std::ostringstream msgAuctionWonBody;
msgAuctionWonBody.width(16);
msgAuctionWonBody << std::right << std::hex << auction->owner;
msgAuctionWonBody << std::dec << ":" << auction->bid << ":" << auction->buyout;
DEBUG_LOG("AuctionWon body string : %s", msgAuctionWonBody.str().c_str());
// set owner to bidder (to prevent delete item with sender char deleting)
// owner in `data` will set at mail receive and item extracting
CharacterDatabase.PExecute("UPDATE item_instance SET owner_guid = '%u' WHERE guid='%u'",auction->bidder,pItem->GetGUIDLow());
CharacterDatabase.CommitTransaction();
if (bidder)
{
bidder->GetSession()->SendAuctionBidderNotification(auction);
// FIXME: for offline player need also
bidder->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_WON_AUCTIONS, 1);
}
else
RemoveAItem(pItem->GetGUIDLow()); // we have to remove the item, before we delete it !!
// will delete item or place to receiver mail list
MailDraft(msgAuctionWonSubject.str(), msgAuctionWonBody.str())
.AddItem(pItem)
.SendMailTo(MailReceiver(bidder, bidder_guid), auction, MAIL_CHECK_MASK_COPIED);
}
// receiver not exist
else
{
CharacterDatabase.PExecute("DELETE FROM item_instance WHERE guid='%u'", pItem->GetGUIDLow());
RemoveAItem(pItem->GetGUIDLow()); // we have to remove the item, before we delete it !!
delete pItem;
}
}
示例5: COUNT
//.........这里部分代码省略.........
bar.step();
sLog.outString();
sLog.outString(">> Loaded 0 auctions. DB table `auction` is empty.");
return;
}
result = CharacterDatabase.Query("SELECT id,houseid,itemguid,item_template,itemowner,buyoutprice,time,moneyTime,buyguid,lastbid,startbid,deposit FROM auction");
if (!result)
{
BarGoLink bar(1);
bar.step();
sLog.outString();
sLog.outString(">> Loaded 0 auctions. DB table `auction` is empty.");
return;
}
BarGoLink bar(AuctionCount);
typedef std::map<uint32, std::wstring> PlayerNames;
PlayerNames playerNames; // caching for load time
do
{
fields = result->Fetch();
bar.step();
AuctionEntry *auction = new AuctionEntry;
auction->Id = fields[0].GetUInt32();
uint32 houseid = fields[1].GetUInt32();
auction->itemGuidLow = fields[2].GetUInt32();
auction->itemTemplate = fields[3].GetUInt32();
auction->owner = fields[4].GetUInt32();
if (auction->owner)
{
std::wstring& plWName = playerNames[auction->owner];
if (plWName.empty())
{
std::string plName;
if (!sObjectMgr.GetPlayerNameByGUID(ObjectGuid(HIGHGUID_PLAYER, auction->owner), plName))
plName = sObjectMgr.GetMangosStringForDBCLocale(LANG_UNKNOWN);
Utf8toWStr(plName, plWName);
}
auction->ownerName = plWName;
}
auction->buyout = fields[5].GetUInt32();
auction->expireTime = fields[6].GetUInt32();
auction->moneyDeliveryTime = fields[7].GetUInt32();
auction->bidder = fields[8].GetUInt32();
auction->bid = fields[9].GetUInt32();
auction->startbid = fields[10].GetUInt32();
auction->deposit = fields[11].GetUInt32();
auction->auctionHouseEntry = NULL; // init later
// check if sold item exists for guid
// and item_template in fact (GetAItem will fail if problematic in result check in AuctionHouseMgr::LoadAuctionItems)
Item* pItem = GetAItem(auction->itemGuidLow);
if (!pItem)
{
auction->DeleteFromDB();
sLog.outError("Auction %u has not a existing item : %u, deleted", auction->Id, auction->itemGuidLow);
delete auction;
continue;
}
auction->auctionHouseEntry = sAuctionHouseStore.LookupEntry(houseid);
if (!houseid)
{
// need for send mail, use goblin auctionhouse
auction->auctionHouseEntry = sAuctionHouseStore.LookupEntry(7);
// Attempt send item back to owner
std::ostringstream msgAuctionCanceledOwner;
msgAuctionCanceledOwner << auction->itemTemplate << ":0:" << AUCTION_CANCELED << ":0:0";
// item will deleted or added to received mail list
MailDraft(msgAuctionCanceledOwner.str(), "") // TODO: fix body
.AddItem(pItem)
.SendMailTo(MailReceiver(ObjectGuid(HIGHGUID_PLAYER, auction->owner)), auction, MAIL_CHECK_MASK_COPIED);
RemoveAItem(auction->itemGuidLow);
auction->DeleteFromDB();
delete auction;
continue;
}
GetAuctionsMap(auction->auctionHouseEntry)->AddAuction(auction);
} while (result->NextRow());
delete result;
sLog.outString();
sLog.outString(">> Loaded %u auctions", AuctionCount);
}
示例6: COUNT
void AuctionHouseMgr::LoadAuctions()
{
QueryResult* result = CharacterDatabase.Query("SELECT COUNT(*) FROM auction");
if (!result)
{
BarGoLink bar(1);
bar.step();
sLog.outString();
sLog.outString(">> Loaded 0 auctions. DB table `auction` is empty.");
return;
}
Field* fields = result->Fetch();
uint32 AuctionCount = fields[0].GetUInt32();
delete result;
if (!AuctionCount)
{
BarGoLink bar(1);
bar.step();
sLog.outString();
sLog.outString(">> Loaded 0 auctions. DB table `auction` is empty.");
return;
}
// 0 1 2 3 4 5 6 7 8 9 10 11 12
result = CharacterDatabase.Query("SELECT id,houseid,itemguid,item_template,item_count,item_randompropertyid,itemowner,buyoutprice,time,buyguid,lastbid,startbid,deposit FROM auction");
if (!result)
{
BarGoLink bar(1);
bar.step();
sLog.outString();
sLog.outString(">> Loaded 0 auctions. DB table `auction` is empty.");
return;
}
BarGoLink bar(AuctionCount);
do
{
fields = result->Fetch();
bar.step();
AuctionEntry* auction = new AuctionEntry;
auction->Id = fields[0].GetUInt32();
uint32 houseid = fields[1].GetUInt32();
auction->itemGuidLow = fields[2].GetUInt32();
auction->itemTemplate = fields[3].GetUInt32();
auction->itemCount = fields[4].GetUInt32();
auction->itemRandomPropertyId = fields[5].GetUInt32();
auction->owner = fields[6].GetUInt32();
auction->buyout = fields[7].GetUInt32();
auction->expireTime = time_t(fields[8].GetUInt64());
auction->bidder = fields[9].GetUInt32();
auction->bid = fields[10].GetUInt32();
auction->startbid = fields[11].GetUInt32();
auction->deposit = fields[12].GetUInt32();
auction->auctionHouseEntry = NULL; // init later
// check if sold item exists for guid
// and item_template in fact (GetAItem will fail if problematic in result check in AuctionHouseMgr::LoadAuctionItems)
Item* pItem = GetAItem(auction->itemGuidLow);
if (!pItem)
{
auction->DeleteFromDB();
sLog.outError("Auction %u has not a existing item : %u, deleted", auction->Id, auction->itemGuidLow);
delete auction;
continue;
}
// overwrite by real item data
if ((auction->itemTemplate != pItem->GetEntry()) ||
(auction->itemCount != pItem->GetCount()) ||
(auction->itemRandomPropertyId != pItem->GetItemRandomPropertyId()))
{
auction->itemTemplate = pItem->GetEntry();
auction->itemCount = pItem->GetCount();
auction->itemRandomPropertyId = pItem->GetItemRandomPropertyId();
// No SQL injection (no strings)
CharacterDatabase.PExecute("UPDATE auction SET item_template = %u, item_count = %u, item_randompropertyid = %i WHERE itemguid = %u",
auction->itemTemplate, auction->itemCount, auction->itemRandomPropertyId, auction->itemGuidLow);
}
auction->auctionHouseEntry = sAuctionHouseStore.LookupEntry(houseid);
if (!auction->auctionHouseEntry)
{
// need for send mail, use goblin auctionhouse
auction->auctionHouseEntry = sAuctionHouseStore.LookupEntry(7);
// Attempt send item back to owner
std::ostringstream msgAuctionCanceledOwner;
msgAuctionCanceledOwner << auction->itemTemplate << ":" << auction->itemRandomPropertyId << ":" << AUCTION_CANCELED;
if (auction->itemGuidLow)
{
RemoveAItem(auction->itemGuidLow);
//.........这里部分代码省略.........
示例7: COUNT
void AuctionHouseMgr::LoadAuctions()
{
QueryResult *result = CharacterDatabase.Query("SELECT COUNT(*) FROM auction");
if( !result )
{
barGoLink bar(1);
bar.step();
sLog.outString();
sLog.outString(">> Loaded 0 auctions. DB table `auction` is empty.");
return;
}
Field *fields = result->Fetch();
uint32 AuctionCount=fields[0].GetUInt32();
delete result;
if(!AuctionCount)
{
barGoLink bar(1);
bar.step();
sLog.outString();
sLog.outString(">> Loaded 0 auctions. DB table `auction` is empty.");
return;
}
result = CharacterDatabase.Query( "SELECT id,houseid,itemguid,item_template,itemowner,buyoutprice,time,buyguid,lastbid,startbid,deposit FROM auction" );
if( !result )
{
barGoLink bar(1);
bar.step();
sLog.outString();
sLog.outString(">> Loaded 0 auctions. DB table `auction` is empty.");
return;
}
barGoLink bar( AuctionCount );
AuctionEntry *auction;
do
{
fields = result->Fetch();
bar.step();
auction = new AuctionEntry;
auction->Id = fields[0].GetUInt32();
uint32 houseid = fields[1].GetUInt32();
auction->item_guidlow = fields[2].GetUInt32();
auction->item_template = fields[3].GetUInt32();
auction->owner = fields[4].GetUInt32();
auction->buyout = fields[5].GetUInt32();
auction->expire_time = fields[6].GetUInt32();
auction->bidder = fields[7].GetUInt32();
auction->bid = fields[8].GetUInt32();
auction->startbid = fields[9].GetUInt32();
auction->deposit = fields[10].GetUInt32();
auction->auctionHouseEntry = NULL; // init later
// check if sold item exists for guid
// and item_template in fact (GetAItem will fail if problematic in result check in AuctionHouseMgr::LoadAuctionItems)
Item* pItem = GetAItem(auction->item_guidlow);
if (!pItem)
{
auction->DeleteFromDB();
sLog.outError("Auction %u has not a existing item : %u, deleted", auction->Id, auction->item_guidlow);
delete auction;
continue;
}
auction->auctionHouseEntry = sAuctionHouseStore.LookupEntry(houseid);
if (!houseid)
{
// need for send mail, use goblin auctionhouse
auction->auctionHouseEntry = sAuctionHouseStore.LookupEntry(7);
// Attempt send item back to owner
std::ostringstream msgAuctionCanceledOwner;
msgAuctionCanceledOwner << auction->item_template << ":0:" << AUCTION_CANCELED << ":0:0";
// item will deleted or added to received mail list
MailDraft(msgAuctionCanceledOwner.str(), "") // TODO: fix body
.AddItem(pItem)
.SendMailTo(MailReceiver(auction->owner), auction, MAIL_CHECK_MASK_COPIED);
RemoveAItem(auction->item_guidlow);
auction->DeleteFromDB();
delete auction;
continue;
}
GetAuctionsMap(auction->auctionHouseEntry)->AddAuction(auction);
} while (result->NextRow());
delete result;
sLog.outString();
sLog.outString( ">> Loaded %u auctions", AuctionCount );
//.........这里部分代码省略.........
示例8: GetAItem
// does not clear ram
void AuctionHouseMgr::SendAuctionWonMail(AuctionEntry* auction)
{
Item* pItem = GetAItem(auction->itemGuidLow);
if (!pItem)
return;
ObjectGuid bidder_guid = ObjectGuid(HIGHGUID_PLAYER, auction->bidder);
Player* bidder = sObjectMgr.GetPlayer(bidder_guid);
uint32 bidder_accId = 0;
ObjectGuid ownerGuid = ObjectGuid(HIGHGUID_PLAYER, auction->owner);
// data for gm.log
if (sWorld.getConfig(CONFIG_BOOL_GM_LOG_TRADE))
{
AccountTypes bidder_security = SEC_PLAYER;
std::string bidder_name;
if (bidder)
{
bidder_accId = bidder->GetSession()->GetAccountId();
bidder_security = bidder->GetSession()->GetSecurity();
bidder_name = bidder->GetName();
}
else
{
bidder_accId = sObjectMgr.GetPlayerAccountIdByGUID(bidder_guid);
bidder_security = bidder_accId ? sAccountMgr.GetSecurity(bidder_accId) : SEC_PLAYER;
if (bidder_security > SEC_PLAYER) // not do redundant DB requests
{
if (!sObjectMgr.GetPlayerNameByGUID(bidder_guid, bidder_name))
bidder_name = sObjectMgr.GetBlizzLikeStringForDBCLocale(LANG_UNKNOWN);
}
}
if (bidder_security > SEC_PLAYER)
{
std::string owner_name;
if (ownerGuid && !sObjectMgr.GetPlayerNameByGUID(ownerGuid, owner_name))
owner_name = sObjectMgr.GetBlizzLikeStringForDBCLocale(LANG_UNKNOWN);
uint32 owner_accid = sObjectMgr.GetPlayerAccountIdByGUID(ownerGuid);
sLog.outCommand(bidder_accId, "GM %s (Account: %u) won item in auction (Entry: %u Count: %u) and pay money: %u. Original owner %s (Account: %u)",
bidder_name.c_str(), bidder_accId, auction->itemTemplate, auction->itemCount, auction->bid, owner_name.c_str(), owner_accid);
}
}
else if (!bidder)
bidder_accId = sObjectMgr.GetPlayerAccountIdByGUID(bidder_guid);
// receiver exist
if (bidder || bidder_accId)
{
std::ostringstream msgAuctionWonSubject;
msgAuctionWonSubject << auction->itemTemplate << ":" << auction->itemRandomPropertyId << ":" << AUCTION_WON;
std::ostringstream msgAuctionWonBody;
msgAuctionWonBody.width(16);
msgAuctionWonBody << std::right << std::hex << auction->owner;
msgAuctionWonBody << std::dec << ":" << auction->bid << ":" << auction->buyout;
DEBUG_LOG("AuctionWon body string : %s", msgAuctionWonBody.str().c_str());
// set owner to bidder (to prevent delete item with sender char deleting)
// owner in `data` will set at mail receive and item extracting
CharacterDatabase.PExecute("UPDATE item_instance SET owner_guid = '%u' WHERE guid='%u'", auction->bidder, auction->itemGuidLow);
if (bidder)
bidder->GetSession()->SendAuctionBidderNotification(auction, true);
RemoveAItem(auction->itemGuidLow); // we have to remove the item, before we delete it !!
auction->itemGuidLow = 0; // pending list will not use guid data
// will delete item or place to receiver mail list
MailDraft(msgAuctionWonSubject.str(), msgAuctionWonBody.str())
.AddItem(pItem)
.SendMailTo(MailReceiver(bidder, bidder_guid), auction, MAIL_CHECK_MASK_COPIED);
}
// receiver not exist
else
{
CharacterDatabase.PExecute("DELETE FROM item_instance WHERE guid='%u'", auction->itemGuidLow);
RemoveAItem(auction->itemGuidLow); // we have to remove the item, before we delete it !!
auction->itemGuidLow = 0;
delete pItem;
}
}