本文整理汇总了C++中Bag::GetSlot方法的典型用法代码示例。如果您正苦于以下问题:C++ Bag::GetSlot方法的具体用法?C++ Bag::GetSlot怎么用?C++ Bag::GetSlot使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Bag
的用法示例。
在下文中一共展示了Bag::GetSlot方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: HandleGetItemState
bool ChatHandler::HandleGetItemState(const char* args)
{
if (!args)
return false;
std::string state_str = args;
ItemUpdateState state;
bool list_queue = false, check_all = false;
if (state_str == "unchanged") state = ITEM_UNCHANGED;
else if (state_str == "changed") state = ITEM_CHANGED;
else if (state_str == "new") state = ITEM_NEW;
else if (state_str == "removed") state = ITEM_REMOVED;
else if (state_str == "queue") list_queue = true;
else if (state_str == "check_all") check_all = true;
else return false;
Player* player = getSelectedPlayer();
if (!player) player = m_session->GetPlayer();
if (!list_queue && !check_all)
{
state_str = "The player has the following " + state_str + " items: ";
SendSysMessage(state_str.c_str());
for (uint8 i = 0; i < INVENTORY_SLOT_ITEM_END; i++)
{
Item *item = player->GetItemByPos(INVENTORY_SLOT_BAG_0, i);
if (!item) continue;
if (!item->IsBag())
{
if (item->GetState() == state)
PSendSysMessage("bag: 255 slot: %d guid: %d owner: %d", item->GetSlot(), item->GetGUIDLow(), GUID_LOPART(item->GetOwnerGUID()));
}
else
{
Bag *bag = (Bag*)item;
const ItemPrototype *proto = bag->GetProto();
for (uint8 i = 0; i < proto->ContainerSlots; i++)
{
Item* item = bag->GetItemByPos(i);
if (item && item->GetState() == state)
PSendSysMessage("bag: 255 slot: %d guid: %d owner: %d", item->GetSlot(), item->GetGUIDLow(), GUID_LOPART(item->GetOwnerGUID()));
}
}
}
}
if (list_queue)
{
std::vector<Item *> &updateQueue = player->GetItemUpdateQueue();
for(size_t i = 0; i < updateQueue.size(); i++)
{
Item *item = updateQueue[i];
if(!item) continue;
Bag *container = item->GetContainer();
uint8 bag_slot = container ? container->GetSlot() : INVENTORY_SLOT_BAG_0;
std::string st;
switch(item->GetState())
{
case ITEM_UNCHANGED: st = "unchanged"; break;
case ITEM_CHANGED: st = "changed"; break;
case ITEM_NEW: st = "new"; break;
case ITEM_REMOVED: st = "removed"; break;
}
PSendSysMessage("bag: %d slot: %d guid: %d - state: %s", bag_slot, item->GetSlot(), item->GetGUIDLow(), st.c_str());
}
if (!updateQueue.size())
PSendSysMessage("updatequeue empty");
}
if (check_all)
{
bool error = false;
std::vector<Item *> &updateQueue = player->GetItemUpdateQueue();
for (uint8 i = 0; i < INVENTORY_SLOT_ITEM_END; i++)
{
Item *item = player->GetItemByPos(INVENTORY_SLOT_BAG_0, i);
if (!item) continue;
if (item->GetSlot() != i)
{
PSendSysMessage("item at slot %d, guid %d has an incorrect slot value: %d", i, item->GetGUIDLow(), item->GetSlot());
error = true; continue;
}
if (item->GetOwnerGUID() != player->GetGUID())
{
PSendSysMessage("for the item at slot %d and itemguid %d, owner's guid (%d) and player's guid (%d) don't match!", item->GetSlot(), item->GetGUIDLow(), GUID_LOPART(item->GetOwnerGUID()), player->GetGUIDLow());
error = true; continue;
}
Bag *container = item->GetContainer();
if (container)
{
PSendSysMessage("item at slot: %d guid: %d has a container (slot: %d, guid: %d) but shouldnt!", item->GetSlot(), item->GetGUIDLow(), container->GetSlot(), container->GetGUIDLow());
error = true; continue;
//.........这里部分代码省略.........