当前位置: 首页>>代码示例>>C++>>正文


C++ CGameItemPtr::getStackSize方法代码示例

本文整理汇总了C++中CGameItemPtr::getStackSize方法的典型用法代码示例。如果您正苦于以下问题:C++ CGameItemPtr::getStackSize方法的具体用法?C++ CGameItemPtr::getStackSize怎么用?C++ CGameItemPtr::getStackSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CGameItemPtr的用法示例。


在下文中一共展示了CGameItemPtr::getStackSize方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: deleteStackItem

// ****************************************************************************
uint32 CInventoryBase::deleteStackItem(uint32 slot, uint32 quantity, TInventoryOpResult * res)
{
	nlassert(slot < _Items.size());
	
	uint32 nbDeletedItem = 0;

	CGameItemPtr item = getItem(slot);
	if(item->getStackSize() > quantity)
	{
		nbDeletedItem = quantity;
		item->setStackSize( item->getStackSize() - quantity );
//		log_Item_UpdateQuantity(item->getItemId(), item->getStackSize(), item->getStackSize() - quantity);
		if( res != NULL )
			*res = ior_ok;
	}
	else
	{
		nbDeletedItem = item->getStackSize();
		deleteItem(slot);
		if( res != NULL )
		{
			if( quantity == nbDeletedItem )
				*res = ior_ok;
			else
				*res = ior_stack_undersize;
		}
	}
	return nbDeletedItem;
}
开发者ID:Kiddinglife,项目名称:ryzom,代码行数:30,代码来源:player_inventory.cpp

示例2: createItem

//---------------------------------------------------
// createItem :
//
//---------------------------------------------------
//CGameItemPtr CGameItemManager::createItem( CEntityId& id, CSheetId& sheetId, uint16 quality, sint16 slot, bool destroyable, bool dropable , const CEntityId &creatorId )
CGameItemPtr CGameItemManager::createItem( const CSheetId& sheetId, uint16 quality, bool destroyable, bool dropable , const CEntityId &creatorId )
{
	H_AUTO(GIM_createItem1);
	
	// test if the item already exists
//	map<CEntityId,CGameItemPtr>::iterator itIt = _Items.find( id );
//	if( itIt != _Items.end() )
//	{
//		nlwarning("<CGameItemManager::createItem> The item %s already exists",id.toString().c_str());
//		return NULL;
//	}

// MALKAV 22/01/03 :  get owner, if owner not found, returns before creating the item and display a simple warning
//	CGameItemPtr ownerItem = NULL;
//	if( owner != CEntityId::Unknown )
//	{
//		ownerItem = getItem( owner );
//		BOMB_IF(ownerItem == NULL ,"Bad owner found for item",return NULL);
//	}
//
	// create a new item
//	CGameItemPtr item = getNewItem( id, sheetId, quality, destroyable, dropable );
	CGameItemPtr item = getNewItem(sheetId, quality, destroyable, dropable );
	if( item != NULL )
	{
//		nldebug("<CGameItemManager::createItem> create item %s with owner %s",id.toString().c_str(), owner.toString().c_str());

//		(*item)->Owner = owner;
		(*item)->setCreator( creatorId );
		
		// insert the item in the map
//		_Items.insert( make_pair(id,item) );
//		_Items.insert( item );

		// insert the item in the children of the owner
// MALKAV 22/01/03 : test the owner existence sooner and use a warning instead of an nlerror to keep going
//		if( owner != CEntityId::Unknown )
//		{
//		 	CGameItemPtr ownerItem = getItem( owner );
//			if( ownerItem!=NULL )
//			{
//				(*ownerItem)->addChild( item, slot );
//			}
//			else
//			{				
//				nlerror("<CGameItemManager::createItem> Can't find the owner item %s",owner.toString().c_str());
//			}
//		}
	}
	else
	{
//		nlwarning("<CGameItemManager::createItem> Can't create the item %s with invalid sheet '%s'", id.toString().c_str(), sheetId.toString().c_str());
		nlwarning("<CGameItemManager::createItem> Can't create an item with invalid sheet '%s'", sheetId.toString().c_str());
	}

	log_Item_Create(item->getItemId(), item->getSheetId(), item->getStackSize(), item->quality());

	return item;

} // createItem //
开发者ID:mixxit,项目名称:solinia,代码行数:65,代码来源:game_item_manager.cpp

示例3: removeItem

// ****************************************************************************
CGameItemPtr CRefInventory::removeItem(uint32 slot, uint32 quantity, TInventoryOpResult * res)
{
	nlassert(slot < _Items.size());

	CGameItemPtr ret = _Items[slot];
	if (_Items[slot] != NULL)
	{
		// unlink the item
		_Items[slot]->setRefInventory(CInventoryPtr(NULL), INVENTORIES::INVALID_INVENTORY_SLOT);
		CGameItemPtr item = _Items[slot];
		_Items[slot] = NULL;
		++_FreeSlotCount;

		updateWeightAndBulk(ret, -sint32(ret->getStackSize()));

		// callbacks for derived class
		onItemChanged(slot, INVENTORIES::itc_removed);
		// callback views
		INVENTORIES::TInventoryChangeFlags flagInvChg(INVENTORIES::ic_total_bulk);
		flagInvChg.setEnumValue(INVENTORIES::ic_total_weight);
		flagInvChg.setEnumValue(INVENTORIES::ic_item_list);
		TViewCont::iterator first(_InventoryViews.begin()), last(_InventoryViews.end());
		for (; first != last; ++first)
		{
			CInventoryViewPtr view = *first;
			view->onInventoryChanged(flagInvChg);
			view->onItemChanged(slot, INVENTORIES::itc_removed);
		}
	}

	if (res != NULL)
		*res = ior_ok;

	return ret;
}
开发者ID:Kiddinglife,项目名称:ryzom,代码行数:36,代码来源:player_inventory.cpp

示例4: canStackItem

/// test if we can stack an item on an existing one
// ****************************************************************************
CInventoryBase::TInventoryOpResult CInventoryBase::canStackItem(const CGameItemPtr &item, uint32 slotDst)
{
	if (item == NULL || slotDst >= getSlotCount())
		return ior_error;

	CGameItemPtr dstItem = getItem(slotDst);

	// ok if slot is empty
	if (dstItem == NULL)
		return ior_ok;

	// check item sheet and craft params
	if (!CGameItem::areStackable(item, dstItem))
		return ior_item_incompatible;

	const CStaticItem *srcForm = CSheets::getForm(item->getSheetId());

	if (dstItem->getStackSize() + item->getStackSize() > dstItem->getMaxStackSize())
		return ior_stack_oversize;

	return ior_ok;
}
开发者ID:Kiddinglife,项目名称:ryzom,代码行数:24,代码来源:player_inventory.cpp

示例5: first

// ****************************************************************************
void	CInventoryBase::onItemStackSizeChanged(uint32 slot, uint32 previousStackSize)
{
	CGameItemPtr item = getItem(slot);
	sint32 deltaSize = item->getStackSize() - previousStackSize;

	updateWeightAndBulk(item, deltaSize);

	// callback all the views
	TViewCont::iterator first(_InventoryViews.begin()), last(_InventoryViews.end());
	for (; first!= last; ++first)
	{
		CInventoryViewPtr view = *first;

		view->onItemStackSizeChanged(slot, previousStackSize);
	}
}
开发者ID:Kiddinglife,项目名称:ryzom,代码行数:17,代码来源:player_inventory.cpp

示例6: updateClientSlot

// ****************************************************************************
void CCharacterInvView::updateClientSlot(uint32 slot, const CGameItemPtr item)
{
	// do nothing if client is not ready
	if (!getCharacter()->getEnterFlag())
		return;

	if (item != NULL)
	{
		uint32 price;
		RM_FABER_STAT_TYPE::TRMStatType itemBestStat;

		getCharacter()->queryItemPrice( item, price );
		itemBestStat = item->getCraftParameters() == 0 ? RM_FABER_STAT_TYPE::Unknown : item->getCraftParameters()->getBestItemStat();

		BOTCHATTYPE::TBotChatResaleFlag resaleFlag = (item->durability() == item->maxDurability() ? BOTCHATTYPE::ResaleOk : BOTCHATTYPE::ResaleKOBroken);
		if (item->getLockedByOwner())
		{
			resaleFlag = BOTCHATTYPE::ResaleKOLockedByOwner;
		}

		INVENTORIES::CItemSlot itemSlot( slot );
		itemSlot.setItemProp( INVENTORIES::Sheet, item->getSheetId().asInt() );
		itemSlot.setItemProp( INVENTORIES::Quality, item->quality() );
		itemSlot.setItemProp( INVENTORIES::Quantity, item->getStackSize() );
		itemSlot.setItemProp( INVENTORIES::UserColor, item->color() );
		itemSlot.setItemProp( INVENTORIES::Locked, item->getLockCount() );
		itemSlot.setItemProp( INVENTORIES::Weight, item->weight() / 10 );
		itemSlot.setItemProp( INVENTORIES::NameId, item->sendNameId(getCharacter()) );
		itemSlot.setItemProp( INVENTORIES::Enchant, item->getClientEnchantValue() );
		itemSlot.setItemProp( INVENTORIES::Price, price );
		itemSlot.setItemProp( INVENTORIES::ResaleFlag, resaleFlag );
		itemSlot.setItemProp( INVENTORIES::ItemClass, item->getItemClass() );
		itemSlot.setItemProp( INVENTORIES::ItemBestStat, itemBestStat );
		itemSlot.setItemProp( INVENTORIES::PrerequisitValid, getCharacter()->checkPreRequired( item ) );
		itemSlot.setItemProp( INVENTORIES::Worned, (item->getItemWornState()==ITEM_WORN_STATE::Worned));
		getCharacter()->_InventoryUpdater.setItemProps( getInventory()->getInventoryId(), itemSlot );
	}
	else
	{
		// empty slot
		getCharacter()->_InventoryUpdater.resetItem( getInventory()->getInventoryId(), slot );
	}

	// send slot update to the client
	getCharacter()->_InventoryUpdater.incInfoVersion(getInventory()->getInventoryId(), slot);
}
开发者ID:Kiddinglife,项目名称:ryzom,代码行数:47,代码来源:player_inventory.cpp

示例7: doInsertItem

// ****************************************************************************
CInventoryBase::TInventoryOpResult CRefInventory::doInsertItem(CGameItemPtr &item, uint32 slot, bool autoStack, bool ignoreWeightAndBulk)
{
	nlassert(item != NULL);
	nlassert(item->getRefInventory() == NULL);
	nlassert(slot < _Items.size() || slot == INVENTORIES::INVALID_INVENTORY_SLOT);

	if (!ignoreWeightAndBulk)
	{
		if (item->getStackWeight() + getInventoryWeight() > getMaxWeight())
			return ior_overweight;
		if (item->getStackBulk() + getInventoryBulk() > getMaxBulk())
			return ior_overbulk;
	}

	// check that we still have a free slot
	if (getFreeSlotCount() == 0)
		return ior_no_free_slot;

	if (slot == INVENTORIES::INSERT_IN_FIRST_FREE_SLOT)
		slot = getFirstFreeSlot();

	// remove any item referenced here
	removeItem(slot);

	// insert and link the new item
	_Items[slot] = item;
	item->setRefInventory(CInventoryPtr(this), slot);
	updateWeightAndBulk(item, item->getStackSize());
	--_FreeSlotCount;

	// callbacks for derived class
	onItemChanged(slot, INVENTORIES::itc_inserted);
	// callback views
	/*TViewCont::iterator first(_InventoryViews.begin()), last(_InventoryViews.end());
	for (; first != last; ++first)
	{
		CInventoryViewPtr view = *first;
		view->onItemChanged(slot, itc_inserted);
	}*/

	return ior_ok;
}
开发者ID:Kiddinglife,项目名称:ryzom,代码行数:43,代码来源:player_inventory.cpp


注:本文中的CGameItemPtr::getStackSize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。