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


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

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


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

示例1: Execute


//.........这里部分代码省略.........
						{
							g_ItemOperator.MoveSpliceItem(pBagContainer,
								(UINT)pBagContainer->BagIndex2ConIndex(indexFrom),
								pBankContainer,
								(UINT)nSpliceTo);

							Item *pItemBag = pBagContainer->GetItem(pBagContainer->BagIndex2ConIndex(indexFrom));
							Item *pItemBank= pBankContainer->GetItem(nSpliceTo);

							//发一个通知更新银行的消息
							GCBankItemInfo MsgBankItemInfo;
							MsgBankItemInfo.setBankIndex((WORD)nSpliceTo);
							MsgBankItemInfo.setIsNull(pItemBank->IsEmpty());
							pItemBank->SaveValueTo(MsgBankItemInfo.getItem());
							pGamePlayer->SendPacket( &MsgBankItemInfo );

							//发送一个通知背包更新的消息
							GCItemInfo MsgBagItemInfo;
							MsgBagItemInfo.setID((WORD)indexFrom);
							MsgBagItemInfo.setIsNull(pItemBag->IsEmpty());
							pItemBag->SaveValueTo(MsgBagItemInfo.getItem());
							pGamePlayer->SendPacket( &MsgBagItemInfo );
						}
					}
					g_pLog->FastSaveLog( LOG_FILE_1, "CGBankAddItemHandler Empty Item indexFrom = %d", indexFrom) ;
					return PACKET_EXE_CONTINUE;
				}
				else				//不执行合并
				{
					//验证位置里是否有东西
					if(ITEMREFPTRISVALID(HumanItemLogic::GetItem(pHuman, indexFrom)))
					{
						if(ITEMREFPTRISVALID(HumanItemLogic::GetBankItem(pHuman, indexTo))) //执行了交换
						{
							//判断银行内的这个物品是不是能够放入背包中
							ItemContainer* pBankContainer = pHuman->GetBankContain();
							Item *pItem = pBankContainer->GetItem(indexTo); 

							ItemContainer *pHumanCon = HumanItemLogic::GetItemContain(pHuman, pItem->GetItemTableIndex());
							if( !pHumanCon )
							{
								//返回错误信息
								Msg.SetFromType(GCBankAddItem::ERROR_POS);
								break;
							}

							if( !pHumanCon->IsInContainer(indexFrom) )
							{
								//返回错误信息
								Msg.SetFromType(GCBankAddItem::ERROR_POS);
								break;
							}

							g_ItemOperator.ExchangeItem(pBagContainer,
								pBagContainer->BagIndex2ConIndex(indexFrom),
								pBankContainer,
								(UINT)indexTo);

							//执行了交换
							Msg.SetOperateType(GCBankAddItem::OPERATE_SWAP);
						}
						else //执行了移动
						{
							g_ItemOperator.MoveItem(pBagContainer,
								pBagContainer->BagIndex2ConIndex(indexFrom),
								pBankContainer,
								(UINT)indexTo);

							//执行了移动
							Msg.SetOperateType(GCBankAddItem::OPERATE_MOVE);
						}
						Msg.SetFromType(GCBankAddItem::BAG_POS);
						Msg.SetIndexFrom(indexFrom);
						Msg.SetIndexTo(indexTo);
						
					}
					else
					{
						Msg.SetFromType(GCBankAddItem::ERROR_POS);
					}
				}
			}
			else	//数据不合法
			{
				Msg.SetFromType(GCBankAddItem::ERROR_POS);
			}
		}
		break;
	default:
		break;
	}

	pGamePlayer->SendPacket( &Msg ) ;
	g_pLog->FastSaveLog( LOG_FILE_1, "CGBankAddItemHandler: indexFrom=%d, indexTo=%d", indexFrom, indexTo ) ;
		return PACKET_EXE_CONTINUE ;

	__LEAVE_FUNCTION

		return PACKET_EXE_ERROR ;
}
开发者ID:ueverything,项目名称:mmo-resourse,代码行数:101,代码来源:CGBankAddItemHandler.cpp

示例2: Execute


//.........这里部分代码省略.........
																pBankContainer,
																indexTo)
									== ITEMOE_SUCCESS)
								{
									GCItemInfo msg1;
									msg1.setID(indexFrom);
									msg1.setIsNull(pItem1->IsEmpty());
									pItem1->SaveValueTo(msg1.getItem());
									pGamePlayer->SendPacket(&msg1);

									GCBankItemInfo msg2;
									msg2.setBankIndex(indexTo);
									msg2.setIsNull(pItem2->IsEmpty());
									pItem2->SaveValueTo(msg2.getItem());
									pGamePlayer->SendPacket(&msg2);
								}
								g_pLog->FastSaveLog( LOG_FILE_1, "CGBankSwapItemHandler: MoveSpliceItem" ) ;
								return PACKET_EXE_CONTINUE ;
							}
							else
							{
								//判断银行内的这个物品是不是能够放入背包中
								ItemContainer* pBankContainer = pHuman->GetBankContain();
								Item *pItem = pBankContainer->GetItem(indexTo); 

								ItemContainer *pHumanCon = HumanItemLogic::GetItemContain(pHuman, pItem->GetItemTableIndex());
								if( !pHumanCon )
								{
									//返回错误信息
									Msg.SetToType(GCBankSwapItem::ERROR_POS);
									break;
								}

								if( !pHumanCon->IsInContainer(indexFrom) )
								{
									//返回错误信息
									Msg.SetToType(GCBankSwapItem::ERROR_POS);
									break;
								}

								g_ItemOperator.ExchangeItem(pBagContainer,
									pBagContainer->BagIndex2ConIndex(indexFrom),
									pBankContainer,
									(UINT)indexTo);

								Msg.SetFromType(GCBankSwapItem::BAG_POS);
								Msg.SetToType(GCBankSwapItem::BANK_POS);
								Msg.SetIndexFrom(indexFrom);
								Msg.SetIndexTo(indexTo);
							}
						}
						else
						{
							Msg.SetFromType(GCBankSwapItem::ERROR_POS);
							Msg.SetToType(GCBankSwapItem::ERROR_POS);
						}
					}
					else
					{
						Msg.SetFromType(GCBankSwapItem::ERROR_POS);
						Msg.SetToType(GCBankSwapItem::ERROR_POS);
					}
				}
				break;
			default:
				break;
开发者ID:ueverything,项目名称:mmo-resourse,代码行数:67,代码来源:CGBankSwapItemHandler.cpp

示例3: if

uint CGPackage_SwapItemHandler :: Execute( CGPackage_SwapItem* 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 ) ;

	//得到所要交换的两个索引
	INT index1 = pPacket->GetPackageIndex1();
	INT index2 = pPacket->GetPackageIndex2();

	INT bSucc = -1;
	GCPackage_SwapItem msg;
	//扩展包互换 禁止
	if ((index1>=EXTRA_CONTAINER_OFFSET)&&(index2>=EXTRA_CONTAINER_OFFSET))
	{
		msg.SetResult(SWITCHITEM_EXTRBAG_EXCHANGE_FAIL);
		pGamePlayer->SendPacket(&msg);
		g_pLog->FastSaveLog( LOG_FILE_1, "CGPackage_SwapItem: index1=%d, index2=%d extrabag fail", 
			index1, index2) ;
		return PACKET_EXE_CONTINUE;
	}
	if (index1>=EXTRA_CONTAINER_OFFSET)
	{
		ItemContainer* pExtraBagContainer = HumanItemLogic::GetBagByExtraContainPos(pHuman, index1);
		//位置无效
		if (pExtraBagContainer == NULL)
		{
			g_pLog->FastSaveLog( LOG_FILE_1, "CGPackage_SwapItem: index1=%d, is invalid", index1) ;
			return PACKET_EXE_ERROR;
		}
		//扩展包不存在
		if (!pExtraBagContainer->IsValid())
		{
			msg.SetResult(SWITCHITEM_SOURCEEXTRBAG_NOALIVE);
			pGamePlayer->SendPacket(&msg);
			g_pLog->FastSaveLog( LOG_FILE_1, "CGPackage_SwapItem: index1=%d, extrabag is not alive", index1) ;
			return PACKET_EXE_CONTINUE;
		}
		//非空扩展包不许移动
		if (!pExtraBagContainer->IsEmpty())
		{
			msg.SetResult(SWITCHITEM_SOURCEEXTRBAG_ITEM_FAIL);
			pGamePlayer->SendPacket(&msg);
			g_pLog->FastSaveLog( LOG_FILE_1, "CGPackage_SwapItem: index1=%d, extrabag has items", index1) ;
			return PACKET_EXE_CONTINUE;
		}
		ItemContainer* pExtraContainer = pHuman->GetExtraContain();

		INT index_container1 = pExtraContainer->BagIndex2ConIndex(index1);
		
		ItemContainer* pBagContainer = HumanItemLogic::GetBagContainer(pHuman, index2);
		INT index_container2 = pBagContainer->BagIndex2ConIndex(index2);
		
		if (pExtraBagContainer->IsInContainer(index2))
		{
			return PACKET_EXE_CONTINUE; 
		}
		Item* pItem2 = pBagContainer->GetItem(index_container2);

		//不能将扩展包移动到有物品位置
		if (!pItem2->IsEmpty())
		{
			msg.SetResult(SWITCHITEM_SOURCEEXTRBAG_ITEM_FAIL);
			pGamePlayer->SendPacket(&msg);
			g_pLog->FastSaveLog( LOG_FILE_1, "CGPackage_SwapItem: index1=%d, extrabag has items", index1) ;
			return PACKET_EXE_CONTINUE;
		}
		
		bSucc = g_ItemOperator.MoveItem(pExtraContainer, index_container1, pBagContainer, index_container2);
		if (bSucc>=0)
		{
			pHuman->ReInitExtraBag();
			msg.SetResult(SWITCHITEM_SUCCESS);
			msg.SetPackageIndex1(index1);
			msg.SetPackageIndex2(index2);

			pGamePlayer->SendPacket(&msg);
			g_pLog->FastSaveLog( LOG_FILE_1, "CGPackage_SwapItem: index1=%d, index2=%d Success", 
				index1, index2 ) ;
			return PACKET_EXE_CONTINUE;
		}
	}
	if ((index2>=EXTRA_CONTAINER_OFFSET)&&(index2<BASE_BAG_POS))
	{
		ItemContainer* pBagContainer = HumanItemLogic::GetBagContainer(pHuman, index1);
		Item* pItem1 = pBagContainer->GetItem(pBagContainer->BagIndex2ConIndex(index1));
		if (pItem1->IsEmpty())
//.........这里部分代码省略.........
开发者ID:,项目名称:,代码行数:101,代码来源:


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