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


C++ ItemContainer::ConIndex2BagIndex方法代码示例

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


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

示例1: Execute


//.........这里部分代码省略.........
							g_ItemOperator.ExchangeItem
							(
							pMyBagContainer,
							BagIndex,
							pOtBagContainer,
							ExItemIndexInOt[j].nIndex
							);
						if(result<0)
						{//拷贝失败
							GCExchangeError Msg;
							Msg.SetID(EXCHANGE_MSG::ERR_ILLEGAL);
							pHuman->GetPlayer()->SendPacket(&Msg);
							pDestHuman->GetPlayer()->SendPacket(&Msg);
							pHuman->m_ExchangBox.CleanUp();
							pDestHuman->m_ExchangBox.CleanUp();
							g_pLog->FastSaveLog( LOG_FILE_1, "		<交易> [%s] <-> [%s] 物品 [%d]失败 result = %d", pHuman->GetName(), pDestHuman->GetName(), pItemRef->GetItemTableIndex(), result );
							return PACKET_EXE_CONTINUE;
						}
						else
						{
							ITEM_LOG_PARAM	ItemLogParam;
							ItemLogParam.OpType		=	ITEM_EXCHANGE_TOOTHER;
							ItemLogParam.CharGUID	=	pHuman->GetGUID();
							ItemLogParam.TargetGUID	=	pDestHuman->GetGUID();
							ItemLogParam.XPos		=	pHuman->getWorldPos()->m_fX;
							ItemLogParam.ZPos		=	pHuman->getWorldPos()->m_fZ;
							ItemLogParam.SceneID	=	pHuman->getScene()->SceneID();
							ItemLogParam.ItemGuid	=	pItemRef->GetGUID();
							ItemLogParam.ItemType	=	pItemRef->GetItemTableIndex();

							ItemListToOt[OtItemNum].m_FromType	= 0;
							ItemListToOt[OtItemNum].m_FromIndex = i;
							ItemListToOt[OtItemNum].m_ToType	= EXCHANGE_MSG::POS_BAG;
							ItemListToOt[OtItemNum++].m_ToIndex	= pOtBagContainer->ConIndex2BagIndex(ExItemIndexInOt[j].nIndex);

							ItemListToMe[MyItemNum].m_FromType	= 0;
							ItemListToMe[MyItemNum].m_FromIndex = ExItemIndexInOt[j].nIndexInEx;
							ItemListToMe[MyItemNum].m_ToType	= EXCHANGE_MSG::POS_BAG;
							ItemListToMe[MyItemNum++].m_ToIndex	= pMyBagContainer->ConIndex2BagIndex(BagIndex);

							//从交易盒中删掉此物品,在后面的移动中就不用再移动它了
							g_ItemOperator.EraseItem(pMyExchangeContainer, i);
							g_ItemOperator.EraseItem(pOtExchangeContainer, ExItemIndexInOt[j].nIndexInEx);
							ExItemIndexInOt[j].nIndex = -1;
						
							g_pLog->FastSaveLog( LOG_FILE_1, "		<交易> [%s] <-> [%s] 物品 [%d]成功", pHuman->GetName(), pDestHuman->GetName(), pItemRef->GetItemTableIndex() );

							break;
						}
					}
				}
			}
	
			//3.2不能交换的一个一个放进去,剩下的直接由系统找格放入
			for(INT i = 0; i<EXCHANGE_BOX_SIZE; i++)
			{
				if(pMyExchangeContainer->GetItem(i)->IsEmpty() == FALSE)
				{
					INT result = 0;
					Item* pItemRef = pMyExchangeContainer->GetItem(i);

					//自己的容器
					ItemContainer*	pMyBagContainer = HumanItemLogic::GetItemContain(pHuman, pItemRef->GetItemTableIndex());
					INT	BagIndex = pMyBagContainer->GetIndexByGUID(&pItemRef->GetGUID());

					//对方的容器
开发者ID:ueverything,项目名称:mmo-resourse,代码行数:67,代码来源:CGExchangeOkIIIHandler.cpp

示例2: Execute

uint CGAskMyBagListHandler::Execute(CGAskMyBagList* pPacket, Player* pPlayer )
{
	__ENTER_FUNCTION

	GamePlayer* pGamePlayer = (GamePlayer*)pPlayer ;
	Assert( pGamePlayer ) ;

	Obj_Human* pHuman = pGamePlayer->GetHuman() ;
	Assert( pHuman ) ;

	Scene* pScene = pHuman->getScene() ;
	if( pScene==NULL )
	{
		Assert(FALSE) ;
		return PACKET_EXE_ERROR ;
	}

	//检查线程执行资源是否正确
	Assert( MyGetCurrentThreadID()==pScene->m_ThreadID ) ;

	
	ASK_BAG_MODE	mode		=	pPacket->GetAskMode();

	GCMyBagList Msg;

	switch(mode) 
	{
	case ASK_ALL:
		{
			_BAG_ITEM		ItemIterator;
			_ITEM_GUID		NullGuid;
			uint			AllAskCount = 0;
			uint            nItemCount  = 0;
			memset(&NullGuid,0,sizeof(_ITEM_GUID));
			

			Msg.SetAskMode(ASK_ALL);

			//读取扩展容器
			ItemContainer* pExtraContainer = pHuman->GetExtraContain();
			Assert(pExtraContainer);
			for( INT i=0; i<pExtraContainer->GetContainerSize(); i++ )
			{
				//临时代码
				Item*	pItem =	HumanItemLogic::GetExtraContainerItem(pHuman,pExtraContainer->ConIndex2BagIndex(i));
				Assert(pItem);

				if(!(pItem->IsEmpty()))
				{
					ItemIterator.m_nndex			=	pExtraContainer->ConIndex2BagIndex(i);
					pItem->SaveValueTo(&ItemIterator.m_nItemData);
					Msg.SetAskItemData(&ItemIterator,nItemCount);
					++nItemCount;
				}

			}
			//读取基本背包
			ItemContainer* pBaseContainer = pHuman->GetBaseContain();
			Assert(pBaseContainer);
			for( INT i=0; i<pBaseContainer->GetContainerSize(); i++ )
			{
				//临时代码
				Item*	pItem =	pBaseContainer->GetItem(i);
				Assert(pItem);

				if(!(pItem->IsEmpty()))
				{
					ItemIterator.m_nndex			=	pBaseContainer->ConIndex2BagIndex(i);
					pItem->SaveValueTo(&ItemIterator.m_nItemData);
					Msg.SetAskItemData(&ItemIterator,nItemCount);
					++nItemCount;
				}
			}

			//读取扩展背包
			for (INT j=0; j<MAX_EXTRA_BAG_NUM; ++j)
			{
				ItemContainer* pBaseContainer = pHuman->GetExtraBagContain(j);
				Assert(pBaseContainer);
				if (pBaseContainer->IsValid())
				{
					for( INT i=0; i<pBaseContainer->GetContainerSize(); i++ )
					{
						//临时代码
						Item*	pItem =	pBaseContainer->GetItem(i);
						Assert(pItem);

						if(!(pItem->IsEmpty()))
						{
							ItemIterator.m_nndex			=	pBaseContainer->ConIndex2BagIndex(i);
							pItem->SaveValueTo(&ItemIterator.m_nItemData);
							Msg.SetAskItemData(&ItemIterator,nItemCount);
							++nItemCount;
						}
					}
				}
			}

			Msg.SetItemCount(nItemCount);

//.........这里部分代码省略.........
开发者ID:uvbs,项目名称:wx2Server,代码行数:101,代码来源:CGAskMyBagListHandler.cpp

示例3: if


//.........这里部分代码省略.........
					msg.SetPackageIndex2(index2);
					pGamePlayer->SendPacket(&msg);
					
					Item* pDestItem = pExtraContainer->GetItem(index_container2);
					Assert(pDestItem);
					if (pDestItem->GetExtraBagBeginTime() == INVALID_TIME)
					{
						pDestItem->SetExtraBagBeginTime();
					}
					pHuman->ReInitExtraBag();

					g_pLog->FastSaveLog( LOG_FILE_1, "CGPackage_SwapItem: use extrabagitem, index2=%d ", index2 ) ;
					return PACKET_EXE_CONTINUE;
				}
				msg.SetResult(SWITCHITEM_FAIL);
				pGamePlayer->SendPacket(&msg);
				return PACKET_EXE_CONTINUE;
			}
			g_pLog->FastSaveLog( LOG_FILE_1, "CGPackage_SwapItem: index2=%d, can't put", index2) ;
			return PACKET_EXE_CONTINUE;
		}
		if (pExtraBagContainer->IsInContainer(index1))
		{
			return PACKET_EXE_CONTINUE;
		}
		if (pExtraBagContainer->IsCanUse())
		{
			INT nBagIndex = -1;
			nBagIndex =g_ItemOperator.MoveItem(pBagContainer, index_container1, pExtraBagContainer, -1);
			if (nBagIndex>=0)
			{
				msg.SetResult(SWITCHITEM_SUCCESS);
				msg.SetPackageIndex1(index1);
				msg.SetPackageIndex2(pExtraBagContainer->ConIndex2BagIndex(nBagIndex));
				pGamePlayer->SendPacket(&msg);
				g_pLog->FastSaveLog( LOG_FILE_1, "CGPackage_SwapItem: index1=%d, index2=%d Success", 
					index1, index2 ) ;
				return PACKET_EXE_CONTINUE;
			}
			msg.SetResult(SWITCHITEM_FAIL);
			pGamePlayer->SendPacket(&msg);
			return PACKET_EXE_CONTINUE;
		}
		msg.SetResult(SWITCHITEM_FAIL);
		pGamePlayer->SendPacket(&msg);
		return PACKET_EXE_CONTINUE;
	}
	if (index2 == BASE_BAG_POS)
	{
		if (index1<MAX_SINGLEBAG_SIZE)
		{
			return PACKET_EXE_CONTINUE;
		}
		
		ItemContainer* pBagContainer = pHuman->GetBaseContain();
		ItemContainer* pExtraBagContainer = HumanItemLogic::GetBagContainer(pHuman, index1);
		if (pExtraBagContainer == NULL)
		{
			g_pLog->FastSaveLog( LOG_FILE_1, "CGPackage_SwapItem: index1=%d, index2=%d fail", 
				index1, index2 ) ;
			return PACKET_EXE_ERROR;
		}
		INT index_container1 = pExtraBagContainer->BagIndex2ConIndex(index1);
		INT nBagIndex = -1;
		nBagIndex =g_ItemOperator.MoveItem(pExtraBagContainer, index_container1, pBagContainer, -1);
		if (nBagIndex>=0)
开发者ID:,项目名称:,代码行数:67,代码来源:


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