本文整理汇总了C++中Item::CanBeTraded方法的典型用法代码示例。如果您正苦于以下问题:C++ Item::CanBeTraded方法的具体用法?C++ Item::CanBeTraded怎么用?C++ Item::CanBeTraded使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Item
的用法示例。
在下文中一共展示了Item::CanBeTraded方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: HandleSetTradeItemOpcode
void WorldSession::HandleSetTradeItemOpcode(WorldPacket& recvPacket)
{
// send update
uint8 tradeSlot;
uint8 bag;
uint8 slot;
recvPacket >> tradeSlot;
recvPacket >> bag;
recvPacket >> slot;
TradeData* my_trade = _player->GetTradeData();
if (!my_trade)
return;
TradeStatusInfo info;
// invalid slot number
if (tradeSlot >= TRADE_SLOT_COUNT)
{
info.Status = TRADE_STATUS_TRADE_CANCELED;
SendTradeStatus(info);
return;
}
// check cheating, can't fail with correct client operations
Item* item = _player->GetItemByPos(bag, slot);
if (!item || (tradeSlot != TRADE_SLOT_NONTRADED && !item->CanBeTraded(false, true)))
{
info.Status = TRADE_STATUS_TRADE_CANCELED;
SendTradeStatus(info);
return;
}
ObjectGuid iGUID = item->GetGUID();
// prevent place single item into many trade slots using cheating and client bugs
if (my_trade->HasItem(iGUID))
{
// cheating attempt
info.Status = TRADE_STATUS_TRADE_CANCELED;
SendTradeStatus(info);
return;
}
if (tradeSlot != TRADE_SLOT_NONTRADED && item->IsBindedNotWith(my_trade->GetTrader()))
{
info.Status = TRADE_STATUS_NOT_ON_TAPLIST;
info.Slot = tradeSlot;
SendTradeStatus(info);
return;
}
my_trade->SetItem(TradeSlots(tradeSlot), item);
}
示例2: HandleSetTradeItemOpcode
void WorldSession::HandleSetTradeItemOpcode(WorldPackets::Trade::SetTradeItem& setTradeItem)
{
TradeData* my_trade = _player->GetTradeData();
if (!my_trade)
return;
WorldPackets::Trade::TradeStatus info;
// invalid slot number
if (setTradeItem.TradeSlot >= TRADE_SLOT_COUNT)
{
info.Status = TRADE_STATUS_CANCELLED;
SendTradeStatus(info);
return;
}
// check cheating, can't fail with correct client operations
Item* item = _player->GetItemByPos(setTradeItem.PackSlot, setTradeItem.ItemSlotInPack);
if (!item || (setTradeItem.TradeSlot != TRADE_SLOT_NONTRADED && !item->CanBeTraded(false, true)))
{
info.Status = TRADE_STATUS_CANCELLED;
SendTradeStatus(info);
return;
}
ObjectGuid iGUID = item->GetGUID();
// prevent place single item into many trade slots using cheating and client bugs
if (my_trade->HasItem(iGUID))
{
// cheating attempt
info.Status = TRADE_STATUS_CANCELLED;
SendTradeStatus(info);
return;
}
my_trade->UpdateClientStateIndex();
if (setTradeItem.TradeSlot != TRADE_SLOT_NONTRADED && item->IsBindedNotWith(my_trade->GetTrader()))
{
info.Status = TRADE_STATUS_NOT_ON_TAPLIST;
info.TradeSlot = setTradeItem.TradeSlot;
SendTradeStatus(info);
return;
}
my_trade->SetItem(TradeSlots(setTradeItem.TradeSlot), item);
}
示例3: HandleSetTradeItemOpcode
void WorldSession::HandleSetTradeItemOpcode(WorldPacket& recvPacket)
{
// send update
uint8 tradeSlot;
uint8 bag;
uint8 slot;
recvPacket >> slot;
recvPacket >> tradeSlot;
recvPacket >> bag;
std::cout << "Unk1 : " << (int)tradeSlot << " Unk2: " << (int)slot << " unk3 : " << (int)bag << std::endl;
TradeData* my_trade = _player->GetTradeData();
if (!my_trade)
return;
// invalid slot number
if (tradeSlot >= TRADE_SLOT_COUNT)
{
std::cout << "Ery : test1" << std::endl;
SendTradeStatus(TRADE_STATUS_TRADE_CANCELED);
return;
}
// check cheating, can't fail with correct client operations
Item* item = _player->GetItemByPos(bag, slot);
if (!item || (tradeSlot != TRADE_SLOT_NONTRADED && !item->CanBeTraded(false, true)))
{
std::cout << "Ery : test2" << std::endl;
SendTradeStatus(TRADE_STATUS_TRADE_CANCELED);
return;
}
uint64 iGUID = item->GetGUID();
// prevent place single item into many trade slots using cheating and client bugs
if (my_trade->HasItem(iGUID))
{
std::cout << "Ery : test3" << std::endl;
// cheating attempt
SendTradeStatus(TRADE_STATUS_TRADE_CANCELED);
return;
}
my_trade->SetItem(TradeSlots(tradeSlot), item);
}
示例4: HandleSetTradeItemOpcode
void WorldSession::HandleSetTradeItemOpcode(WorldPacket& recvPacket)
{
// send update
uint8 tradeSlot;
uint8 bag;
uint8 slot;
recvPacket >> tradeSlot;
recvPacket >> bag;
recvPacket >> slot;
if (!_player->pTrader)
return;
// invalid slot number
if (tradeSlot >= TRADE_SLOT_COUNT)
{
SendTradeStatus(TRADE_STATUS_TRADE_CANCELED);
return;
}
// check cheating, can't fail with correct client operations
Item* item = _player->GetItemByPos(bag,slot);
if (!item || (tradeSlot != TRADE_SLOT_NONTRADED && !item->CanBeTraded()))
{
SendTradeStatus(TRADE_STATUS_TRADE_CANCELED);
return;
}
uint64 iGUID = item->GetGUID();
// prevent place single item into many trade slots using cheating and client bugs
for (int i = 0; i < TRADE_SLOT_COUNT; ++i)
{
if (_player->tradeItems[i] == iGUID)
{
// cheating attempt
SendTradeStatus(TRADE_STATUS_TRADE_CANCELED);
return;
}
}
_player->tradeItems[tradeSlot] = iGUID;
_player->pTrader->GetSession()->SendUpdateTrade();
}
示例5: HandleSetTradeItemOpcode
void WorldSession::HandleSetTradeItemOpcode(WorldPacket& recvPacket)
{
// send update
uint8 tradeSlot;
uint8 bag;
uint8 slot;
recvPacket >> tradeSlot;
recvPacket >> bag;
recvPacket >> slot;
TradeData* my_trade = _player->m_trade;
if (!my_trade)
return;
// invalid slot number
if (tradeSlot >= TRADE_SLOT_COUNT)
{
SendTradeStatus(TRADE_STATUS_TRADE_CANCELED);
return;
}
// check cheating, can't fail with correct client operations
Item* item = _player->GetItemByPos(bag, slot);
if (!item || (tradeSlot != TRADE_SLOT_NONTRADED && !item->CanBeTraded()))
{
SendTradeStatus(TRADE_STATUS_TRADE_CANCELED);
return;
}
// prevent place single item into many trade slots using cheating and client bugs
if (my_trade->HasItem(item->GetObjectGuid()))
{
// cheating attempt
SendTradeStatus(TRADE_STATUS_TRADE_CANCELED);
return;
}
my_trade->SetItem(TradeSlots(tradeSlot), item);
}
示例6: HandleSendMail
//.........这里部分代码省略.........
}
// do not allow to have more than 100 mails in mailbox.. mails count is in opcode uint8!!! - so max can be 255..
if (mails_count > 100)
{
pl->SendMailResult(0, MAIL_SEND, MAIL_ERR_RECIPIENT_CAP_REACHED);
return;
}
// check the receiver's Faction...
if (!sWorld.getConfig(CONFIG_BOOL_ALLOW_TWO_SIDE_INTERACTION_MAIL) && pl->GetTeam() != rc_team && GetSecurity() == SEC_PLAYER)
{
pl->SendMailResult(0, MAIL_SEND, MAIL_ERR_NOT_YOUR_TEAM);
return;
}
uint32 rc_account = receive
? receive->GetSession()->GetAccountId()
: sObjectMgr.GetPlayerAccountIdByGUID(rc);
Item* item = NULL;
if (itemGuid)
{
item = pl->GetItemByGuid(itemGuid);
// prevent sending bag with items (cheat: can be placed in bag after adding equipped empty bag to mail)
if (!item)
{
pl->SendMailResult(0, MAIL_SEND, MAIL_ERR_MAIL_ATTACHMENT_INVALID);
return;
}
if (!item->CanBeTraded())
{
pl->SendMailResult(0, MAIL_SEND, MAIL_ERR_MAIL_ATTACHMENT_INVALID);
return;
}
if ((item->GetProto()->Flags & ITEM_FLAG_CONJURED) || item->GetUInt32Value(ITEM_FIELD_DURATION))
{
pl->SendMailResult(0, MAIL_SEND, MAIL_ERR_MAIL_ATTACHMENT_INVALID);
return;
}
if (COD && item->HasFlag(ITEM_FIELD_FLAGS, ITEM_DYNFLAG_WRAPPED))
{
pl->SendMailResult(0, MAIL_SEND, MAIL_ERR_CANT_SEND_WRAPPED_COD);
return;
}
}
pl->SendMailResult(0, MAIL_SEND, MAIL_OK);
// pl->ModifyMoney(-int32(reqmoney));
bool needItemDelay = false;
MailDraft draft(subject, body);
if (itemGuid || money > 0)
{
uint32 rc_account = 0;
if (receive)
rc_account = receive->GetSession()->GetAccountId();
else
示例7: HandleAuctionSellItem
// 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 4*MIN_AUCTION_TIME:
case 12*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_ITEM_NOT_FOUND);
return;
}
if ((it->GetProto()->Flags & ITEM_FLAG_CONJURED) || it->GetUInt32Value(ITEM_FIELD_DURATION))
{
SendAuctionCommandResult(NULL, AUCTION_STARTED, AUCTION_ERR_INVENTORY, EQUIP_ERR_ITEM_NOT_FOUND);
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);
//.........这里部分代码省略.........
示例8: HandleAuctionSellItem
//this void creates new auction and adds auction to some auctionhouse
void WorldSession::HandleAuctionSellItem(WorldPacket & recv_data)
{
uint64 auctioneer;
uint32 itemsCount, etime, bid, buyout;
recv_data >> auctioneer;
recv_data >> itemsCount;
uint64 itemGUIDs[MAX_AUCTION_ITEMS]; // 160 slot = 4x 36 slot bag + backpack 16 slot
uint32 count[MAX_AUCTION_ITEMS];
for (uint32 i = 0; i < itemsCount; ++i)
{
recv_data >> itemGUIDs[i];
recv_data >> count[i];
if (!itemGUIDs[i] || !count[i] || count[i] > 1000 )
return;
}
recv_data >> bid;
recv_data >> buyout;
recv_data >> etime;
if (!bid || !etime)
return;
Creature* creature = GetPlayer()->GetNPCIfCanInteractWith(auctioneer, UNIT_NPC_FLAG_AUCTIONEER);
if (!creature)
{
sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: HandleAuctionSellItem - Unit (GUID: %u) not found or you can't interact with him.", GUID_LOPART(auctioneer));
return;
}
AuctionHouseEntry const* auctionHouseEntry = AuctionHouseMgr::GetAuctionHouseEntry(creature->getFaction());
if (!auctionHouseEntry)
{
sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: HandleAuctionSellItem - Unit (GUID: %u) has wrong faction.", GUID_LOPART(auctioneer));
return;
}
if (itemsCount > MAX_AUCTION_ITEMS)
{
SendAuctionCommandResult(0, AUCTION_SELL_ITEM, AUCTION_INTERNAL_ERROR);
return;
}
etime *= MINUTE;
switch(etime)
{
case 1*MIN_AUCTION_TIME:
case 2*MIN_AUCTION_TIME:
case 4*MIN_AUCTION_TIME:
break;
default:
return;
}
if (GetPlayer()->HasUnitState(UNIT_STATE_DIED))
GetPlayer()->RemoveAurasByType(SPELL_AURA_FEIGN_DEATH);
Item* items[MAX_AUCTION_ITEMS];
uint32 finalCount = 0;
for (uint32 i = 0; i < itemsCount; ++i)
{
Item* item = _player->GetItemByGuid(itemGUIDs[i]);
if (!item)
{
SendAuctionCommandResult(0, AUCTION_SELL_ITEM, AUCTION_ITEM_NOT_FOUND);
return;
}
if (sAuctionMgr->GetAItem(item->GetGUIDLow()) || !item->CanBeTraded() || item->IsNotEmptyBag() ||
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)
{
//.........这里部分代码省略.........
示例9: HandleAuctionSellItem
//this void creates new auction and adds auction to some auctionhouse
void WorldSession::HandleAuctionSellItem(WorldPackets::AuctionHouse::AuctionSellItem& packet)
{
if (packet.Items.size() > MAX_AUCTION_ITEMS)
{
SendAuctionCommandResult(NULL, AUCTION_SELL_ITEM, ERR_AUCTION_DATABASE_ERROR);
return;
}
for (auto const& item : packet.Items)
if (!item.Guid || !item.UseCount || item.UseCount > 1000)
return;
if (!packet.MinBid || !packet.RunTime)
return;
if (packet.MinBid > MAX_MONEY_AMOUNT || packet.BuyoutPrice > MAX_MONEY_AMOUNT)
{
TC_LOG_DEBUG("network", "WORLD: HandleAuctionSellItem - Player %s (%s) attempted to sell item with higher price than max gold amount.", _player->GetName().c_str(), _player->GetGUID().ToString().c_str());
SendAuctionCommandResult(NULL, AUCTION_SELL_ITEM, ERR_AUCTION_DATABASE_ERROR);
return;
}
Creature* creature = GetPlayer()->GetNPCIfCanInteractWith(packet.Auctioneer, UNIT_NPC_FLAG_AUCTIONEER);
if (!creature)
{
TC_LOG_DEBUG("network", "WORLD: HandleAuctionSellItem - Unit (%s) not found or you can't interact with him.", packet.Auctioneer.ToString().c_str());
return;
}
AuctionHouseEntry const* auctionHouseEntry = AuctionHouseMgr::GetAuctionHouseEntry(creature->getFaction());
if (!auctionHouseEntry)
{
TC_LOG_DEBUG("network", "WORLD: HandleAuctionSellItem - Unit (%s) has wrong faction.", packet.Auctioneer.ToString().c_str());
return;
}
packet.RunTime *= MINUTE;
switch (packet.RunTime)
{
case 1 * MIN_AUCTION_TIME:
case 2 * MIN_AUCTION_TIME:
case 4 * MIN_AUCTION_TIME:
break;
default:
return;
}
if (GetPlayer()->HasUnitState(UNIT_STATE_DIED))
GetPlayer()->RemoveAurasByType(SPELL_AURA_FEIGN_DEATH);
uint32 finalCount = 0;
for (auto const& packetItem : packet.Items)
{
Item* item = _player->GetItemByGuid(packetItem.Guid);
if (!item)
{
SendAuctionCommandResult(NULL, AUCTION_SELL_ITEM, ERR_AUCTION_ITEM_NOT_FOUND);
return;
}
if (sAuctionMgr->GetAItem(item->GetGUID().GetCounter()) || !item->CanBeTraded() || item->IsNotEmptyBag() ||
item->GetTemplate()->GetFlags() & ITEM_FLAG_CONJURED || item->GetUInt32Value(ITEM_FIELD_DURATION) ||
item->GetCount() < packetItem.UseCount)
{
SendAuctionCommandResult(NULL, AUCTION_SELL_ITEM, ERR_AUCTION_DATABASE_ERROR);
return;
}
finalCount += packetItem.UseCount;
}
if (packet.Items.empty())
{
SendAuctionCommandResult(NULL, AUCTION_SELL_ITEM, ERR_AUCTION_DATABASE_ERROR);
return;
}
if (!finalCount)
{
SendAuctionCommandResult(NULL, 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 < packet.Items.size() - 1; ++i)
{
for (uint32 j = i + 1; j < packet.Items.size(); ++j)
{
if (packet.Items[i].Guid == packet.Items[j].Guid)
{
SendAuctionCommandResult(NULL, AUCTION_SELL_ITEM, ERR_AUCTION_DATABASE_ERROR);
return;
}
}
}
//.........这里部分代码省略.........
示例10: HandleSendMail
//.........这里部分代码省略.........
}
}
}*/
uint32 rc_account = receive
? receive->GetSession()->GetAccountId()
: sObjectMgr->GetPlayerAccountIdByGUID(rc);
if (/*!accountBound*/ GetAccountId() != rc_account && !sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_MAIL) && player->GetTeamId() != rc_teamId && AccountMgr::IsPlayerAccount(GetSecurity()))
{
player->SendMailResult(0, MAIL_SEND, MAIL_ERR_NOT_YOUR_TEAM);
return;
}
Item* items[MAX_MAIL_ITEMS];
for (uint8 i = 0; i < items_count; ++i)
{
if (!itemGUIDs[i])
{
player->SendMailResult(0, MAIL_SEND, MAIL_ERR_MAIL_ATTACHMENT_INVALID);
return;
}
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() && 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;
}
示例11: HandleSendMailCallback
// $req will be deleted by the caller.
void WorldSession::HandleSendMailCallback(WorldSession::AsyncMailSendRequest* req)
{
MasterPlayer* pl = GetMasterPlayer();
Player* loadedPlayer = GetPlayer();
ASSERT(pl);
uint32 reqmoney = req->money + 30;
// Check for overflow
if (reqmoney < req->money)
{
ProcessAnticheatAction("MailCheck", "Attempt to send free mails with money overflow", CHEAT_ACTION_LOG);
pl->SendMailResult(0, MAIL_SEND, MAIL_ERR_NOT_ENOUGH_MONEY);
return;
}
if (reqmoney && (!loadedPlayer || loadedPlayer->GetMoney() < reqmoney))
{
pl->SendMailResult(0, MAIL_SEND, MAIL_ERR_NOT_ENOUGH_MONEY);
return;
}
// do not allow to have more than 100 mails in mailbox.. mails count is in opcode uint8!!! - so max can be 255..
if (req->mailsCount > 100)
{
pl->SendMailResult(0, MAIL_SEND, MAIL_ERR_RECIPIENT_CAP_REACHED);
return;
}
// check the receiver's Faction...
if (!sWorld.getConfig(CONFIG_BOOL_ALLOW_TWO_SIDE_INTERACTION_MAIL) && pl->GetTeam() != req->rcTeam && GetSecurity() == SEC_PLAYER)
{
pl->SendMailResult(0, MAIL_SEND, MAIL_ERR_NOT_YOUR_TEAM);
return;
}
uint32 rc_account = sObjectMgr.GetPlayerAccountIdByGUID(req->receiver);
Item* item = NULL;
if (req->itemGuid)
{
item = loadedPlayer->GetItemByGuid(req->itemGuid);
// prevent sending bag with items (cheat: can be placed in bag after adding equipped empty bag to mail)
if (!item || !item->IsInWorld())
{
pl->SendMailResult(0, MAIL_SEND, MAIL_ERR_MAIL_ATTACHMENT_INVALID);
return;
}
if (!item->CanBeTraded())
{
pl->SendMailResult(0, MAIL_SEND, MAIL_ERR_MAIL_ATTACHMENT_INVALID);
return;
}
if ((item->GetProto()->Flags & ITEM_FLAG_CONJURED) || item->GetUInt32Value(ITEM_FIELD_DURATION))
{
pl->SendMailResult(0, MAIL_SEND, MAIL_ERR_MAIL_ATTACHMENT_INVALID);
return;
}
if (req->COD && item->HasFlag(ITEM_FIELD_FLAGS, ITEM_DYNFLAG_WRAPPED))
{
pl->SendMailResult(0, MAIL_SEND, MAIL_ERR_CANT_SEND_WRAPPED_COD);
return;
}
}
// Antispam checks
if (loadedPlayer->getLevel() < sWorld.getConfig(CONFIG_UINT32_MAILSPAM_LEVEL) &&
req->money < sWorld.getConfig(CONFIG_UINT32_MAILSPAM_MONEY) &&
(sWorld.getConfig(CONFIG_BOOL_MAILSPAM_ITEM) && !req->itemGuid))
{
pl->SendMailResult(0, MAIL_SEND, MAIL_ERR_INTERNAL_ERROR);
return;
}
AccountPersistentData& data = sAccountMgr.GetAccountPersistentData(GetAccountId());
if (!data.CanMail(rc_account))
{
std::stringstream details;
std::string from = ChatHandler(this).playerLink(GetMasterPlayer()->GetName());
std::string to = ChatHandler(this).playerLink(req->receiverName);
details << from << " -> " << to << "\n";
details << req->subject << "\n";
details << req->body << "\n";
if (req->COD)
details << "COD: " << req->COD << " coppers\n";
uint32 logId = sWorld.InsertLog(details.str(), SEC_GAMEMASTER);
std::stringstream oss;
oss << "Mail limit reached (\"" << req->body.substr(0, 30) << "...\") [log #" << logId << "]";
ProcessAnticheatAction("ChatSpam", oss.str().c_str(), CHEAT_ACTION_LOG | CHEAT_ACTION_REPORT_GMS);
pl->SendMailResult(0, MAIL_SEND, MAIL_OK);
return;
}
data.JustMailed(rc_account);
//.........这里部分代码省略.........
示例12: HandleAuctionSellItem
// this void creates new auction and adds auction to some auctionhouse
void WorldSession::HandleAuctionSellItem(WorldPacket & recv_data)
{
DEBUG_LOG("WORLD: HandleAuctionSellItem");
ObjectGuid auctioneerGuid;
uint32 etime, bid, buyout, itemCount;
GuidVector guids;
std::vector<uint32> stackSizes;
recv_data >> auctioneerGuid;
recv_data >> itemCount;
if (itemCount > MAX_BAG_SIZE * 5)
{
recv_data.rpos(recv_data.wpos()); // should not happen
return;
}
guids.resize(itemCount);
stackSizes.resize(itemCount);
for (uint32 i = 0; i < itemCount; ++i)
{
recv_data >> guids[i]; // item guid
recv_data >> stackSizes[i]; // stack size
}
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);
for (uint32 i = 0; i < itemCount; ++i)
{
ObjectGuid itemGuid = guids[i];
if (!itemGuid)
continue;
uint32 stackSize = stackSizes[i];
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);
continue;
}
// 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);
continue;
}
if (!it->CanBeTraded())
{
SendAuctionCommandResult(NULL, AUCTION_STARTED, AUCTION_ERR_INVENTORY, EQUIP_ERR_CANNOT_TRADE_THAT);
continue;
}
if ((it->GetProto()->Flags & ITEM_FLAG_CONJURED) || it->GetUInt32Value(ITEM_FIELD_DURATION))
{
SendAuctionCommandResult(NULL, AUCTION_STARTED, AUCTION_ERR_INVENTORY, EQUIP_ERR_CANNOT_TRADE_THAT);
continue;
}
//.........这里部分代码省略.........
示例13: HandleAuctionSellItem
// 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;
}
//.........这里部分代码省略.........
示例14: HandleAcceptTradeOpcode
void WorldSession::HandleAcceptTradeOpcode(WorldPacket& /*recvPacket*/)
{
Item *myItems[TRADE_SLOT_TRADED_COUNT] = { NULL, NULL, NULL, NULL, NULL, NULL };
Item *hisItems[TRADE_SLOT_TRADED_COUNT] = { NULL, NULL, NULL, NULL, NULL, NULL };
bool myCanCompleteTrade=true,hisCanCompleteTrade=true;
if ( !GetPlayer()->pTrader )
return;
// not accept case incorrect money amount
if( _player->tradeGold > _player->GetMoney() )
{
SendNotification(LANG_NOT_ENOUGH_GOLD);
_player->pTrader->GetSession()->SendTradeStatus(TRADE_STATUS_BACK_TO_TRADE);
_player->acceptTrade = false;
return;
}
// not accept case incorrect money amount
if( _player->pTrader->tradeGold > _player->pTrader->GetMoney() )
{
_player->pTrader->GetSession( )->SendNotification(LANG_NOT_ENOUGH_GOLD);
SendTradeStatus(TRADE_STATUS_BACK_TO_TRADE);
_player->pTrader->acceptTrade = false;
return;
}
// not accept if some items now can't be trade (cheating)
for (int i=0; i<TRADE_SLOT_TRADED_COUNT; ++i)
{
if(_player->tradeItems[i] != NULL_SLOT )
{
Item* item =_player->GetItemByPos( _player->tradeItems[i] );
if(!item || !item->CanBeTraded())
{
SendTradeStatus(TRADE_STATUS_TRADE_CANCELED);
return;
}
}
if(_player->pTrader->tradeItems[i] != NULL_SLOT)
{
Item* item =_player->pTrader->GetItemByPos( _player->pTrader->tradeItems[i]);
if(!item || !item->CanBeTraded())
{
SendTradeStatus(TRADE_STATUS_TRADE_CANCELED);
return;
}
}
}
_player->acceptTrade = true;
if (_player->pTrader->acceptTrade )
{
// inform partner client
_player->pTrader->GetSession()->SendTradeStatus(TRADE_STATUS_TRADE_ACCEPT);
// store items in local list and set 'in-trade' flag
for(int i=0; i<TRADE_SLOT_TRADED_COUNT; ++i)
{
if(_player->tradeItems[i] != NULL_SLOT )
{
sLog.outDebug("player trade item bag: %u slot: %u",_player->tradeItems[i] >> 8, _player->tradeItems[i] & 255 );
//Can return NULL
myItems[i]=_player->GetItemByPos( _player->tradeItems[i] );
if (myItems[i])
myItems[i]->SetInTrade();
}
if(_player->pTrader->tradeItems[i] != NULL_SLOT)
{
sLog.outDebug("partner trade item bag: %u slot: %u",_player->pTrader->tradeItems[i] >> 8,_player->pTrader->tradeItems[i] & 255);
//Can return NULL
hisItems[i]=_player->pTrader->GetItemByPos( _player->pTrader->tradeItems[i]);
if(hisItems[i])
hisItems[i]->SetInTrade();
}
示例15: HandleAuctionSellItem
//this void creates new auction and adds auction to some auctionhouse
void WorldSession::HandleAuctionSellItem( WorldPacket & recv_data )
{
CHECK_PACKET_SIZE(recv_data,8+8+4+4+4);
uint64 auctioneer, item;
uint32 etime, bid, buyout;
recv_data >> auctioneer >> item;
recv_data >> bid >> buyout >> etime;
Player *pl = GetPlayer();
if (!item || !bid || !etime)
return; //check for cheaters
Creature *pCreature = GetPlayer()->GetNPCIfCanInteractWith(auctioneer,UNIT_NPC_FLAG_AUCTIONEER);
if (!pCreature)
{
sLog.outDebug( "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( "WORLD: HandleAuctionSellItem - Unit (GUID: %u) has wrong faction.", uint32(GUID_LOPART(auctioneer)) );
return;
}
// 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(auctionmgr.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->HasFlag(ITEM_FIELD_FLAGS, ITEM_FLAGS_CONJURED) || it->GetUInt32Value(ITEM_FIELD_DURATION))
{
SendAuctionCommandResult(0, AUCTION_SELL_ITEM, AUCTION_INTERNAL_ERROR);
return;
}
AuctionHouseObject* auctionHouse = auctionmgr.GetAuctionsMap( pCreature->getFaction() );
//we have to take deposit :
uint32 deposit = auctionmgr.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_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.getRate(RATE_AUCTION_TIME));
AuctionEntry *AH = new AuctionEntry;
AH->Id = objmgr.GenerateAuctionID();
AH->auctioneer = GUID_LOPART(auctioneer);
AH->item_guidlow = GUID_LOPART(item);
AH->item_template = it->GetEntry();
AH->owner = pl->GetGUIDLow();
//.........这里部分代码省略.........