本文整理汇总了C++中Mail::RemoveItem方法的典型用法代码示例。如果您正苦于以下问题:C++ Mail::RemoveItem方法的具体用法?C++ Mail::RemoveItem怎么用?C++ Mail::RemoveItem使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mail
的用法示例。
在下文中一共展示了Mail::RemoveItem方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: HandleMailTakeItem
/**
* Handles the packet sent by the client when taking an item from the mail.
*/
void WorldSession::HandleMailTakeItem(WorldPacket & recv_data )
{
ObjectGuid mailboxGuid;
uint32 mailId;
uint32 itemId;
recv_data >> mailboxGuid;
recv_data >> mailId;
recv_data >> itemId; // item guid low
if (!CheckMailBox(mailboxGuid))
return;
Player* pl = _player;
Mail* m = pl->GetMail(mailId);
if(!m || m->state == MAIL_STATE_DELETED || m->deliver_time > time(NULL))
{
pl->SendMailResult(mailId, MAIL_ITEM_TAKEN, MAIL_ERR_INTERNAL_ERROR);
return;
}
// prevent cheating with skip client money check
if(pl->GetMoney() < m->COD)
{
pl->SendMailResult(mailId, MAIL_ITEM_TAKEN, MAIL_ERR_NOT_ENOUGH_MONEY);
return;
}
Item *it = pl->GetMItem(itemId);
ItemPosCountVec dest;
InventoryResult msg = _player->CanStoreItem( NULL_BAG, NULL_SLOT, dest, it, false );
if (msg == EQUIP_ERR_OK)
{
m->RemoveItem(itemId);
m->removedItems.push_back(itemId);
if (m->COD > 0) // if there is COD, take COD money from player and send them to sender by mail
{
ObjectGuid sender_guid = ObjectGuid(HIGHGUID_PLAYER, m->sender);
Player *sender = sObjectMgr.GetPlayer(sender_guid);
uint32 sender_accId = 0;
if( GetSecurity() > SEC_PLAYER && sWorld.getConfig(CONFIG_BOOL_GM_LOG_TRADE) )
{
std::string sender_name;
if(sender)
{
sender_accId = sender->GetSession()->GetAccountId();
sender_name = sender->GetName();
}
else if (sender_guid)
{
// can be calculated early
sender_accId = sAccountMgr.GetPlayerAccountIdByGUID(sender_guid);
if(!sAccountMgr.GetPlayerNameByGUID(sender_guid, sender_name))
sender_name = sObjectMgr.GetMangosStringForDBCLocale(LANG_UNKNOWN);
}
sLog.outCommand(GetAccountId(), "GM %s (Account: %u) receive mail item: %s (Entry: %u Count: %u) and send COD money: %u to player: %s (Account: %u)",
GetPlayerName(), GetAccountId(), it->GetProto()->Name1, it->GetEntry(), it->GetCount(), m->COD, sender_name.c_str(), sender_accId);
}
else if (!sender)
sender_accId = sAccountMgr.GetPlayerAccountIdByGUID(sender_guid);
// check player existence
if(sender || sender_accId)
{
MailDraft(m->subject, "")
.SetMoney(m->COD)
.SendMailTo(MailReceiver(sender, sender_guid), _player, MAIL_CHECK_MASK_COD_PAYMENT);
}
pl->ModifyMoney( -int32(m->COD) );
}
m->COD = 0;
m->state = MAIL_STATE_CHANGED;
pl->m_mailsUpdated = true;
pl->RemoveMItem(it->GetGUIDLow());
uint32 count = it->GetCount(); // save counts before store and possible merge with deleting
pl->MoveItemToInventory(dest, it, true);
CharacterDatabase.BeginTransaction();
pl->SaveInventoryAndGoldToDB();
pl->_SaveMail();
CharacterDatabase.CommitTransaction();
pl->SendMailResult(mailId, MAIL_ITEM_TAKEN, MAIL_OK, 0, itemId, count);
}
else
pl->SendMailResult(mailId, MAIL_ITEM_TAKEN, MAIL_ERR_EQUIP_ERROR, msg);
}