示例#1
0
// ****************************************************************************
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);
}
示例#2
0
// ****************************************************************************
void CInventoryBase::updateWeightAndBulk(const CGameItemPtr &item, sint32 deltaQt)
{
	const CStaticItem *form = item->getStaticForm();

	if (form != NULL)
	{
		_InventoryBulk = uint32(max(sint32(0), sint32(_InventoryBulk + form->Bulk*deltaQt)));
		_InventoryWeight = uint32(max(sint32(0), sint32(_InventoryWeight + item->weight()*deltaQt)));

		if (_InventoryWeight > getMaxWeight())
		{
			nlwarning("Inventory '%s' : weight is overload", INVENTORIES::toString(_InventoryId).c_str());
		}
		if (_InventoryBulk > getMaxBulk())
		{
			nlwarning("Inventory '%s' : bulk is overload", INVENTORIES::toString(_InventoryId).c_str());
		}
	}
}