本文整理汇总了C++中Item::GetEntry方法的典型用法代码示例。如果您正苦于以下问题:C++ Item::GetEntry方法的具体用法?C++ Item::GetEntry怎么用?C++ Item::GetEntry使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Item
的用法示例。
在下文中一共展示了Item::GetEntry方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: HandleTransmogrifyItems
void WorldSession::HandleTransmogrifyItems(WorldPackets::Item::TransmogrifyItems& transmogrifyItems)
{
Player* player = GetPlayer();
// Validate
if (!player->GetNPCIfCanInteractWith(transmogrifyItems.Npc, UNIT_NPC_FLAG_TRANSMOGRIFIER))
{
TC_LOG_DEBUG("network", "WORLD: HandleTransmogrifyItems - %s not found or player can't interact with it.", transmogrifyItems.Npc.ToString().c_str());
return;
}
int64 cost = 0;
std::unordered_map<Item*, Item*> transmogItems;
std::unordered_map<Item*, std::pair<VoidStorageItem*, BonusData>> transmogVoidItems;
std::vector<Item*> resetAppearanceItems;
for (WorldPackets::Item::TransmogrifyItem const& transmogItem : transmogrifyItems.Items)
{
// slot of the transmogrified item
if (transmogItem.Slot >= EQUIPMENT_SLOT_END)
{
TC_LOG_DEBUG("network", "WORLD: HandleTransmogrifyItems - Player (%s, name: %s) tried to transmogrify wrong slot (%u) when transmogrifying items.", player->GetGUID().ToString().c_str(), player->GetName().c_str(), transmogItem.Slot);
return;
}
// transmogrified item
Item* itemTransmogrified = player->GetItemByPos(INVENTORY_SLOT_BAG_0, transmogItem.Slot);
if (!itemTransmogrified)
{
TC_LOG_DEBUG("network", "WORLD: HandleTransmogrifyItems - Player (%s, name: %s) tried to transmogrify an invalid item in a valid slot (slot: %u).", player->GetGUID().ToString().c_str(), player->GetName().c_str(), transmogItem.Slot);
return;
}
WorldPackets::Item::ItemInstance itemInstance;
BonusData const* bonus = nullptr;
if (transmogItem.SrcItemGUID)
{
// guid of the transmogrifier item
Item* itemTransmogrifier = player->GetItemByGuid(*transmogItem.SrcItemGUID);
if (!itemTransmogrifier)
{
TC_LOG_DEBUG("network", "WORLD: HandleTransmogrifyItems - Player (%s, name: %s) tried to transmogrify with an invalid item (%s).", player->GetGUID().ToString().c_str(), player->GetName().c_str(), transmogItem.SrcItemGUID->ToString().c_str());
return;
}
itemInstance.Initialize(itemTransmogrifier);
bonus = itemTransmogrifier->GetBonus();
transmogItems[itemTransmogrified] = itemTransmogrifier;
}
else if (transmogItem.SrcVoidItemGUID)
{
// guid of the transmogrifier item
uint8 slot;
VoidStorageItem* itemTransmogrifier = player->GetVoidStorageItem(transmogItem.SrcVoidItemGUID->GetCounter(), slot);
if (!itemTransmogrifier)
{
TC_LOG_DEBUG("network", "WORLD: HandleTransmogrifyItems - Player (%s, name: %s) tried to transmogrify with an invalid void storage item (%s).", player->GetGUID().ToString().c_str(), player->GetName().c_str(), transmogItem.SrcVoidItemGUID->ToString().c_str());
return;
}
itemInstance.Initialize(itemTransmogrifier);
std::pair<VoidStorageItem*, BonusData>& transmogData = transmogVoidItems[itemTransmogrified];
transmogData.first = itemTransmogrifier;
transmogData.second.Initialize(itemInstance);
bonus = &transmogData.second;
}
else
{
resetAppearanceItems.push_back(itemTransmogrified);
continue;
}
// entry of transmogrifier and from packet
if (itemInstance != transmogItem.Item)
{
TC_LOG_DEBUG("network", "WORLD: HandleTransmogrifyItems - Player (%s, name: %s) tried to transmogrify with an invalid item instance data for %s.", player->GetGUID().ToString().c_str(), player->GetName().c_str(), transmogItem.SrcItemGUID->ToString().c_str());
return;
}
// validity of the transmogrification items
if (!Item::CanTransmogrifyItemWithItem(itemTransmogrified, transmogItem.Item, bonus))
{
TC_LOG_DEBUG("network", "WORLD: HandleTransmogrifyItems - Player (%s, name: %s) failed CanTransmogrifyItemWithItem (%u with %u).", player->GetGUID().ToString().c_str(), player->GetName().c_str(), itemTransmogrified->GetEntry(), transmogItem.Item.ItemID);
return;
}
// add cost
cost += itemTransmogrified->GetSpecialPrice();
}
if (cost) // 0 cost if reverting look
{
if (!player->HasEnoughMoney(cost))
return;
player->ModifyMoney(-cost);
}
// Everything is fine, proceed
for (auto& transmogPair : transmogItems)
{
Item* transmogrified = transmogPair.first;
//.........这里部分代码省略.........
示例2: HandleWrapItemOpcode
void WorldSession::HandleWrapItemOpcode(WorldPacket& recv_data)
{
DEBUG_LOG("Received opcode CMSG_WRAP_ITEM");
uint8 gift_bag, gift_slot, item_bag, item_slot;
// recv_data.hexlike();
recv_data >> gift_bag >> gift_slot; // paper
recv_data >> item_bag >> item_slot; // item
DEBUG_LOG("WRAP: receive gift_bag = %u, gift_slot = %u, item_bag = %u, item_slot = %u", gift_bag, gift_slot, item_bag, item_slot);
Item* gift = _player->GetItemByPos(gift_bag, gift_slot);
if (!gift)
{
_player->SendEquipError(EQUIP_ERR_ITEM_NOT_FOUND, gift, nullptr);
return;
}
// cheating: non-wrapper wrapper (all empty wrappers is stackable)
if (!(gift->GetProto()->Flags & ITEM_FLAG_IS_WRAPPER) || gift->GetMaxStackCount() == 1)
{
_player->SendEquipError(EQUIP_ERR_ITEM_NOT_FOUND, gift, nullptr);
return;
}
Item* item = _player->GetItemByPos(item_bag, item_slot);
if (!item)
{
_player->SendEquipError(EQUIP_ERR_ITEM_NOT_FOUND, item, nullptr);
return;
}
if (item == gift) // not possible with packet from real client
{
_player->SendEquipError(EQUIP_ERR_WRAPPED_CANT_BE_WRAPPED, item, nullptr);
return;
}
if (item->IsEquipped())
{
_player->SendEquipError(EQUIP_ERR_EQUIPPED_CANT_BE_WRAPPED, item, nullptr);
return;
}
if (item->GetGuidValue(ITEM_FIELD_GIFTCREATOR)) // HasFlag(ITEM_FIELD_FLAGS, ITEM_DYNFLAG_WRAPPED);
{
_player->SendEquipError(EQUIP_ERR_WRAPPED_CANT_BE_WRAPPED, item, nullptr);
return;
}
if (item->IsBag())
{
_player->SendEquipError(EQUIP_ERR_BAGS_CANT_BE_WRAPPED, item, nullptr);
return;
}
if (item->IsSoulBound())
{
_player->SendEquipError(EQUIP_ERR_BOUND_CANT_BE_WRAPPED, item, nullptr);
return;
}
if (item->GetMaxStackCount() != 1)
{
_player->SendEquipError(EQUIP_ERR_STACKABLE_CANT_BE_WRAPPED, item, nullptr);
return;
}
// maybe not correct check (it is better than nothing)
if (item->GetProto()->MaxCount > 0)
{
_player->SendEquipError(EQUIP_ERR_UNIQUE_CANT_BE_WRAPPED, item, nullptr);
return;
}
CharacterDatabase.BeginTransaction();
CharacterDatabase.PExecute("INSERT INTO character_gifts VALUES ('%u', '%u', '%u', '%u')", item->GetOwnerGuid().GetCounter(), item->GetGUIDLow(), item->GetEntry(), item->GetUInt32Value(ITEM_FIELD_FLAGS));
item->SetEntry(gift->GetEntry());
switch (item->GetEntry())
{
case 5042: item->SetEntry(5043); break;
case 5048: item->SetEntry(5044); break;
case 17303: item->SetEntry(17302); break;
case 17304: item->SetEntry(17305); break;
case 17307: item->SetEntry(17308); break;
case 21830: item->SetEntry(21831); break;
}
item->SetGuidValue(ITEM_FIELD_GIFTCREATOR, _player->GetObjectGuid());
item->SetUInt32Value(ITEM_FIELD_FLAGS, ITEM_DYNFLAG_WRAPPED);
item->SetState(ITEM_CHANGED, _player);
if (item->GetState() == ITEM_NEW) // save new item, to have alway for `character_gifts` record in `item_instance`
{
// after save it will be impossible to remove the item from the queue
item->RemoveFromUpdateQueueOf(_player);
item->SaveToDB(); // item gave inventory record unchanged and can be save standalone
}
//.........这里部分代码省略.........
示例3: Finalize
//.........这里部分代码省略.........
while(_player == NULL && pitr != m_passRolls.end())
{
_player = _mgr->GetPlayer( (*(pitr)) );
++pitr;
}
if( _player != NULL )
{
if(_player->InGroup())
_player->GetGroup()->SendPacketToAll(&data);
else
_player->GetSession()->SendPacket(&data);
}
/* item can now be looted by anyone :) */
pLoot->items.at(_slotid).passed = true;
delete this;
return;
}
pLoot->items.at(_slotid).roll = 0;
data.Initialize(SMSG_LOOT_ROLL_WON);
data << _guid << _slotid << _itemid << _randomsuffixid << _randompropertyid;
data << _player->GetGUID() << uint8(highest) << uint8(hightype);
if(_player->InGroup())
_player->GetGroup()->SendPacketToAll(&data);
else
_player->GetSession()->SendPacket(&data);
if(hightype == DISENCHANT)
{
//generate Disenchantingloot
Item * pItem = objmgr.CreateItem( itemid, _player);
lootmgr.FillItemLoot(&pItem->m_loot, pItem->GetEntry(), _player->GetTeam());
//add loot
for(std::vector<__LootItem>::iterator iter=pItem->m_loot.items.begin();iter != pItem->m_loot.items.end();iter++)
{
itemid =iter->item.itemproto->ItemId;
Item * Titem = objmgr.CreateItem( itemid, _player);
if( Titem == NULLITEM )
continue;
if( !_player->GetItemInterface()->AddItemToFreeSlot(Titem) )
{
_player->GetSession()->SendNotification("No free slots were found in your inventory, item has been mailed.");
sMailSystem.DeliverMessage(MAILTYPE_NORMAL, _player->GetGUID(), _player->GetGUID(), "Loot Roll", "Here is your reward.", 0, 0, itemid, 1, true);
}
Titem->DeleteMe();
Titem = NULLITEM;
}
pItem->DeleteMe();
pItem = NULLITEM;
// Set a looter, doesn't matter who.
pLoot->items.at(_slotid).has_looted.insert(_player->GetLowGUID());
//Send "finish" packet
data.Initialize(SMSG_LOOT_REMOVED);
data << uint8(_slotid);
Player* plr;
for(LooterSet::iterator itr = pLoot->looters.begin(); itr != pLoot->looters.end(); itr++)
{
if((plr = _player->GetMapMgr()->GetPlayer(*itr)))
plr->GetSession()->SendPacket(&data);
}
示例4: HandleUseItemOpcode
void WorldSession::HandleUseItemOpcode(WorldPacket& recvPacket)
{
uint8 bagIndex, slot;
uint8 unk_flags; // flags (if 0x02 - some additional data are received)
uint8 cast_count; // next cast if exists (single or not)
uint64 item_guid;
uint32 glyphIndex; // something to do with glyphs?
uint32 spellid; // casted spell id
recvPacket >> bagIndex >> slot >> cast_count >> spellid >> item_guid >> glyphIndex >> unk_flags;
// TODO: add targets.read() check
Player* pUser = _player;
// ignore for remote control state
if (!pUser->IsSelfMover())
{
recvPacket.rpos(recvPacket.wpos()); // prevent spam at not read packet tail
return;
}
// reject fake data
if (glyphIndex >= MAX_GLYPH_SLOT_INDEX)
{
recvPacket.rpos(recvPacket.wpos()); // prevent spam at not read packet tail
pUser->SendEquipError(EQUIP_ERR_ITEM_NOT_FOUND, NULL, NULL );
return;
}
Item *pItem = pUser->GetItemByPos(bagIndex, slot);
if (!pItem)
{
recvPacket.rpos(recvPacket.wpos()); // prevent spam at not read packet tail
pUser->SendEquipError(EQUIP_ERR_ITEM_NOT_FOUND, NULL, NULL );
return;
}
if (pItem->GetGUID() != item_guid)
{
recvPacket.rpos(recvPacket.wpos()); // prevent spam at not read packet tail
pUser->SendEquipError(EQUIP_ERR_ITEM_NOT_FOUND, NULL, NULL );
return;
}
DETAIL_LOG("WORLD: CMSG_USE_ITEM packet, bagIndex: %u, slot: %u, cast_count: %u, spellid: %u, Item: %u, glyphIndex: %u, unk_flags: %u, data length = %i", bagIndex, slot, cast_count, spellid, pItem->GetEntry(), glyphIndex, unk_flags, (uint32)recvPacket.size());
ItemPrototype const *proto = pItem->GetProto();
if (!proto)
{
recvPacket.rpos(recvPacket.wpos()); // prevent spam at not read packet tail
pUser->SendEquipError(EQUIP_ERR_ITEM_NOT_FOUND, pItem, NULL );
return;
}
// some item classes can be used only in equipped state
if (proto->InventoryType != INVTYPE_NON_EQUIP && !pItem->IsEquipped())
{
recvPacket.rpos(recvPacket.wpos()); // prevent spam at not read packet tail
pUser->SendEquipError(EQUIP_ERR_ITEM_NOT_FOUND, pItem, NULL );
return;
}
uint8 msg = pUser->CanUseItem(pItem);
if (msg != EQUIP_ERR_OK)
{
recvPacket.rpos(recvPacket.wpos()); // prevent spam at not read packet tail
pUser->SendEquipError( msg, pItem, NULL );
return;
}
// not allow use item from trade (cheat way only)
if (pItem->IsInTrade())
{
recvPacket.rpos(recvPacket.wpos()); // prevent spam at not read packet tail
pUser->SendEquipError(EQUIP_ERR_ITEM_NOT_FOUND, pItem, NULL );
return;
}
// only allow conjured consumable, bandage, poisons (all should have the 2^21 item flag set in DB)
if (proto->Class == ITEM_CLASS_CONSUMABLE &&
!(proto->Flags & ITEM_FLAGS_USEABLE_IN_ARENA) &&
pUser->InArena())
{
recvPacket.rpos(recvPacket.wpos()); // prevent spam at not read packet tail
pUser->SendEquipError(EQUIP_ERR_NOT_DURING_ARENA_MATCH,pItem,NULL);
return;
}
if (pUser->isInCombat())
{
for(int i = 0; i < MAX_ITEM_PROTO_SPELLS; ++i)
{
if (SpellEntry const *spellInfo = sSpellStore.LookupEntry(proto->Spells[i].SpellId))
{
if (IsNonCombatSpell(spellInfo))
{
recvPacket.rpos(recvPacket.wpos()); // prevent spam at not read packet tail
pUser->SendEquipError(EQUIP_ERR_NOT_IN_COMBAT,pItem,NULL);
return;
}
//.........这里部分代码省略.........
示例5: HandleAuctionSellItem
//.........这里部分代码省略.........
}
}
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, ERR_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().c_str(), GetAccountId(), item->GetTemplate()->Name1.c_str(), item->GetEntry(), item->GetCount());
}
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;
AH->buyout = buyout;
AH->expire_time = time(NULL) + auctionTime;
AH->deposit = deposit;
AH->auctionHouseEntry = auctionHouseEntry;
sLog->outInfo(LOG_FILTER_NETWORKIO, "CMSG_AUCTION_SELL_ITEM: Player %s (guid %d) is selling item %s entry %u (guid %d) to auctioneer %u with count %u with initial bid %u with buyout %u and with time %u (in sec) in auctionhouse %u", _player->GetName().c_str(), _player->GetGUIDLow(), item->GetTemplate()->Name1.c_str(), item->GetEntry(), item->GetGUIDLow(), AH->auctioneer, item->GetCount(), bid, buyout, auctionTime, AH->GetHouseId());
sAuctionMgr->AddAItem(item);
auctionHouse->AddAuction(AH);
_player->MoveItemFromInventory(item->GetBagSlot(), item->GetSlot(), true);
SQLTransaction trans = CharacterDatabase.BeginTransaction();
item->DeleteFromInventoryDB(trans);
item->SaveToDB(trans);
AH->SaveToDB(trans);
_player->SaveInventoryAndGoldToDB(trans);
CharacterDatabase.CommitTransaction(trans);
SendAuctionCommandResult(AH->Id, AUCTION_SELL_ITEM, ERR_AUCTION_OK);
GetPlayer()->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_CREATE_AUCTION, 1);
return;
}
示例6: HandleGetMailList
//called when player lists his received mails
void WorldSession::HandleGetMailList(WorldPacket & recv_data )
{
uint64 mailbox;
recv_data >> mailbox;
if (!GetPlayer()->GetGameObjectIfCanInteractWith(mailbox, GAMEOBJECT_TYPE_MAILBOX))
return;
// client can't work with packets > max int16 value
const uint32 maxPacketSize = 32767;
uint32 mailsCount = 0; // send to client mails amount
uint32 realCount = 0; // real mails amount
WorldPacket data(SMSG_MAIL_LIST_RESULT, 200); // guess size
data << uint32(0); // real mail's count
data << uint8(0); // mail's count
time_t cur_time = time(NULL);
for(PlayerMails::iterator itr = _player->GetMailBegin(); itr != _player->GetMailEnd(); ++itr)
{
// packet send mail count as uint8, prevent overflow
if(mailsCount >= 254)
{
realCount += 1;
continue;
}
// skip deleted or not delivered (deliver delay not expired) mails
if ((*itr)->state == MAIL_STATE_DELETED || cur_time < (*itr)->deliver_time)
continue;
uint8 item_count = (*itr)->items.size(); // max count is MAX_MAIL_ITEMS (12)
size_t next_mail_size = 2+4+1+((*itr)->messageType == MAIL_NORMAL ? 8 : 4)+4*8+((*itr)->subject.size()+1)+1+item_count*(1+4+4+7*3*4+4+4+4+4+4+4+1);
if(data.wpos()+next_mail_size > maxPacketSize)
{
realCount += 1;
continue;
}
uint32 show_flags = 0;
if ((*itr)->messageType != MAIL_NORMAL)
show_flags |= MAIL_SHOW_DELETE;
if ((*itr)->messageType == MAIL_AUCTION)
show_flags |= MAIL_SHOW_AUCTION;
if ((*itr)->HasItems() && (*itr)->messageType == MAIL_NORMAL)
show_flags |= MAIL_SHOW_RETURN;
data << uint16(next_mail_size); // Message size
data << uint32((*itr)->messageID); // Message ID
data << uint8((*itr)->messageType); // Message Type
switch((*itr)->messageType)
{
case MAIL_NORMAL: // sender guid
data << uint64(MAKE_NEW_GUID((*itr)->sender, 0, HIGHGUID_PLAYER));
break;
case MAIL_CREATURE:
case MAIL_GAMEOBJECT:
case MAIL_AUCTION:
data << uint32((*itr)->sender); // creature/gameobject entry, auction id
break;
case MAIL_ITEM: // item entry (?) sender = "Unknown", NYI
data << uint32(0); // item entry
break;
}
data << uint32((*itr)->COD); // COD
data << uint32((*itr)->itemTextId); // sure about this
data << uint32(0); // unknown
data << uint32((*itr)->stationery); // stationery (Stationery.dbc)
data << uint32((*itr)->money); // Gold
data << uint32(show_flags); // unknown, 0x4 - auction, 0x10 - normal
data << float(((*itr)->expire_time-time(NULL))/DAY);// Time
data << uint32((*itr)->mailTemplateId); // mail template (MailTemplate.dbc)
data << (*itr)->subject; // Subject string - once 00, when mail type = 3
data << uint8(item_count); // client limit is 0x10
for(uint8 i = 0; i < item_count; ++i)
{
Item *item = _player->GetMItem((*itr)->items[i].item_guid);
// item index (0-6?)
data << uint8(i);
// item guid low?
data << uint32(item ? item->GetGUIDLow() : 0);
// entry
data << uint32(item ? item->GetEntry() : 0);
for(uint8 j = 0; j < MAX_INSPECTED_ENCHANTMENT_SLOT; ++j)
{
// unsure
data << uint32(item ? item->GetEnchantmentCharges((EnchantmentSlot)j) : 0);
// unsure
data << uint32(item ? item->GetEnchantmentDuration((EnchantmentSlot)j) : 0);
// unsure
data << uint32(item ? item->GetEnchantmentId((EnchantmentSlot)j) : 0);
}
//.........这里部分代码省略.........
示例7: Transmogrify
TransmogTrinityStrings Transmogrification::Transmogrify(Player* player, uint64 itemGUID, uint8 slot, /*uint32 newEntry, */bool no_cost)
{
int32 cost = 0;
// slot of the transmogrified item
if (slot >= EQUIPMENT_SLOT_END)
{
TC_LOG_DEBUG("network", "WORLD: HandleTransmogrifyItems - Player (GUID: %u, name: %s) tried to transmogrify an item (lowguid: %u) with a wrong slot (%u) when transmogrifying items.", player->GetGUIDLow(), player->GetName().c_str(), GUID_LOPART(itemGUID), slot);
return LANG_ERR_TRANSMOG_INVALID_SLOT;
}
/* // GET FROM itemTransmogrifier
// entry of the transmogrifier item, if it's not 0
if (newEntry)
{
ItemTemplate const* proto = sObjectMgr->GetItemTemplate(newEntry);
if (!proto)
{
TC_LOG_DEBUG(LOG_FILTER_NETWORKIO, "WORLD: HandleTransmogrifyItems - Player (GUID: %u, name: %s) tried to transmogrify to an invalid item (entry: %u).", player->GetGUIDLow(), player->GetName().c_str(), newEntry);
return LANG_ERR_TRANSMOG_INVALID_SRC_ENTRY;
}
}
*/
Item* itemTransmogrifier = NULL;
// guid of the transmogrifier item, if it's not 0
if (itemGUID)
{
itemTransmogrifier = player->GetItemByGuid(itemGUID);
if (!itemTransmogrifier)
{
TC_LOG_DEBUG("network", "WORLD: HandleTransmogrifyItems - Player (GUID: %u, name: %s) tried to transmogrify with an invalid item (lowguid: %u).", player->GetGUIDLow(), player->GetName().c_str(), GUID_LOPART(itemGUID));
return LANG_ERR_TRANSMOG_MISSING_SRC_ITEM;
}
}
// transmogrified item
Item* itemTransmogrified = player->GetItemByPos(INVENTORY_SLOT_BAG_0, slot);
if (!itemTransmogrified)
{
TC_LOG_DEBUG("network", "WORLD: HandleTransmogrifyItems - Player (GUID: %u, name: %s) tried to transmogrify an invalid item in a valid slot (slot: %u).", player->GetGUIDLow(), player->GetName().c_str(), slot);
return LANG_ERR_TRANSMOG_MISSING_DEST_ITEM;
}
// uint16 tempDest;
//// has to be able to equip item transmogrified item
//if (!player->CanEquipItem(slot, tempDest, itemTransmogrified, true, true))
//{
// TC_LOG_DEBUG(LOG_FILTER_NETWORKIO, "WORLD: HandleTransmogrifyItems - Player (GUID: %u, name: %s) can't equip the item to be transmogrified (slot: %u, entry: %u).", player->GetGUIDLow(), player->GetName().c_str(), slot, itemTransmogrified->GetEntry());
// return;
//}
//
//// has to be able to equip item transmogrifier item
//if (!player->CanEquipItem(slot, tempDest, itemTransmogrifier, true, true))
//{
// TC_LOG_DEBUG(LOG_FILTER_NETWORKIO, "WORLD: HandleTransmogrifyItems - Player (GUID: %u, name: %s) can't equip the transmogrifier item (slot: %u, entry: %u).", player->GetGUIDLow(), player->GetName().c_str(), slot, itemTransmogrifier->GetEntry());
// return;
//}
if (!itemTransmogrifier) // reset look newEntry
{
// itemTransmogrified->ClearEnchantment(TRANSMOGRIFY_ENCHANTMENT_SLOT);
// player->SetVisibleItemSlot(slot, itemTransmogrified);
// Custom
DeleteFakeEntry(player, slot, itemTransmogrified);
}
else
{
if (!CanTransmogrifyItemWithItem(player, itemTransmogrified->GetTemplate(), itemTransmogrifier->GetTemplate()))
{
TC_LOG_DEBUG("network", "WORLD: HandleTransmogrifyItems - Player (GUID: %u, name: %s) failed CanTransmogrifyItemWithItem (%u with %u).", player->GetGUIDLow(), player->GetName().c_str(), itemTransmogrified->GetEntry(), itemTransmogrifier->GetEntry());
return LANG_ERR_TRANSMOG_INVALID_ITEMS;
}
if (!no_cost)
{
cost = GetSpecialPrice(itemTransmogrified->GetTemplate());
cost *= ScaledCostModifier;
cost += CopperCost;
if (!player->HasEnoughMoney(cost))
return LANG_ERR_TRANSMOG_NOT_ENOUGH_MONEY;
if (RequireToken)
{
if (player->HasItemCount(TokenEntry, TokenAmount))
player->DestroyItemCount(TokenEntry, TokenAmount, true);
else
return LANG_ERR_TRANSMOG_NOT_ENOUGH_TOKENS;
}
}
// All okay, proceed
// itemTransmogrified->SetEnchantment(TRANSMOGRIFY_ENCHANTMENT_SLOT, newEntry, 0, 0);
// player->SetVisibleItemSlot(slot, itemTransmogrified);
// Custom
SetFakeEntry(player, itemTransmogrifier->GetEntry(), slot, itemTransmogrified); // newEntry
itemTransmogrified->UpdatePlayedTime(player);
//.........这里部分代码省略.........
示例8: HandleSendMail
//.........这里部分代码省略.........
Item* item = player->GetItemByGuid(itemGUIDs[i]);
// prevent sending bag with items (cheat: can be placed in bag after adding equipped empty bag to mail)
if (!item)
{
player->SendMailResult(0, MAIL_SEND, MAIL_ERR_MAIL_ATTACHMENT_INVALID);
return;
}
if (!item->CanBeTraded(true))
{
player->SendMailResult(0, MAIL_SEND, MAIL_ERR_EQUIP_ERROR, EQUIP_ERR_MAIL_BOUND_ITEM);
return;
}
if (item->IsBoundAccountWide() && item->IsSoulBound() && player->GetSession()->GetAccountId() != rc_account)
{
player->SendMailResult(0, MAIL_SEND, MAIL_ERR_EQUIP_ERROR, EQUIP_ERR_ARTEFACTS_ONLY_FOR_OWN_CHARACTERS);
return;
}
if (item->GetTemplate()->Flags & ITEM_PROTO_FLAG_CONJURED || item->GetUInt32Value(ITEM_FIELD_DURATION))
{
player->SendMailResult(0, MAIL_SEND, MAIL_ERR_EQUIP_ERROR, EQUIP_ERR_MAIL_BOUND_ITEM);
return;
}
if (COD && item->HasFlag(ITEM_FIELD_FLAGS, ITEM_FLAG_WRAPPED))
{
player->SendMailResult(0, MAIL_SEND, MAIL_ERR_CANT_SEND_WRAPPED_COD);
return;
}
if (item->IsNotEmptyBag())
{
player->SendMailResult(0, MAIL_SEND, MAIL_ERR_EQUIP_ERROR, EQUIP_ERR_CAN_ONLY_DO_WITH_EMPTY_BAGS);
return;
}
items[i] = item;
}
player->SendMailResult(0, MAIL_SEND, MAIL_OK);
player->ModifyMoney(-int32(reqmoney));
player->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_GOLD_SPENT_FOR_MAIL, cost);
bool needItemDelay = false;
MailDraft draft(subject, body);
SQLTransaction trans = CharacterDatabase.BeginTransaction();
if (items_count > 0 || money > 0)
{
if (items_count > 0)
{
for (uint8 i = 0; i < items_count; ++i)
{
Item* item = items[i];
if (!AccountMgr::IsPlayerAccount(GetSecurity()) && sWorld->getBoolConfig(CONFIG_GM_LOG_TRADE))
{
sLog->outCommand(GetAccountId(), "GM %s (Account: %u) mail item: %s (Entry: %u Count: %u) to player: %s (Account: %u)",
GetPlayerName(), GetAccountId(), item->GetTemplate()->Name1.c_str(), item->GetEntry(), item->GetCount(), receiver.c_str(), rc_account);
}
item->SetNotRefundable(GetPlayer()); // makes the item no longer refundable
player->MoveItemFromInventory(items[i]->GetBagSlot(), item->GetSlot(), true);
item->DeleteFromInventoryDB(trans); // deletes item from character's inventory
item->SetOwnerGUID(rc);
item->SaveToDB(trans); // recursive and not have transaction guard into self, item not in inventory and can be save standalone
draft.AddItem(item);
}
// if item send to character at another account, then apply item delivery delay
needItemDelay = player->GetSession()->GetAccountId() != rc_account;
}
if (money > 0 && !AccountMgr::IsPlayerAccount(GetSecurity()) && sWorld->getBoolConfig(CONFIG_GM_LOG_TRADE))
{
sLog->outCommand(GetAccountId(), "GM %s (Account: %u) mail money: %u to player: %s (Account: %u)",
GetPlayerName(), GetAccountId(), money, receiver.c_str(), rc_account);
}
}
// If theres is an item, there is a one hour delivery delay if sent to another account's character.
uint32 deliver_delay = needItemDelay ? sWorld->getIntConfig(CONFIG_MAIL_DELIVERY_DELAY) : 0;
// will delete item or place to receiver mail list
draft
.AddMoney(money)
.AddCOD(COD)
.SendMailTo(trans, MailReceiver(receive, GUID_LOPART(rc)), MailSender(player), body.empty() ? MAIL_CHECK_MASK_COPIED : MAIL_CHECK_MASK_HAS_BODY, deliver_delay);
player->SaveInventoryAndGoldToDB(trans);
CharacterDatabase.CommitTransaction(trans);
}
示例9: SendAuctionWonMail
//does not clear ram
void AuctionHouseMgr::SendAuctionWonMail(AuctionEntry* auction, SQLTransaction& trans)
{
Item* pItem = GetAItem(auction->itemGUIDLow);
if (!pItem)
return;
uint32 bidderAccId = 0;
uint64 bidderGuid = MAKE_NEW_GUID(auction->bidder, 0, HIGHGUID_PLAYER);
Player* bidder = ObjectAccessor::FindPlayer(bidderGuid);
// data for gm.log
std::string bidderName;
bool logGmTrade = false;
if (bidder)
{
bidderAccId = bidder->GetSession()->GetAccountId();
bidderName = bidder->GetName();
logGmTrade = bidder->GetSession()->HasPermission(RBAC_PERM_LOG_GM_TRADE);
}
else
{
bidderAccId = sObjectMgr->GetPlayerAccountIdByGUID(bidderGuid);
logGmTrade = AccountMgr::HasPermission(bidderAccId, RBAC_PERM_LOG_GM_TRADE, realmID);
if (logGmTrade && !sObjectMgr->GetPlayerNameByGUID(bidderGuid, bidderName))
bidderName = sObjectMgr->GetTrinityStringForDBCLocale(LANG_UNKNOWN);
}
if (logGmTrade)
{
std::string ownerName;
if (!sObjectMgr->GetPlayerNameByGUID(auction->owner, ownerName))
ownerName = sObjectMgr->GetTrinityStringForDBCLocale(LANG_UNKNOWN);
uint32 ownerAccId = sObjectMgr->GetPlayerAccountIdByGUID(auction->owner);
sLog->outCommand(bidderAccId, "GM %s (Account: %u) won item in auction: %s (Entry: %u Count: %u) and pay money: %u. Original owner %s (Account: %u)",
bidderName.c_str(), bidderAccId, pItem->GetTemplate()->Name1.c_str(), pItem->GetEntry(), pItem->GetCount(), auction->bid, ownerName.c_str(), ownerAccId);
}
// receiver exist
if (bidder || bidderAccId)
{
// set owner to bidder (to prevent delete item with sender char deleting)
// owner in `data` will set at mail receive and item extracting
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_ITEM_OWNER);
stmt->setUInt32(0, auction->bidder);
stmt->setUInt32(1, pItem->GetGUIDLow());
trans->Append(stmt);
if (bidder)
{
bidder->GetSession()->SendAuctionBidderNotification(auction->GetHouseId(), auction->Id, bidderGuid, 0, 0, auction->itemEntry);
// FIXME: for offline player need also
bidder->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_WON_AUCTIONS, 1);
}
MailDraft(auction->BuildAuctionMailSubject(AUCTION_WON), AuctionEntry::BuildAuctionMailBody(auction->owner, auction->bid, auction->buyout, 0, 0))
.AddItem(pItem)
.SendMailTo(trans, MailReceiver(bidder, auction->bidder), auction, MAIL_CHECK_MASK_COPIED);
}
}
示例10: AddMessageToListingPacket
bool Mailbox::AddMessageToListingPacket(WorldPacket& data,MailMessage *msg)
{
uint8 i = 0;
uint32 j;
size_t pos;
vector<uint64>::iterator itr;
Item* pItem;
// add stuff
if(msg->deleted_flag || msg->Expired() || (uint32)UNIXTIME < msg->delivery_time)
return false;
uint8 guidsize;
if( msg->message_type )
guidsize = 4;
else
guidsize = 8;
size_t msize = 2 + 4 + 1 + guidsize + 7 * 4 + ( msg->subject.size() + 1 ) + ( msg->body.size() + 1 ) + 1 + ( msg->items.size() * ( 1 + 2*4 + 7 * ( 3*4 ) + 6*4 + 1 ) );
data << uint16(msize);
data << msg->message_id;
data << uint8(msg->message_type);
if(msg->message_type)
data << uint32(msg->sender_guid);
else
data << msg->sender_guid;
data << msg->cod;
data << uint32(0);
data << msg->stationary;
data << msg->money; // money
data << uint32(0x10);
data << float((msg->expire_time - uint32(UNIXTIME)) / 86400.0f);
data << uint32( 0 ); // mail template
data << msg->subject;
data << msg->body; // subjectbody
pos = data.wpos();
data << uint8(0); // item count
if( !msg->items.empty( ) )
{
for( itr = msg->items.begin( ); itr != msg->items.end( ); itr++ )
{
pItem = objmgr.LoadItem( *itr );
if( pItem == NULL )
continue;
data << uint8(i++);
data << pItem->GetLowGUID();
data << pItem->GetEntry();
for( j = 0; j < 7; ++j )
{
data << pItem->GetUInt32Value( ITEM_FIELD_ENCHANTMENT_1_1 + ( j * 3 ) );
data << pItem->GetUInt32Value( (ITEM_FIELD_ENCHANTMENT_1_1 + 1) + ( j * 3 ) );
data << pItem->GetUInt32Value( ITEM_FIELD_ENCHANTMENT_1_3 + ( j * 3 ) );
}
data << pItem->GetUInt32Value( ITEM_FIELD_RANDOM_PROPERTIES_ID );
if( ( (int32)pItem->GetUInt32Value( ITEM_FIELD_RANDOM_PROPERTIES_ID ) ) < 0 )
data << pItem->GetItemRandomSuffixFactor();
else
data << uint32( 0 );
data << uint32( pItem->GetUInt32Value(ITEM_FIELD_STACK_COUNT) );
data << uint32( pItem->GetChargesLeft() );
data << pItem->GetUInt32Value( ITEM_FIELD_MAXDURABILITY );
data << pItem->GetUInt32Value( ITEM_FIELD_DURABILITY );
data << uint8(0);
pItem->DeleteMe();
pItem = NULLITEM;
}
data.put< uint8 >( pos, i );
}
return true;
}
示例11: HandleSendMail
//.........这里部分代码省略.........
}
// Check stationary
if(msg.stationary != STATIONERY_GM && HasGMPermissions())
{
msg.stationary = STATIONERY_GM; // GM mail always has GM Stationary.
}
if( msg.stationary == STATIONERY_GM && !HasGMPermissions())
{
msg.stationary = STATIONERY_NORMAL; // Send stationary as normal instead.
}
// Set up the cost
int32 cost = 0;
if( !sMailSystem.MailOption( MAIL_FLAG_DISABLE_POSTAGE_COSTS ) && !( GetPermissionCount() && sMailSystem.MailOption( MAIL_FLAG_NO_COST_FOR_GM ) ) )
{
cost = 30;
}
// Check for attached money
if( msg.money > 0 )
cost += msg.money;
if( cost < 0 )
{
SendMailError(MAIL_ERR_INTERNAL_ERROR);
return;
}
// check that we have enough in our backpack
if( (int32)_player->GetUInt32Value( PLAYER_FIELD_COINAGE ) < cost )
{
SendMailError( MAIL_ERR_NOT_ENOUGH_MONEY );
return;
}
// Check we're sending to the same faction (disable this for testing)
bool interfaction = (sMailSystem.MailOption( MAIL_FLAG_CAN_SEND_TO_OPPOSITE_FACTION ) || (HasGMPermissions() && sMailSystem.MailOption( MAIL_FLAG_CAN_SEND_TO_OPPOSITE_FACTION_GM ) ));
if(!interfaction)
{
if(player->team != _player->GetTeam())
{
SendMailError( MAIL_ERR_NOT_YOUR_ALLIANCE );
return;
}
}
msg.message_id = 0;
msg.message_type = 0;
msg.copy_made = false;
msg.read_flag = false;
msg.deleted_flag = false;
msg.returned_flag = false;
msg.delivery_time = (uint32)UNIXTIME;
if(msg.money != 0 || msg.cod != 0 || !items.size() && player->acct != _player->GetSession()->GetAccountId())
{
if(!sMailSystem.MailOption(MAIL_FLAG_DISABLE_HOUR_DELAY_FOR_ITEMS))
msg.delivery_time += 3600; // +1hr
}
msg.expire_time = 0;
if(!sMailSystem.MailOption(MAIL_FLAG_NO_EXPIRY))
{
msg.expire_time = (uint32)UNIXTIME + (TIME_DAY * 30);
}
if (items.empty() && msg.money != 0 && HasGMPermissions())
sWorld.LogGM(this, "sent mail with %u gold to %s (Acct: %u, Charid: %u).", msg.money, player->name, player->acct, player->guid);
// Sending Message
// take the money
_player->ModUnsigned32Value(PLAYER_FIELD_COINAGE, -cost);
// Check for the item, and required item.
if( !items.empty( ) )
{
for( itr = items.begin(); itr != items.end(); itr++ )
{
pItem = *itr;
if( _player->GetItemInterface()->SafeRemoveAndRetreiveItemByGuid(pItem->GetGUID(), false) != pItem )
continue; // should never be hit.
sQuestMgr.OnPlayerDropItem(_player, pItem->GetEntry());
pItem->RemoveFromWorld();
pItem->SetOwner( NULLPLR );
pItem->SaveToDB( INVENTORY_SLOT_NOT_SET, 0, true, NULL );
msg.items.push_back( pItem->GetUInt32Value(OBJECT_FIELD_GUID) );
if( HasGMPermissions() )
sWorld.LogGM(this, "sent mail with item entry %u to %s, with gold %u.", pItem->GetEntry(), player->name, msg.money);
pItem->DeleteMe();
pItem = NULLITEM;
}
}
// Great, all our info is filled in. Now we can add it to the other players mailbox.
sMailSystem.DeliverMessage(&msg);
// Success packet :)
SendMailError(MAIL_OK);
}
示例12: HandleWrapItem
void WorldSession::HandleWrapItem(WorldPackets::Item::WrapItem& packet)
{
if (packet.Inv.Items.size() != 2)
{
TC_LOG_ERROR("network", "HandleWrapItem - Invalid itemCount (" SZFMTD ")", packet.Inv.Items.size());
return;
}
/// @todo: 6.x find better way for read
// Gift
uint8 giftContainerSlot = packet.Inv.Items[0].ContainerSlot;
uint8 giftSlot = packet.Inv.Items[0].Slot;
// Item
uint8 itemContainerSlot = packet.Inv.Items[1].ContainerSlot;
uint8 itemSlot = packet.Inv.Items[1].Slot;
TC_LOG_DEBUG("network", "HandleWrapItem - Receive giftContainerSlot = %u, giftSlot = %u, itemContainerSlot = %u, itemSlot = %u", giftContainerSlot, giftSlot, itemContainerSlot, itemSlot);
Item* gift = _player->GetItemByPos(giftContainerSlot, giftSlot);
if (!gift)
{
_player->SendEquipError(EQUIP_ERR_ITEM_NOT_FOUND, gift, NULL);
return;
}
if (!(gift->GetTemplate()->GetFlags() & ITEM_FLAG_WRAPPER)) // cheating: non-wrapper wrapper
{
_player->SendEquipError(EQUIP_ERR_ITEM_NOT_FOUND, gift, NULL);
return;
}
Item* item = _player->GetItemByPos(itemContainerSlot, itemSlot);
if (!item)
{
_player->SendEquipError(EQUIP_ERR_ITEM_NOT_FOUND, item, NULL);
return;
}
if (item == gift) // not possable with pacjket from real client
{
_player->SendEquipError(EQUIP_ERR_CANT_WRAP_WRAPPED, item, NULL);
return;
}
if (item->IsEquipped())
{
_player->SendEquipError(EQUIP_ERR_CANT_WRAP_EQUIPPED, item, NULL);
return;
}
if (!item->GetGuidValue(ITEM_FIELD_GIFTCREATOR).IsEmpty()) // HasFlag(ITEM_FIELD_FLAGS, ITEM_FLAGS_WRAPPED);
{
_player->SendEquipError(EQUIP_ERR_CANT_WRAP_WRAPPED, item, NULL);
return;
}
if (item->IsBag())
{
_player->SendEquipError(EQUIP_ERR_CANT_WRAP_BAGS, item, NULL);
return;
}
if (item->IsSoulBound())
{
_player->SendEquipError(EQUIP_ERR_CANT_WRAP_BOUND, item, NULL);
return;
}
if (item->GetMaxStackCount() != 1)
{
_player->SendEquipError(EQUIP_ERR_CANT_WRAP_STACKABLE, item, NULL);
return;
}
// maybe not correct check (it is better than nothing)
if (item->GetTemplate()->GetMaxCount() > 0)
{
_player->SendEquipError(EQUIP_ERR_CANT_WRAP_UNIQUE, item, NULL);
return;
}
SQLTransaction trans = CharacterDatabase.BeginTransaction();
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_CHAR_GIFT);
stmt->setUInt64(0, item->GetOwnerGUID().GetCounter());
stmt->setUInt64(1, item->GetGUID().GetCounter());
stmt->setUInt32(2, item->GetEntry());
stmt->setUInt32(3, item->GetUInt32Value(ITEM_FIELD_FLAGS));
trans->Append(stmt);
item->SetEntry(gift->GetEntry());
switch (item->GetEntry())
{
case 5042:
item->SetEntry(5043);
break;
case 5048:
item->SetEntry(5044);
break;
//.........这里部分代码省略.........
示例13: HandleSellItemOpcode
void WorldSession::HandleSellItemOpcode(WorldPackets::Item::SellItem& packet)
{
TC_LOG_DEBUG("network", "WORLD: Received CMSG_SELL_ITEM: Vendor %s, Item %s, Amount: %u",
packet.VendorGUID.ToString().c_str(), packet.ItemGUID.ToString().c_str(), packet.Amount);
if (packet.ItemGUID.IsEmpty())
return;
Creature* creature = GetPlayer()->GetNPCIfCanInteractWith(packet.VendorGUID, UNIT_NPC_FLAG_VENDOR);
if (!creature)
{
TC_LOG_DEBUG("network", "WORLD: HandleSellItemOpcode - %s not found or you can not interact with him.", packet.VendorGUID.ToString().c_str());
_player->SendSellError(SELL_ERR_CANT_FIND_VENDOR, nullptr, packet.ItemGUID);
return;
}
// remove fake death
if (GetPlayer()->HasUnitState(UNIT_STATE_DIED))
GetPlayer()->RemoveAurasByType(SPELL_AURA_FEIGN_DEATH);
Item* pItem = _player->GetItemByGuid(packet.ItemGUID);
if (pItem)
{
// prevent sell not owner item
if (_player->GetGUID() != pItem->GetOwnerGUID())
{
_player->SendSellError(SELL_ERR_CANT_SELL_ITEM, creature, packet.ItemGUID);
return;
}
// prevent sell non empty bag by drag-and-drop at vendor's item list
if (pItem->IsNotEmptyBag())
{
_player->SendSellError(SELL_ERR_CANT_SELL_ITEM, creature, packet.ItemGUID);
return;
}
// prevent sell currently looted item
if (_player->GetLootGUID() == pItem->GetGUID())
{
_player->SendSellError(SELL_ERR_CANT_SELL_ITEM, creature, packet.ItemGUID);
return;
}
// prevent selling item for sellprice when the item is still refundable
// this probably happens when right clicking a refundable item, the client sends both
// CMSG_SELL_ITEM and CMSG_REFUND_ITEM (unverified)
if (pItem->HasFlag(ITEM_FIELD_FLAGS, ITEM_FIELD_FLAG_REFUNDABLE))
return; // Therefore, no feedback to client
// special case at auto sell (sell all)
if (packet.Amount == 0)
packet.Amount = pItem->GetCount();
else
{
// prevent sell more items that exist in stack (possible only not from client)
if (packet.Amount > pItem->GetCount())
{
_player->SendSellError(SELL_ERR_CANT_SELL_ITEM, creature, packet.ItemGUID);
return;
}
}
ItemTemplate const* pProto = pItem->GetTemplate();
if (pProto)
{
if (pProto->GetSellPrice() > 0)
{
if (packet.Amount < pItem->GetCount()) // need split items
{
Item* pNewItem = pItem->CloneItem(packet.Amount, _player);
if (!pNewItem)
{
TC_LOG_ERROR("network", "WORLD: HandleSellItemOpcode - could not create clone of item %u; count = %u", pItem->GetEntry(), packet.Amount);
_player->SendSellError(SELL_ERR_CANT_SELL_ITEM, creature, packet.ItemGUID);
return;
}
pItem->SetCount(pItem->GetCount() - packet.Amount);
_player->ItemRemovedQuestCheck(pItem->GetEntry(), packet.Amount);
if (_player->IsInWorld())
pItem->SendUpdateToPlayer(_player);
pItem->SetState(ITEM_CHANGED, _player);
_player->AddItemToBuyBackSlot(pNewItem);
if (_player->IsInWorld())
pNewItem->SendUpdateToPlayer(_player);
}
else
{
_player->ItemRemovedQuestCheck(pItem->GetEntry(), pItem->GetCount());
_player->RemoveItem(pItem->GetBagSlot(), pItem->GetSlot(), true);
pItem->RemoveFromUpdateQueueOf(_player);
_player->AddItemToBuyBackSlot(pItem);
}
uint32 money = pProto->GetSellPrice() * packet.Amount;
_player->ModifyMoney(money);
_player->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_MONEY_FROM_VENDORS, money);
}
//.........这里部分代码省略.........
示例14: HandleUseCritterItem
void WorldSession::HandleUseCritterItem(WorldPackets::Item::UseCritterItem& useCritterItem)
{
Item* item = _player->GetItemByGuid(useCritterItem.ItemGuid);
if (!item)
return;
ItemToBattlePetSpeciesEntry const* itemToBattlePetSpecies = sItemToBattlePetSpeciesStore.LookupEntry(item->GetEntry());
if (!itemToBattlePetSpecies)
return;
BattlePetSpeciesEntry const* battlePetSpecies = sBattlePetSpeciesStore.LookupEntry(itemToBattlePetSpecies->BattlePetSpeciesID);
if (!battlePetSpecies)
return;
GetBattlePetMgr()->AddPet(battlePetSpecies->ID, battlePetSpecies->CreatureID, BattlePetMgr::RollPetBreed(battlePetSpecies->ID), BattlePetMgr::GetDefaultPetQuality(battlePetSpecies->ID));
_player->DestroyItem(item->GetBagSlot(), item->GetSlot(), true);
}
示例15: HandleMailTakeItem
//called when player takes item attached in mail
void WorldSession::HandleMailTakeItem(WorldPacket & recv_data )
{
uint64 mailbox;
uint32 mailId;
uint32 itemId;
recv_data >> mailbox;
recv_data >> mailId;
recv_data >> itemId; // item guid low
if (!GetPlayer()->GetGameObjectIfCanInteractWith(mailbox, GAMEOBJECT_TYPE_MAILBOX))
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;
uint8 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
{
uint64 sender_guid = MAKE_NEW_GUID(m->sender, 0, HIGHGUID_PLAYER);
Player *receive = sObjectMgr.GetPlayer(sender_guid);
uint32 sender_accId = 0;
if( GetSecurity() > SEC_PLAYER && sWorld.getConfig(CONFIG_GM_LOG_TRADE) )
{
std::string sender_name;
if(receive)
{
sender_accId = receive->GetSession()->GetAccountId();
sender_name = receive->GetName();
}
else
{
// can be calculated early
sender_accId = sObjectMgr.GetPlayerAccountIdByGUID(sender_guid);
if(!sObjectMgr.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(!receive)
sender_accId = sObjectMgr.GetPlayerAccountIdByGUID(sender_guid);
// check player existence
if(receive || sender_accId)
{
MailDraft(m->subject)
.AddMoney(m->COD)
.SendMailTo(MailReceiver(receive,m->sender),MailSender(MAIL_NORMAL,m->receiver), 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);
}