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


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

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


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

示例1: Execute


//.........这里部分代码省略.........
			INT	OtItemNum = 0;
			BOOL	bFlag = FALSE;

			//用来记录可以交换的物品
			struct ExItem_t
			{
				UCHAR	uItemType;
				INT		nIndex;
				INT		nIndexInEx;
				ExItem_t()
				{
					uItemType	= 0;
					nIndex		= -1;
					nIndexInEx	= -1;
				}
			};

			INT				ExItemNumOt = 0;
			ExItem_t		ExItemIndexInOt[EXCHANGE_BOX_SIZE];
			INT				ExItemNumMy = 0;
			ExItem_t		ExItemIndexInMy[EXCHANGE_BOX_SIZE];
			INT				ExPetItemNumOt = 0;
			ExItem_t		ExPetItemIndexInOt[EXCHANGE_PET_BOX_SIZE];
			INT				ExPetItemNumMy = 0;
			ExItem_t		ExPetItemIndexInMy[EXCHANGE_PET_BOX_SIZE];

			for(INT i = 0; i<EXCHANGE_BOX_SIZE; i++)
			{
				if(pMyExchangeContainer->GetItem(i)->IsEmpty() == FALSE)
				{
					Item* pItemRef = pMyExchangeContainer->GetItem(i);
					ItemContainer*	pMyBagContainer = HumanItemLogic::GetItemContain(pHuman, pItemRef->GetItemTableIndex());
					ExItemIndexInMy[ExItemNumMy].uItemType	= pItemRef->GetItemClass();
					ExItemIndexInMy[ExItemNumMy].nIndex		= pMyBagContainer->GetIndexByGUID(&pItemRef->GetGUID());
					ExItemIndexInMy[ExItemNumMy].nIndexInEx	= i;
					ExItemNumMy++;
				}

				if(pOtExchangeContainer->GetItem(i)->IsEmpty() == FALSE)
				{
					Item* pItemRef = pOtExchangeContainer->GetItem(i);
					ItemContainer*	pOtBagContainer = HumanItemLogic::GetItemContain(pDestHuman, pItemRef->GetItemTableIndex());
					ExItemIndexInOt[ExItemNumOt].uItemType	= pItemRef->GetItemClass();
					ExItemIndexInOt[ExItemNumOt].nIndex		= pOtBagContainer->GetIndexByGUID(&pItemRef->GetGUID());
					ExItemIndexInOt[ExItemNumOt].nIndexInEx	= i;
					ExItemNumOt++;
				}
			}

			for(INT i = 0; i<EXCHANGE_PET_BOX_SIZE; i++)
			{
				if(pMyExchangePetContainer->GetItem(i)->IsEmpty() == FALSE)
				{
					Item* pItemRef = pMyExchangePetContainer->GetItem(i);
					ItemContainer*	pMyPetContainer = pHuman->GetPetContain();
					ExPetItemIndexInMy[ExPetItemNumMy].nIndex = pMyPetContainer->GetIndexByGUID(&pItemRef->GetPetGUID());
					ExPetItemIndexInMy[ExPetItemNumMy].nIndexInEx = i;
					ExPetItemNumMy++;
				}

				if(pOtExchangePetContainer->GetItem(i)->IsEmpty() == FALSE)
				{
					Item* pItemRef = pOtExchangePetContainer->GetItem(i);
					ItemContainer*	pOtPetContainer = pDestHuman->GetPetContain();
					ExPetItemIndexInOt[ExPetItemNumOt].nIndex		= pOtPetContainer->GetIndexByGUID(&pItemRef->GetPetGUID());
					ExPetItemIndexInOt[ExPetItemNumOt].nIndexInEx = i;
开发者ID:ueverything,项目名称:mmo-resourse,代码行数:67,代码来源:CGExchangeOkIIIHandler.cpp

示例2: Execute

uint CGStallRemoveItemHandler::Execute( CGStallRemoveItem* 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 ) ;

	_ITEM_GUID	ItemGuid	= pPacket->GetObjGUID();
	PET_GUID_t  PetGuid		= pPacket->GetPetGUID();
	BYTE		ToType		= pPacket->GetToType();
	UINT		Serial		= pPacket->GetSerial();

	if(pHuman->m_StallBox.GetStallStatus() != ServerStallBox::STALL_OPEN)
	{
		GCStallError	Msg;
		Msg.SetID(STALL_MSG::ERR_ILLEGAL);
		pGamePlayer->SendPacket(&Msg);
		g_pLog->FastSaveLog( LOG_FILE_1, "ERROR: CGStallRemoveItemHandler::ObjName=%s, ERR_ILLEGAL: != ServerStallBox::STALL_OPEN"
			,pHuman->GetName()) ;
		return PACKET_EXE_CONTINUE;
	}

	ItemContainer*			pStallContainer		= pHuman->m_StallBox.GetContainer();
	ItemContainer*			pStallPetContainer	= pHuman->m_StallBox.GetPetContainer();
	GCStallError			MsgError;
	GCStallRemoveItem		MsgRemoveItem;

	switch(ToType)
	{
	case STALL_MSG::POS_BAG:
		{
			INT	IndexInStall = pStallContainer->GetIndexByGUID(&ItemGuid);
			if(IndexInStall<0)
			{
				MsgError.SetID(STALL_MSG::ERR_NEED_NEW_COPY);
				pGamePlayer->SendPacket(&MsgError);
				g_pLog->FastSaveLog( LOG_FILE_1, "ERROR: CGStallRemoveItemHandler::ObjName=%s, ERR_NEED_NEW_COPY: IndexInStall = %d"
					,pHuman->GetName(), IndexInStall) ;
				return PACKET_EXE_CONTINUE;
			}

			if( pHuman->m_StallBox.GetSerialByIndex(IndexInStall) > Serial)
			{
				MsgError.SetID(STALL_MSG::ERR_NEED_NEW_COPY);
				pGamePlayer->SendPacket(&MsgError);
				g_pLog->FastSaveLog( LOG_FILE_1, "ERROR: CGStallRemoveItemHandler::ObjName=%s, ERR_NEED_NEW_COPY: Serial = %d, BoxSerial = %d"
					,pHuman->GetName(), Serial, pHuman->m_StallBox.GetSerialByIndex(IndexInStall)) ;
				return PACKET_EXE_CONTINUE;
			}

			Item* pItem =	pStallContainer->GetItem(IndexInStall);
			
			ItemContainer* pBagContainer = HumanItemLogic::GetItemContain(pHuman, pItem->GetItemTableIndex());
			INT	IndexInBag = pBagContainer->GetIndexByGUID(&ItemGuid);
			if(IndexInBag<0)
			{
				MsgError.SetID(STALL_MSG::ERR_ILLEGAL);
				pHuman->m_StallBox.CleanUp();
				pGamePlayer->SendPacket(&MsgError);
				g_pLog->FastSaveLog( LOG_FILE_1, "ERROR: CGStallRemoveItemHandler::ObjName=%s, ERR_ILLEGAL: IndexInBag = %d"
					,pHuman->GetName(), IndexInBag) ;
				return PACKET_EXE_CONTINUE;
			}

			//解锁原背包中的物品
			g_ItemOperator.UnlockItem( pBagContainer, IndexInBag );

			//干掉物品
			if(g_ItemOperator.EraseItem(pStallContainer, IndexInStall)>0)
			{
				pHuman->m_StallBox.IncSerialByIndex(IndexInStall);
				pHuman->m_StallBox.SetPriceByIndex(IndexInStall, 0);
			}
			else
			{
				MsgError.SetID(STALL_MSG::ERR_ILLEGAL);
				pHuman->m_StallBox.CleanUp();
				pGamePlayer->SendPacket(&MsgError);
				g_pLog->FastSaveLog( LOG_FILE_1, "ERROR: CGStallRemoveItemHandler::ObjName=%s, ERR_ILLEGAL: IndexInStall = %d"
					,pHuman->GetName(), IndexInStall) ;
				return PACKET_EXE_CONTINUE;
			}

			//通知客户端
			MsgRemoveItem.SetObjGUID( ItemGuid );
			MsgRemoveItem.SetSerial( pHuman->m_StallBox.GetSerialByIndex(IndexInStall) );
			MsgRemoveItem.SetToType( STALL_MSG::POS_BAG );

//.........这里部分代码省略.........
开发者ID:ueverything,项目名称:mmo-resourse,代码行数:101,代码来源:CGStallRemoveItemHandler.cpp

示例3: Execute


//.........这里部分代码省略.........
								return PACKET_EXE_CONTINUE;
							}

						}
						else
						{
							MsgError.SetID(ERR_ILLEGAL);
							pGamePlayer->SendPacket(&MsgError);
							g_pLog->FastSaveLog( LOG_FILE_1, "<交易> [%s] 交易盒位置 [%d] 处不存在物品",	pHuman->GetName(), FromIndex ) ;
							return PACKET_EXE_CONTINUE;
						}
					}
					break;

				case POS_EQUIP:
					{
					}
					break;

				case POS_PET:
					{
					}
					break;
				default:
					break;

			}

		}
		break;
	case OPT_ADDPET:
		{
			ItemContainer*	pPetContainer = pHuman->GetPetContain();
			FromIndex = pPetContainer->GetIndexByGUID( &PetGuid );

            if (255 == FromIndex)
            {
                g_pLog->FastSaveLog( LOG_FILE_1, "<交易> [%s] 加入非法交易宠物",	pHuman->GetName()) ;
                return PACKET_EXE_CONTINUE ;
            }

			//先查一遍交易盒中是不是已经有该物品了
			for(INT i = 0; i<EXCHANGE_PET_BOX_SIZE; i++)
			{
				if(pExchangePetContainer->GetItem(i)->GetPetGUID() == pPetContainer->GetItem(FromIndex)->GetPetGUID() )
				{//物品已经在交易盒中,丢弃该消息
					return PACKET_EXE_CONTINUE ;
				}
			}

			//自动找格
			INT result = 
				g_ItemOperator.CopyItem
				(
				pPetContainer,
				FromIndex,
				pExchangePetContainer
				);

			if(result>=0)
			{//拷贝成功
				Item* pIt = pExchangePetContainer->GetItem(result);
				g_pLog->FastSaveLog( LOG_FILE_1, "<交易> [%s] 加入交易宠物 [%s]",	pHuman->GetName(), pIt->GetName() ) ;
				if(pIt->IsEmpty() == FALSE)
				{
					//先锁定此物品
开发者ID:uvbs,项目名称:wx2Server,代码行数:67,代码来源:CGExchangeSynchItemIIHandler.cpp

示例4: Execute

uint CGStallItemPriceHandler::Execute( CGStallItemPrice* 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 ) ;

	//操作
	_ITEM_GUID	ItemGuid	=	pPacket->GetObjGUID();
	PET_GUID_t	PetGuid		=	pPacket->GetPetGUID();
	UINT		ItemPrice	=	pPacket->GetPrice();
	UINT		ItemSerial	=	pPacket->GetSerial();

	if(pHuman->m_StallBox.GetStallStatus() != ServerStallBox::STALL_OPEN)
	{
		GCStallError	Msg;
		Msg.SetID(STALL_MSG::ERR_ILLEGAL);
		pGamePlayer->SendPacket(&Msg);
		g_pLog->FastSaveLog( LOG_FILE_1, "ERROR: CGStallItemPriceHandler::ObjName=%s, ERR_ILLEGAL:!= ServerStallBox::STALL_OPEN"
			,pHuman->GetName()) ;
		return PACKET_EXE_CONTINUE ;
	}

	ItemContainer*		pStallContainer		= pHuman->m_StallBox.GetContainer();
	ItemContainer*		pStallPetContainer	= pHuman->m_StallBox.GetPetContainer();
	GCStallError		MsgError;

	if(PetGuid.IsNull())
	{//对物品的价格操作
		INT	IndexInStall	=	pStallContainer->GetIndexByGUID(&ItemGuid);
		if(IndexInStall<0)
		{
			MsgError.SetID(STALL_MSG::ERR_NEED_NEW_COPY);
			pGamePlayer->SendPacket(&MsgError);
			g_pLog->FastSaveLog( LOG_FILE_1, "ERROR: CGStallItemPriceHandler::ObjID=%d, ERR_NEED_NEW_COPY: IndexInStall = %d"
				,pHuman->GetID(), IndexInStall) ;
			return PACKET_EXE_CONTINUE ;
		}

		if(pHuman->m_StallBox.GetSerialByIndex(IndexInStall) > ItemSerial)
		{
			MsgError.SetID(STALL_MSG::ERR_NEED_NEW_COPY);
			pGamePlayer->SendPacket(&MsgError);
			g_pLog->FastSaveLog( LOG_FILE_1, "ERROR: CGStallItemPriceHandler::ObjID=%d, ERR_NEED_NEW_COPY: ItemSerial = %d, BoxSerial = %d"
				,pHuman->GetID(), ItemSerial, pHuman->m_StallBox.GetSerialByIndex(IndexInStall)) ;
			return PACKET_EXE_CONTINUE ;
		}

		pHuman->m_StallBox.SetPriceByIndex(IndexInStall, ItemPrice);
		pHuman->m_StallBox.IncSerialByIndex(IndexInStall);

		//给Client返回一条消息,告诉Client版本号
		GCStallItemPrice msg;
		msg.SetObjGUID(pPacket->GetObjGUID());
		msg.SetPrice(pPacket->GetPrice());
		msg.SetSerial(pHuman->m_StallBox.GetSerialByIndex(IndexInStall));

		pGamePlayer->SendPacket(&msg);

		g_pLog->FastSaveLog( LOG_FILE_1, "CGStallItemPriceHandler::ObjName=%s, ERR_NEED_NEW_COPY: IndexInStall = %d, ItemPrice = %d"
			,pHuman->GetName(), IndexInStall, ItemPrice) ;
	}
	else
	{//改变宠物价格
		INT	PetIndexInStall	= pStallPetContainer->GetIndexByGUID(&PetGuid);

		if(PetIndexInStall<0)
		{
			MsgError.SetID(STALL_MSG::ERR_NEED_NEW_COPY);
			pGamePlayer->SendPacket(&MsgError);
			g_pLog->FastSaveLog( LOG_FILE_1, "ERROR: CGStallItemPriceHandler::ObjName=%s, ERR_NEED_NEW_COPY: PetIndexInStall = %d"
				,pHuman->GetName(), PetIndexInStall) ;
			return PACKET_EXE_CONTINUE ;
		}

		if(pHuman->m_StallBox.GetPetSerialByIndex(PetIndexInStall) != ItemSerial)
		{
			MsgError.SetID(STALL_MSG::ERR_NEED_NEW_COPY);
			pGamePlayer->SendPacket(&MsgError);
			g_pLog->FastSaveLog( LOG_FILE_1, "ERROR: CGStallItemPriceHandler::ObjName=%s, ERR_NEED_NEW_COPY: ItemSerial = %d, BoxSerial = %d"
				,pHuman->GetName(), ItemSerial, pHuman->m_StallBox.GetPetSerialByIndex(PetIndexInStall)) ;
			return PACKET_EXE_CONTINUE ;
		}

		pHuman->m_StallBox.SetPetPriceByIndex(PetIndexInStall, ItemPrice);
		pHuman->m_StallBox.IncPetSerialByIndex(PetIndexInStall);

		//给Client返回一条消息,告诉Client版本号
//.........这里部分代码省略.........
开发者ID:ueverything,项目名称:mmo-resourse,代码行数:101,代码来源:CGStallItemPriceHandler.cpp

示例5: Execute

uint CGStallAddItemHandler::Execute( CGStallAddItem* 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 ) ;

	//操作
	_ITEM_GUID	ItemGuid = pPacket->GetObjGUID();
	UINT		ItemPrice = pPacket->GetPrice();
	BYTE		FromType = pPacket->GetFromType();
	PET_GUID_t	PetGuid  = pPacket->GetPetGUID();

	if(pHuman->m_StallBox.GetStallStatus() != ServerStallBox::STALL_OPEN)
	{
		GCStallError	Msg;
		Msg.SetID(STALL_MSG::ERR_ILLEGAL);
		pGamePlayer->SendPacket(&Msg);
		g_pLog->FastSaveLog( LOG_FILE_1, "ERROR: CGStallAddItemHandler::ObjID=%d ERR_ILLEGAL: != ServerStallBox::STALL_OPEN", pHuman->GetID()) ;
		return PACKET_EXE_CONTINUE ;
	}
	
	ItemContainer*		pStallContainer		= pHuman->m_StallBox.GetContainer();
	ItemContainer*		pStallPetContainer	= pHuman->m_StallBox.GetPetContainer();

	GCStallError		MsgError;
	GCStallAddItem		MsgAddItem;

	switch(FromType)
	{
	case STALL_MSG::POS_BAG :
		{
			//ItemContainer* pMatContainer	= pHuman->GetMatContain();
			ItemContainer* pBaseContainer	= pHuman->GetBaseContain();
			//ItemContainer* pBagContainer	=	NULL;

			//if(pMatContainer->GetIndexByGUID(&ItemGuid) >= 0)
			//{
			//	pBagContainer = pMatContainer;
			//}
			//else if(pBaseContainer->GetIndexByGUID(&ItemGuid) >=0 )
			//{
			//	pBagContainer = pBaseContainer;
			//}
			//else
			//{//guid非法
			//	Assert(0);
			//	GCStallError	Msg;
			//	Msg.SetID(STALL_MSG::ERR_ILLEGAL);
			//	pGamePlayer->SendPacket(&Msg);
			//	g_pLog->FastSaveLog( LOG_FILE_1, "ERROR: CGStallAddItemHandler::ObjID=%d, ERR_ILLEGAL:World = %d, Server = %d, Serial = %d "
			//		,pHuman->GetID(), ItemGuid.m_World, ItemGuid.m_Server, ItemGuid.m_Serial) ;
			//	return PACKET_EXE_CONTINUE ;
			//}

			INT	IndexInBag = pBaseContainer->GetIndexByGUID(&ItemGuid);
			
			//先查一遍摊位盒中是不是已经有该物品了
			for(INT i = 0; i<STALL_BOX_SIZE; i++)
			{
				if(pStallContainer->GetItem(i)->GetGUID() == ItemGuid )
				{//物品已经在t摊位盒中,丢弃该消息
					g_pLog->FastSaveLog( LOG_FILE_1, "ERROR: CGStallAddItemHandler::ObjID=%d, Already in box "
						,pHuman->GetID()) ;
					return PACKET_EXE_CONTINUE ;
				}
			}

			//拷贝到摊位盒
			//自动找格
			INT result = 
				g_ItemOperator.CopyItem
				(
				pBaseContainer,
				IndexInBag,
				pStallContainer
				);

			if(result>=0)
			{//拷贝成功,
				//发送消息给双方客户端
				Item* pIt = pStallContainer->GetItem(result);
				if(pIt->IsEmpty() == FALSE)
				{
					//先锁定此物品
					g_ItemOperator.LockItem( pBaseContainer, IndexInBag );

//.........这里部分代码省略.........
开发者ID:yuanxiubin1128,项目名称:mmo-resourse,代码行数:101,代码来源:CGStallAddItemHandler.cpp


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