本文整理汇总了C++中ItemInstance::isStackable方法的典型用法代码示例。如果您正苦于以下问题:C++ ItemInstance::isStackable方法的具体用法?C++ ItemInstance::isStackable怎么用?C++ ItemInstance::isStackable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ItemInstance
的用法示例。
在下文中一共展示了ItemInstance::isStackable方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: giveItem
//----[ giveItem ]-----------------------------------------------------------
bool ClientItemsInterface::giveItem(ItemPointer* item_pointer,
unsigned int* assigned_index) {
if (!item_pointer || item_pointer->invalid()) return false;
ItemInstance* item = item_pointer->dereferenceAssumingValid(); // justified by prev. line
int source_quantity = item->getQuantity();
if (source_quantity < 0) return false;
// stack with existing items
if (item->isStackable()) {
unsigned int start_search_index = 0;
while (item &&
start_search_index < items_in_inventory_) { // keep the index safe!
ItemInstance* stackable_item = NULL;
if (!findStackableItemInInventory(item,
start_search_index,
&start_search_index,
&stackable_item)) break;
inventory_dirty_bits_.set(start_search_index);
update_inventory_ = true;
++start_search_index;
item->setQuantity(stackable_item->addQuantity(item->getQuantity()));
if (item->getQuantity() <= 0) {
GlobalItemManager::singleton()->releaseItem(item_pointer);
item = NULL;
}
}
}
// add to the inventory
return item ? addToInventory(*item_pointer, assigned_index) : true;
}
示例2: setInventoryItem
//----[ setInventoryItem ]---------------------------------------------------
void ClientItemsInterface::setInventoryItem(unsigned int index,
ItemPointer& item_pointer) {
ItemInstance* item = item_pointer.dereferenceAssumingValid();
inventory_[index].item.copy(item_pointer);
inventory_[index].stackable = item->isStackable();
inventory_[index].equipped = false;
inventory_dirty_bits_.set(index);
update_inventory_ = true;
{ // become the owner of this item
//inventory_[index].item.becomeUniquePointer();
GlobalDatabaseManager::singleton()->itemChangeOwner(item->getUniqueID(),
account_id_,
character_id_,
session_id_);
}
}