Exemple #1
0
uint WGDetailOtherOnlineEquipList_HumanHandler::Execute( WGDetailOtherOnlineEquipList_Human* pPacket, Player* pPlayer )
{
__ENTER_FUNCTION

	PlayerID_t PlayerID = pPacket->GetPlayerID(); //发起查看者的ID
	GamePlayer* pGamePlayer = g_pPlayerPool->GetPlayer(PlayerID);
	if( pGamePlayer==NULL )
	{
		Assert(FALSE);
		return PACKET_EXE_CONTINUE;
	}

	GCDetailEquipList Msg;
	Msg.setObjID(INVALID_ID);	//因为该玩家在Client或Client所在的当前Server根本就不存在
	Msg.SetAskMode(ASK_EQUIP_ALL);

	UINT dwEquipMask = pPacket->GetPartFlags();
	for(INT i=0; i<HEQUIP_NUMBER; i++){
		if(dwEquipMask&(1<<i)){
			Msg.SetEquipData((HUMAN_EQUIP)i, pPacket->GetEquipData((HUMAN_EQUIP)i));
		}
	}			
	
	pGamePlayer->SendPacket(&Msg);

	g_pLog->FastSaveLog( LOG_FILE_1, "WGDetailOtherOnlineEquipList_HumanHandler: ok  obj=%d,scene=%d",
		pGamePlayer->GetHuman()->GetID(), pGamePlayer->GetHuman()->getScene()->SceneID());

	return PACKET_EXE_CONTINUE ;

__LEAVE_FUNCTION

	return PACKET_EXE_ERROR ;
}
Exemple #2
0
uint CGEquipSuitExchangeHandler::Execute(CGEquipSuitExchange* 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 ) ;

	//交易状态不可操作
	if(pHuman->m_ExchangBox.m_Status > 0)
	{//丢弃
		g_pLog->FastSaveLog( LOG_FILE_1, "ERROR: ObjID=%d, ExchangBox::m_Status>0" ,pHuman->GetID()) ;
		return PACKET_EXE_CONTINUE ;
	}
	//摆摊状态不可操作
	if(pHuman->m_StallBox.GetStallStatus() == ServerStallBox::STALL_OPEN)
	{//丢弃
		g_pLog->FastSaveLog( LOG_FILE_1, "ERROR: ObjID=%d, ServerStallBox::STALL_OPEN" ,pHuman->GetID()) ;
		return PACKET_EXE_CONTINUE ;
	}

	//切场景时丢弃换装消息
	if(pGamePlayer->GetPlayerStatus()!=PS_SERVER_NORMAL ||
		!pHuman->IsActiveObj() )
	{
		g_pLog->FastSaveLog( LOG_FILE_1, "CGEquipSuitExchangeHandler: change scene") ;
		return PACKET_EXE_CONTINUE;
	}
	//摆摊不可操作
	if(pHuman->m_StallBox.GetStallStatus() == ServerStallBox::STALL_OPEN)
	{//丢弃
		g_pLog->FastSaveLog( LOG_FILE_1, "ERROR: ObjID=%d, ServerStallBox::STALL_OPEN" ,pHuman->GetID()) ;
		return PACKET_EXE_CONTINUE ;
	}

	UINT  nSuitNum = pPacket->getEquipSuitNum();

	if( nSuitNum > MAX_EQUIP_SUIT_NUM )
	{
		return PACKET_EXE_ERROR ;
	}

	ItemContainer* pEquipContainer = pHuman->GetEquipContain();
	
	Assert(pEquipContainer);
	_SUIT_SETTING suitSetting = pHuman->GetEquipSuitSetting(nSuitNum);

	GCEquipSuitExchangeResult Msg;
	GCDetailEquipList	SelfMsg;
	GCCharEquipment OtherMsg;
	SelfMsg.setObjID( pHuman->GetID() );
	BOOL bChange = FALSE;
	UINT RetPart = 0;

	//遍历所有套装
	for(INT i=0; i<HEQUIP_NUMBER; ++i)
	{
		//存在套装数据
		if(!suitSetting.m_EquipData[i].isNull())
		{
			//检查装备栏
			Item* pEquip = pEquipContainer->GetItem(i);
			Assert(pEquip);

			//装备有变化,装备栏数据与保存的对应位置套装信息不一致,需要到背包里找
			if(!(pEquip->GetGUID() == suitSetting.m_EquipData[i]))
			{
				INT nPos = INVALID_INDEX;
				ItemContainer* pBagContainer = HumanItemLogic::GetBagItemContain(pHuman, &suitSetting.m_EquipData[i], nPos);
				//背包里也找不到,需记录下来(卖掉了?丢掉了?。。)
				if(nPos == INVALID_INDEX)
				{
					EXCHANGE_EQUIP_INFO ExchangeInfo;
					ExchangeInfo.m_BagIndex = INVALID_ITEM_POS;
					ExchangeInfo.m_EquipPoint	= INVALID_ITEM_POS;
					Msg.setEquipInfo(ExchangeInfo, i);
					continue;
				}
				
				//找到了
				Item*	pExchangeItem = HumanItemLogic::GetBagItem(pHuman, nPos);
				
				Assert(pExchangeItem->GetItemClass() == ICLASS_EQUIP);
				if(pExchangeItem->GetEquipPoint() != i)
				{
					if(pExchangeItem->GetEquipPoint() == HEQUIP_RING1)
					{
						Assert(i == HEQUIP_RING2);
					}
					else if(pExchangeItem->GetEquipPoint() == HEQUIP_ADORN1)
					{
						Assert(i == HEQUIP_ADORN2);
					}
					else
						Assert(0);
				}
				//玩家可能等级变了
				if(pExchangeItem->GetRequireLevel() > pHuman->GetLevel() )
				{
					EXCHANGE_EQUIP_INFO ExchangeInfo;
					ExchangeInfo.m_BagIndex = INVALID_ITEM_POS;
					ExchangeInfo.m_EquipPoint	= i;
					Msg.setEquipInfo(ExchangeInfo, i);
					g_pLog->FastSaveLog( LOG_FILE_1, "CGEquipSuitExchangeHandler: Equiplevel , pEquip->GetRequireLevel()=%d", pEquip->GetRequireLevel() ) ;
					continue;
				}
				
				//可能换职业了
				if(!pExchangeItem->IsWuMenPai())
				{
					if(!pExchangeItem->InReqJob(pHuman->GetMenPai()))
					{
						EXCHANGE_EQUIP_INFO ExchangeInfo;
						ExchangeInfo.m_BagIndex = INVALID_ITEM_POS;
						ExchangeInfo.m_EquipPoint	= i;
						Msg.setEquipInfo(ExchangeInfo, i);
						g_pLog->FastSaveLog( LOG_FILE_1, "CGEquipSuitExchangeHandler: ReqJob") ;
						continue;
					}
				}
				if (pEquip->IsEmpty())
				{
					g_ItemOperator.MoveItem( pBagContainer,
						pBagContainer->BagIndex2ConIndex(nPos),
						pEquipContainer,
						i ) ;
				}
				
				else
				{
					if (pBagContainer->IsCanUse())
					{
						//与装备的物品进行交换
						g_ItemOperator.ExchangeItem(pBagContainer,
							pBagContainer->BagIndex2ConIndex(nPos),
							pEquipContainer,
							i);
					}
					else //背包已经过期
					{
						EXCHANGE_EQUIP_INFO ExchangeInfo;
						ExchangeInfo.m_BagIndex = INVALID_ITEM_POS;
						ExchangeInfo.m_EquipPoint	= INVALID_ITEM_POS;
						Msg.setEquipInfo(ExchangeInfo, i);
						continue;
					}
				}
				EXCHANGE_EQUIP_INFO ExchangeInfo;
				ExchangeInfo.m_BagIndex = nPos;
				ExchangeInfo.m_EquipPoint	= i;
				Msg.setEquipInfo(ExchangeInfo, i);

				//交换到人身上了,重新获取一下
				Item* pEquipItem = HumanItemLogic::GetEquip(pHuman, (HUMAN_EQUIP)i);
				if(!pEquipItem)
				{
					Assert(FALSE);
					return PACKET_EXE_CONTINUE;
				}
				Assert(!pEquipItem->IsEmpty()); 

				pEquipItem->SaveValueTo(SelfMsg.GetEquipData((HUMAN_EQUIP)i));
				RetPart|=(1<<((UINT)i));
				SelfMsg.SetAskPart(RetPart);
				RetPart = 0;
				//如果可见
				if(pHuman->IsVisualPart((HUMAN_EQUIP)i))
				{	
					OtherMsg.setObjID(pHuman->GetID());
					OtherMsg.setID((HUMAN_EQUIP)i, pEquipItem->GetItemTableIndex());
				}

				//换装了
				bChange = TRUE;
			}

			//装备正穿着呢,不需要通知
			continue;
		}
		else
		{
			//根本没有呀
			EXCHANGE_EQUIP_INFO ExchangeInfo;
			ExchangeInfo.m_BagIndex = INVALID_ITEM_POS;
			ExchangeInfo.m_EquipPoint	= i;
			Msg.setEquipInfo(ExchangeInfo, i);
		}
	}

	
	if(bChange)
	{
		Msg.setResult(EQUIPSUIT_SUCCESS);
		pGamePlayer->SendPacket(&Msg);
		pGamePlayer->SendPacket( &SelfMsg ) ;
		pScene->BroadCast(&OtherMsg,pHuman,TRUE);
		pHuman->SetEquipVer(pHuman->GetEquipVer()+1);
		//刷新装备对人物的属性影响

		pHuman->ItemEffectFlush();
	}
	else
	{
		Msg.setResult(EQUIPSUIT_SUCCESS);
		pGamePlayer->SendPacket(&Msg);
	}

	g_pLog->FastSaveLog( LOG_FILE_1, "CGEquipSuitExchangeHandler: nSuitNum=%d", nSuitNum ) ;

	return PACKET_EXE_CONTINUE ;

	__LEAVE_FUNCTION

		return PACKET_EXE_ERROR ;
}
uint CGEquipLevelupHandler::Execute(CGEquipLevelup* 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 );

	//交易状态不可操作
	if(pHuman->m_ExchangBox.m_Status > 0)
	{//丢弃
		g_pLog->FastSaveLog( LOG_FILE_1, "ERROR: ObjID=%d, ExchangBox::m_Status>0" ,pHuman->GetID()) ;
		return PACKET_EXE_CONTINUE ;
	}
	//摆摊状态不可操作
	if(pHuman->m_StallBox.GetStallStatus() == ServerStallBox::STALL_OPEN)
	{//丢弃
		g_pLog->FastSaveLog( LOG_FILE_1, "ERROR: ObjID=%d, ServerStallBox::STALL_OPEN" ,pHuman->GetID()) ;
		return PACKET_EXE_CONTINUE ;
	}

	Item*		pEquipItem		= NULL;
	UINT		EquipPoint		= INVALID_ITEM_POS;
	UINT		BagIndex		= INVALID_ITEM_POS;  
	EQUIPLEVEUP_RESULT nResult	= EQUIPLEVEUP_FAIL;
	GCEquipLevelupResult Msg;
	switch(pPacket->GetEquipPosType())
	{
	case ENUM_EQUIP_POINT:
		{
			EquipPoint = pPacket->GetPos();
			if(EquipPoint>HEQUIP_ADORN2)
			{
				g_pLog->FastSaveLog( LOG_FILE_1, "CGEquipLevelupHandler: EquipPoint error, EquipPoint=%d", EquipPoint) ;
				return PACKET_EXE_ERROR;
			}

			ItemContainer* pEquipContainer = pHuman->GetEquipContain();
			if(NULL==pEquipContainer)
			{
				AssertEx(FALSE,"[CGUseGem]: NULL EquipContainer pointer found!");
			}
			pEquipItem = pEquipContainer->GetItem((UINT)EquipPoint);
			Assert(pEquipItem);
			
			if(pEquipItem->IsEmpty())
			{
				nResult = EQUIPLEVEUP_EQUIP_FAIL;
				Msg.SetResult(nResult);
				pGamePlayer->SendPacket( &Msg ) ;
				g_pLog->FastSaveLog( LOG_FILE_1, "CGEquipLevelupHandler pEquipItem is Null at  EquipPoint= %d", EquipPoint) ;
				return PACKET_EXE_CONTINUE;
			}
			
			Assert (pEquipItem->GetItemClass() == ICLASS_EQUIP);

			if(!(pPacket->getItemID() == pEquipItem->GetGUID()))
			{
				nResult = EQUIPLEVEUP_EQUIP_FAIL;
				Msg.SetResult(nResult);
				pGamePlayer->SendPacket( &Msg ) ;
				g_pLog->FastSaveLog( LOG_FILE_1, "CGEquipLevelupHandler GUID is different ") ;
				return PACKET_EXE_CONTINUE;
			}


		}
		break;
	case ENUM_BAG:
		{
			BagIndex = pPacket->GetPos();
			ItemContainer* pItemContainer = HumanItemLogic::GetBagContainer(pHuman,BagIndex);
			if( pItemContainer == NULL )
			{
				g_pLog->FastSaveLog( LOG_FILE_1, "CGEquipLevelupHandler: BagIndex error, BagIndex=%d", BagIndex) ;
				return PACKET_EXE_ERROR;
			}
			if (!pItemContainer->IsCanUse())
			{
				nResult = EQUIPLEVEUP_BAG_INVALID;
				Msg.SetResult(nResult);
				pGamePlayer->SendPacket( &Msg ) ;
				g_pLog->FastSaveLog( LOG_FILE_1, "CGEquipLevelupHandler: ItemContainer is invalid, ContainerType=%d, BagIndex=%d", 
					pItemContainer->GetContainerType(), BagIndex) ;
					return PACKET_EXE_ERROR;
			}

			pEquipItem		=	pItemContainer->GetItem(pItemContainer->BagIndex2ConIndex(BagIndex));
			if(pEquipItem->IsEmpty())
			{
				nResult = EQUIPLEVEUP_EQUIP_FAIL;
				Msg.SetResult(nResult);
				pGamePlayer->SendPacket( &Msg ) ;
				g_pLog->FastSaveLog( LOG_FILE_1, "Obj_Human::EquipLevelup pEquipItem is Null at  BagIndex= %d", BagIndex) ;
				return PACKET_EXE_CONTINUE;
			}
			
			if (pEquipItem->GetItemClass() != ICLASS_EQUIP)
			{
				nResult = EQUIPLEVEUP_EQUIP_FAIL;
				Msg.SetResult(nResult);
				pGamePlayer->SendPacket( &Msg ) ;
				g_pLog->FastSaveLog( LOG_FILE_1, "EquipLevelup GetItemClass is not ICLASS_EQUIP ") ;
				return PACKET_EXE_CONTINUE;
			}

			if(!(pPacket->getItemID() == pEquipItem->GetGUID()))
			{
				nResult = EQUIPLEVEUP_EQUIP_FAIL;
				Msg.SetResult(nResult);
				pGamePlayer->SendPacket( &Msg ) ;
				g_pLog->FastSaveLog( LOG_FILE_1, "Obj_Human::EquipLevelup GUID is different ") ;
				return PACKET_EXE_CONTINUE;
			}

			if (pEquipItem->GetItemType() > EQUIP_ADORN)
			{
				nResult = EQUIPLEVEUP_EQUIP_FAIL;
				Msg.SetResult(nResult);
				pGamePlayer->SendPacket( &Msg ) ;
				g_pLog->FastSaveLog( LOG_FILE_1, "Obj_Human::EquipLevelup GUID is different ") ;
				return PACKET_EXE_CONTINUE;
			}
		}
		break;
	default:
		{
			g_pLog->FastSaveLog( LOG_FILE_1, "CGEquipLevelupHandler: EquipFromType error, EquipFromType=%d", pPacket->GetEquipPosType()) ;
			return PACKET_EXE_ERROR;
		}
		break;
	}

	INT nCurLevel = pEquipItem->GetCurLevel();
	if(nCurLevel >=MAX_EQUIP_LEVELUP_NUM)
	{
		g_pLog->FastSaveLog( LOG_FILE_1, "CGEquipLevelupHandler LEVEL full ") ;
		nResult = EQUIPLEVEUP_FULL_FAIL;
		Msg.SetResult(nResult);
		pGamePlayer->SendPacket( &Msg ) ;
		return PACKET_EXE_CONTINUE;
	}


	nResult = (EQUIPLEVEUP_RESULT)pHuman->EquipLevelup(pEquipItem, pPacket->getGemID(), pPacket->GetGemNum());

	if(nResult == EQUIPLEVEUP_FAIL)
	{
		g_pLog->FastSaveLog( LOG_FILE_1, "CGEquipLevelupHandler: pHuman->AddHole Fail") ;
		return PACKET_EXE_ERROR;
	}

	Msg.SetResult(nResult);
	pGamePlayer->SendPacket( &Msg ) ;
	//////////////////////////////////////////////////////////////////////////

	if((nResult == EQUIPLEVEUP_SUCCESS)||(nResult == EQUIPLEVEUP_FAIL_SUCCESS))
	{
		if(pPacket->GetEquipPosType() == ENUM_EQUIP_POINT)
		{
			pHuman->ItemEffectFlush();

			pHuman->SetEquipVer(pHuman->GetEquipVer()+1);
			INT Equip_Point = pPacket->GetPos();
			UINT RetPart = 0;
			GCDetailEquipList	SelfMsg;
			SelfMsg.setObjID( pHuman->GetID() );
			Item* pEquipItem = HumanItemLogic::GetEquip(pHuman, (HUMAN_EQUIP)Equip_Point);
			if(!pEquipItem)
			{
				Assert(FALSE);
			}
			if(pEquipItem->IsEmpty()) 
			{
				Assert(FALSE);
			}
			pEquipItem->SaveValueTo(SelfMsg.GetEquipData((HUMAN_EQUIP)Equip_Point));
			RetPart|=(1<<((UINT)Equip_Point));
			SelfMsg.SetAskPart(RetPart);
			pGamePlayer->SendPacket( &SelfMsg ) ;
		}
		else
		{
			GCItemInfo	EquipMsg;
			EquipMsg.setIsNull(FALSE);
			EquipMsg.setID(BagIndex);
			pEquipItem->SaveValueTo(EquipMsg.getItem());
			pHuman->GetPlayer()->SendPacket(&EquipMsg);
		}
	}

	g_pLog->FastSaveLog( LOG_FILE_1, "CGEquipLevelupHandler: success nResult=%d", nResult ) ;
	return PACKET_EXE_CONTINUE;

	__LEAVE_FUNCTION

		return PACKET_EXE_ERROR;
}
Exemple #4
0
uint CGEquipRemouldHandler::Execute(CGEquipRemould* 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 );

	//交易状态不可操作
	if(pHuman->m_ExchangBox.m_Status > 0)
	{//丢弃
		g_pLog->FastSaveLog( LOG_FILE_1, "ERROR: ObjID=%d, ExchangBox::m_Status>0" ,pHuman->GetID()) ;
		return PACKET_EXE_CONTINUE ;
	}
	//摆摊状态不可操作
	if(pHuman->m_StallBox.GetStallStatus() == ServerStallBox::STALL_OPEN)
	{//丢弃
		g_pLog->FastSaveLog( LOG_FILE_1, "ERROR: ObjID=%d, ServerStallBox::STALL_OPEN" ,pHuman->GetID()) ;
		return PACKET_EXE_CONTINUE ;
	}

	Item*		pEquipItem		= NULL;
	UINT		EquipPoint		= INVALID_ITEM_POS;
	UINT		BagIndex		= INVALID_ITEM_POS;  
	EQUIPREMOULD_RESULT nResult	= EQUIPREMOULD_FAIL;
	GCEquipRemouldResult Msg;
	switch(pPacket->GetEquipPosType())
	{
	case ENUM_EQUIP_POINT:
		{
			EquipPoint = pPacket->GetPos();
			if(EquipPoint>HEQUIP_ADORN2)
			{
				g_pLog->FastSaveLog( LOG_FILE_1, "CGEquipRemouldHandler: EquipPoint error, EquipPoint=%d", EquipPoint) ;
				return PACKET_EXE_ERROR;
			}

			ItemContainer* pEquipContainer = pHuman->GetEquipContain();
			if(NULL==pEquipContainer)
			{
				AssertEx(FALSE,"[CGEquipRemouldHandler]: NULL EquipContainer pointer found!");
			}
			pEquipItem = pEquipContainer->GetItem((UINT)EquipPoint);
			Assert(pEquipItem);

			if(pEquipItem->IsEmpty())
			{
				nResult = EQUIPREMOULD_EQUIP_FAIL;
				Msg.SetResult(nResult);
				pGamePlayer->SendPacket( &Msg ) ;
				g_pLog->FastSaveLog( LOG_FILE_1, "CGEquipRemouldHandler pEquipItem is Null at  EquipPoint= %d", EquipPoint) ;
				return PACKET_EXE_CONTINUE;
			}

			Assert (pEquipItem->GetItemClass() == ICLASS_EQUIP);

			if(!(pPacket->getItemID() == pEquipItem->GetGUID()))
			{
				nResult = EQUIPREMOULD_EQUIP_FAIL;
				Msg.SetResult(nResult);
				pGamePlayer->SendPacket( &Msg ) ;
				g_pLog->FastSaveLog( LOG_FILE_1, "CGEquipRemouldHandler GUID is different ") ;
				return PACKET_EXE_CONTINUE;
			}
		}
		break;
	case ENUM_BAG:
		{
			BagIndex = pPacket->GetPos();
			ItemContainer* pItemContainer = HumanItemLogic::GetBagContainer(pHuman,BagIndex);
			if( pItemContainer == NULL )
			{
				g_pLog->FastSaveLog( LOG_FILE_1, "CGEquipRemouldHandler: BagIndex error, BagIndex=%d", BagIndex) ;
				return PACKET_EXE_ERROR;
			}
			if (!pItemContainer->IsCanUse())
			{
				nResult = EQUIPREMOULD_BAG_INVALID;
				Msg.SetResult(nResult);
				pGamePlayer->SendPacket( &Msg ) ;
				g_pLog->FastSaveLog( LOG_FILE_1, "CGEquipRemouldHandler: ItemContainer is invalid, ContainerType=%d, BagIndex=%d", 
					pItemContainer->GetContainerType(), BagIndex) ;
					return PACKET_EXE_ERROR;
			}

			pEquipItem		=	pItemContainer->GetItem(pItemContainer->BagIndex2ConIndex(BagIndex));
			if(pEquipItem->IsEmpty())
			{
				nResult = EQUIPREMOULD_EQUIP_FAIL;
				Msg.SetResult(nResult);
				pGamePlayer->SendPacket( &Msg ) ;
				g_pLog->FastSaveLog( LOG_FILE_1, "CGEquipRemouldHandler pEquipItem is Null at  BagIndex= %d", BagIndex) ;
				return PACKET_EXE_CONTINUE;
			}

			if (pEquipItem->GetItemClass() != ICLASS_EQUIP)
			{
				nResult = EQUIPREMOULD_EQUIP_FAIL;
				Msg.SetResult(nResult);
				pGamePlayer->SendPacket( &Msg ) ;
				g_pLog->FastSaveLog( LOG_FILE_1, "CGEquipRemouldHandler GetItemClass is not ICLASS_EQUIP ") ;
				return PACKET_EXE_CONTINUE;
			}

			if(!(pPacket->getItemID() == pEquipItem->GetGUID()))
			{
				nResult = EQUIPREMOULD_EQUIP_FAIL;
				Msg.SetResult(nResult);
				pGamePlayer->SendPacket( &Msg ) ;
				g_pLog->FastSaveLog( LOG_FILE_1, "CGEquipRemouldHandler GUID is different ") ;
				return PACKET_EXE_CONTINUE;
			}

			if (pEquipItem->GetItemType() > EQUIP_ADORN)
			{
				nResult = EQUIPREMOULD_EQUIP_FAIL;
				Msg.SetResult(nResult);
				pGamePlayer->SendPacket( &Msg ) ;
				g_pLog->FastSaveLog( LOG_FILE_1, "CGEquipRemouldHandler GUID is different ") ;
				return PACKET_EXE_CONTINUE;
			}
		}
		break;
	default:
		{
			g_pLog->FastSaveLog( LOG_FILE_1, "CGEquipRemouldHandler: EquipFromType error, EquipFromType=%d", pPacket->GetEquipPosType()) ;
			return PACKET_EXE_ERROR;
		}
		break;
	}

	if (pEquipItem->GetEquipFromType() != ITEM_CREATE)
	{
		nResult = EQUIPREMOULD_TYPE_FAIL;
		Msg.SetResult(nResult);
		pGamePlayer->SendPacket( &Msg ) ;
		g_pLog->FastSaveLog( LOG_FILE_1, "CGEquipRemouldHandler Type error ") ;
		return PACKET_EXE_CONTINUE;
	}

	ITEM_PRODUCT_INFO_TB* pCreateTB = g_ItemTable.GetItemProductInfoTB(pEquipItem->GetItemTableIndex());
	if(pCreateTB == NULL)
	{
		nResult = EQUIPREMOULD_EQUIP_FAIL;
		Msg.SetResult(nResult);
		pGamePlayer->SendPacket(&Msg);
		return PACKET_EXE_CONTINUE;
	}
	if (pCreateTB->m_nRemouldInfoCount != pPacket->GetValidNum())
	{
		return PACKET_EXE_ERROR;
	}
	
	if (pCreateTB->m_RemouldMoney > pHuman->GetMoney())
	{
		nResult = EQUIPREMOULD_MONEY_FAIL;
		Msg.SetResult(nResult);
		pGamePlayer->SendPacket(&Msg);
		return PACKET_EXE_CONTINUE;
	}
	struct MATERIAL_REQ 
	{
		UINT m_nIndex;
		UINT m_nCount;
	};
	MATERIAL_REQ MaterialIndex[MAX_REMOULD_MATERIAL_NUM];
	UINT nEquipScore = 0;
	for (UINT i=0; i<pCreateTB->m_nRemouldInfoCount; ++i)
	{
		REMOULDITEM_INFO RemouldInfo = pCreateTB->m_RemouldInfo[i];

		EQUIPREMOULD_MATERIAL_INFO MaterialInfo = pPacket->GetMaterialReq(i);
		if(MaterialInfo.m_nMaterialType != RemouldInfo.m_MaterialType)
		{
			nResult = EQUIPREMOULD_MATERIAL_FAIL;
			Msg.SetResult(nResult);
			pGamePlayer->SendPacket( &Msg ) ;
			g_pLog->FastSaveLog( LOG_FILE_1, "CGEquipRemouldHandler MaterialType error") ;
			return PACKET_EXE_CONTINUE;
		}

		if(MaterialInfo.m_nMaterialLevel < RemouldInfo.m_NeedLevel)
		{
			nResult = EQUIPREMOULD_MATERIAL_LEVEL;
			Msg.SetResult(nResult);
			pGamePlayer->SendPacket( &Msg ) ;
			g_pLog->FastSaveLog( LOG_FILE_1, "CGEquipRemouldHandler MaterialLevel fail") ;
			return PACKET_EXE_CONTINUE;
		}

		UINT nMaterialIndex = GenMaterialIndex(MaterialInfo.m_nMaterialType, MaterialInfo.m_nMaterialLevel);
		//查询物品表该材料是否存在
		COMMITEM_INFO_TB* pMaterialInfoTB = g_ItemTable.GetCommItemInfoTB(nMaterialIndex);
		if(pMaterialInfoTB == NULL)
		{
			return PACKET_EXE_ERROR;
		}

		INT nCount = HumanItemLogic::CalcBagItemCount(pHuman, nMaterialIndex);
		if (nCount<RemouldInfo.m_MaterialNum)
		{
			nResult = EQUIPREMOULD_MATERIAL_COUNT;
			Msg.SetResult(nResult);
			pGamePlayer->SendPacket( &Msg ) ;
			g_pLog->FastSaveLog( LOG_FILE_1, "CGEquipRemouldHandler Material num fail") ;
			return PACKET_EXE_CONTINUE;
		}

		//获取对应材料分
		MATERIAL_LEVEL_INFO_TB* pMaterialLevelInfo = g_ItemTable.GetMaterialInfoTB(MaterialInfo.m_nMaterialLevel);
		Assert(pMaterialLevelInfo != NULL);
		if (!pMaterialLevelInfo)
		{
			g_pLog->FastSaveLog( LOG_FILE_1, "[CGEquipRemouldHandler::Execute] GetMaterialInfoTB index is error [%d]",MaterialInfo.m_nMaterialLevel);
			return PACKET_EXE_ERROR;
		}
		nEquipScore = nEquipScore + pMaterialLevelInfo->m_MaterialValue;

		MaterialIndex[i].m_nIndex = nMaterialIndex;
		MaterialIndex[i].m_nCount = pCreateTB->m_RemouldInfo[i].m_MaterialNum;
	}

	nResult = (EQUIPREMOULD_RESULT)pHuman->EquipRemould(pEquipItem, nEquipScore);
	if(nResult == EQUIPREMOULD_FAIL)
	{
		g_pLog->FastSaveLog( LOG_FILE_1, "CGEquipRemouldHandler: pHuman->AddHole Fail") ;
		return PACKET_EXE_ERROR;
	}

	if (nResult == EQUIPREMOULD_SUCCESS)
	{
		ITEM_LOG_PARAM LogParam;
		LogParam.OpType     =   ITEM_REMOULD_CONSUME;
		LogParam.CharGUID	=	pHuman->GetGUID();
		LogParam.XPos		=	pHuman->getWorldPos()->m_fX;
		LogParam.ZPos		=	pHuman->getWorldPos()->m_fZ;
		LogParam.SceneID	=	pHuman->getScene()->SceneID();

		for (UINT i=0; i<pCreateTB->m_nRemouldInfoCount; ++i)
		{
			if(HumanItemLogic::EraseBagItem(&LogParam, pHuman,MaterialIndex[i].m_nIndex, MaterialIndex[i].m_nCount))
			{
				SaveItemLog(&LogParam);
			}
		}
		
		pHuman->SetMoney(pHuman->GetMoney() - pCreateTB->m_RemouldMoney);

		MONEY_LOG_PARAM	MoneyLogParam;
		MoneyLogParam.CharGUID	=	pHuman->GetGUID();
		MoneyLogParam.OPType	=	MONEY_REMOULD_REDUCE;	
		MoneyLogParam.Count		=	(INT)pCreateTB->m_RemouldMoney;
		MoneyLogParam.SceneID	=	pHuman->getScene()->SceneID();
		MoneyLogParam.XPos		=	pHuman->getWorldPos()->m_fX;
		MoneyLogParam.ZPos		=	pHuman->getWorldPos()->m_fZ;
		SaveMoneyLog(&MoneyLogParam);
	}

	Msg.SetResult(nResult);
	pGamePlayer->SendPacket( &Msg ) ;
	//////////////////////////////////////////////////////////////////////////

	if((nResult == EQUIPREMOULD_SUCCESS)||(nResult == EQUIPREMOULD_MAX_FAIL))
	{
		if(pPacket->GetEquipPosType() == ENUM_EQUIP_POINT)
		{
			pHuman->ItemEffectFlush();

			pHuman->SetEquipVer(pHuman->GetEquipVer()+1);
			INT Equip_Point = pPacket->GetPos();
			UINT RetPart = 0;
			GCDetailEquipList	SelfMsg;
			SelfMsg.setObjID( pHuman->GetID() );
			Item* pEquipItem = HumanItemLogic::GetEquip(pHuman, (HUMAN_EQUIP)Equip_Point);
			if(!pEquipItem)
			{
				Assert(FALSE);
			}
			if(pEquipItem->IsEmpty()) 
			{
				Assert(FALSE);
			}
			pEquipItem->SaveValueTo(SelfMsg.GetEquipData((HUMAN_EQUIP)Equip_Point));
			RetPart|=(1<<((UINT)Equip_Point));
			SelfMsg.SetAskPart(RetPart);
			pGamePlayer->SendPacket( &SelfMsg ) ;
		}
		else
		{
			GCItemInfo	 ItemMsg;
			ItemMsg.setIsNull(FALSE);
			ItemMsg.setID(BagIndex);
			pEquipItem->SaveValueTo(ItemMsg.getItem());
			pHuman->GetPlayer()->SendPacket(&ItemMsg);

		}
	}

	g_pLog->FastSaveLog( LOG_FILE_1, "CGEquipRemouldHandler: success nResult=%d", nResult ) ;
	return PACKET_EXE_CONTINUE;

	__LEAVE_FUNCTION

		return PACKET_EXE_ERROR;
}
UINT CGUseEquipHandler::Execute(CGUseEquip* 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 ) ;

	//切场景时丢弃换装消息
	if(pGamePlayer->GetPlayerStatus()!=PS_SERVER_NORMAL ||
		!pHuman->IsActiveObj() )
	{
		g_pLog->FastSaveLog( LOG_FILE_1, "CGUseEquipmentHandler: change scene") ;
		return PACKET_EXE_CONTINUE;
	}

	BYTE  BagIndex = pPacket->getBagIndex();

	if( BagIndex == INVALID_BAG_INDEX )
	{
		Assert(FALSE) ; //包发错了
		return PACKET_EXE_CONTINUE ;
	}
		
	Item* pUseItem = HumanItemLogic::GetItem(pHuman,BagIndex);
	
	GCUseEquipResult Msg;

	//////////////////////////////////////////////////////////////////////////
	//装配条件判断
	UCHAR	itemClass = pUseItem->GetItemClass();

	if(itemClass == ICLASS_EQUIP)
	{
		//需求等级判断
		if(pUseItem->GetRequireLevel()>pHuman->GetLevel())
		{
			Msg.setResult(USEEQUIP_IDENT_FAIL);
			pGamePlayer->SendPacket( &Msg ) ;
		}
		//鉴定判断
		else if(pUseItem->GetItemQual() == EQUALITY_BLUE && pUseItem->GetItemIdent() == FALSE)
		{
			Msg.setResult(USEEQUIP_LEVEL_FAIL);
			pGamePlayer->SendPacket( &Msg ) ;
		}
		else
		{
			
			HUMAN_EQUIP		Equip_Point =(HUMAN_EQUIP)pUseItem->GetEquipPoint();
			//const	_ITEM*			pEquip = pHuman->GetEquip(Equip_Point);
			ItemContainer*	pEquipContainer = pHuman->GetEquipContain();
			
			if(!pEquipContainer)
			{
				Assert(pEquipContainer);
				return PACKET_EXE_CONTINUE;
			}

			Item*	pEquipItem = pEquipContainer->GetItem((UINT)Equip_Point);

			if(!pEquipItem)
			{
				Assert(pEquipItem);
				return PACKET_EXE_CONTINUE;

			}
			
			BOOL			bEquipStatus = (!pEquipItem->IsEmpty());

			ItemContainer*	pBagContainer =
				HumanItemLogic::GetContainer(pHuman,BagIndex);

			if(bEquipStatus)
			{
				//装备上物品,替换下来装备点数据
				
				g_ItemOperator.ExchangeItem(pBagContainer,
											pBagContainer->BagIndex2ConIndex(BagIndex),
											pEquipContainer,
											(UINT)Equip_Point);


			}
			else
			{ 
				//pHuman->GetDB()->OverWriteBag2Equip(BagIndex,Equip_Point);
				g_ItemOperator.MoveItem(pBagContainer,
										pBagContainer->BagIndex2ConIndex(BagIndex),
										pEquipContainer,
										(UINT)Equip_Point);

							
			}
			
			Item* pEquip = pEquipContainer->GetItem((UINT)Equip_Point);
			
			if(pEquip&&pEquip->IsCanEquipBind())
			{
				g_ItemOperator.SetItemBind(pEquipContainer,(UINT)Equip_Point);	
			}

			

			Msg.setBagIndex(BagIndex);
			Msg.setEquipPoint(Equip_Point);
			Msg.setEquipID(pEquipItem->GetGUID());
			Msg.setEquipResID(pEquipItem->GetItemTableIndex());
			Msg.setItemResID(pUseItem->GetItemTableIndex());
			Msg.setBagItemId(pUseItem->GetGUID());
			Msg.setResult(USEEQUIP_SUCCESS);
			
			pGamePlayer->SendPacket( &Msg ) ;
			pHuman->SetEquipVer(pHuman->GetEquipVer()+1);
			//刷新装备对人物的属性影响

			pHuman->ItemEffectFlush();

			//如果可见
			if(pHuman->IsVisualPart(Equip_Point))
			{	
				GCCharEquipment OtherMsg;
				OtherMsg.setObjID(pHuman->GetID());
				if(Equip_Point == HEQUIP_WEAPON)
				{
					UINT uGemID = GetEquipmentMaxLevelGemID(pEquip);
					OtherMsg.setID(Equip_Point,pEquip->GetItemTableIndex(), uGemID);
				}
				else
				{
					OtherMsg.setID(Equip_Point,pEquip->GetItemTableIndex(), -1);
				}
				pScene->BroadCast(&OtherMsg,pHuman,TRUE);

			}


			WORD RetPart = 0;
			GCDetailEquipList	SelfMsg;
			SelfMsg.setObjID( pHuman->GetID() );
			pEquipItem = HumanItemLogic::GetEquip(pHuman,Equip_Point);
			if(!pEquipItem)
			{
				Assert(FALSE);
				return PACKET_EXE_CONTINUE;
			}
			if(pEquipItem->IsEmpty()) 
			{
				g_pLog->FastSaveLog( LOG_FILE_1, "CGUseEquipmentHandler: Equip_Point =%d Fail", Equip_Point ) ;
				return PACKET_EXE_CONTINUE;
			}
				
			pEquipItem->SaveValueTo(SelfMsg.GetEquipData(Equip_Point));
			RetPart|=(1<<((INT)Equip_Point));
			SelfMsg.SetAskPart(RetPart);
			pGamePlayer->SendPacket( &SelfMsg ) ;
		}
		
		
		
		
		
	}
	else
	{
		Msg.setResult(USEEQUIP_TYPE_FAIL);
		Msg.setBagIndex(0);
		Msg.setEquipPoint(0);
		pGamePlayer->SendPacket( &Msg ) ;
		
	}
	
	

	
	

	g_pLog->FastSaveLog( LOG_FILE_1, "CGUseEquipmentHandler: BagIndex=%d", BagIndex ) ;

	return PACKET_EXE_CONTINUE ;

	__LEAVE_FUNCTION

		return PACKET_EXE_ERROR ;
}
uint CGEquipExChangePaiTypeHandler::Execute(CGEquipExChangePaiType* 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 );
	//交易状态不可操作
	if(pHuman->m_ExchangBox.m_Status > 0)
	{//丢弃
		g_pLog->FastSaveLog( LOG_FILE_1, "ERROR: ObjID=%d, ExchangBox::m_Status>0" ,pHuman->GetID()) ;
		return PACKET_EXE_CONTINUE ;
	}
	//摆摊状态不可操作
	if(pHuman->m_StallBox.GetStallStatus() == ServerStallBox::STALL_OPEN)
	{//丢弃
		g_pLog->FastSaveLog( LOG_FILE_1, "ERROR: ObjID=%d, ServerStallBox::STALL_OPEN" ,pHuman->GetID()) ;
		return PACKET_EXE_CONTINUE ;
	}

	//摆摊不可操作
	if(pHuman->m_StallBox.GetStallStatus() == ServerStallBox::STALL_OPEN)
	{//丢弃
		g_pLog->FastSaveLog( LOG_FILE_1, "ERROR: ObjID=%d, ServerStallBox::STALL_OPEN" ,pHuman->GetID()) ;
		return PACKET_EXE_CONTINUE ;
	}

	ObjID_t		NpcObjID=	pPacket->GetUniqueID();
	Obj* pNpcObj = pScene->GetObjManager()->GetObj(NpcObjID);
	if (pNpcObj == NULL)
	{
		return PACKET_EXE_ERROR;
	}
	else
	{
		if( pNpcObj->GetObjType() != Obj::OBJ_TYPE_MONSTER )
		{
			return PACKET_EXE_ERROR;
		}
	}

	FLOAT fDist = MySqrt(pNpcObj->getWorldPos(), pHuman->getWorldPos());

	if(fDist>MAX_NPC_DISTANCE)
	{
		g_pLog->FastSaveLog( LOG_FILE_1, "CGEquipExChangePaiTypeHandler Out Of Range ObjName = %s", pHuman->GetName()) ;
		return PACKET_EXE_CONTINUE ; 
	}


	EQUIPEXCHANGEPAITTYPE_RESULT	Result = EQUIPEXCHANGEPAITTYPE_FAIL;
	GCEquipExChangePaiTypeResult  ResultPacket;

	Item*		pEquip1Item		= NULL;
	Item*		pEquip2Item		= NULL;
	INT			Equip1Point		= INVALID_ITEM_POS;
	INT			Equip2Point		= INVALID_ITEM_POS;
	if(pPacket->GetEquip1PosType()>=INVALID_ITEM_POS_TYPE)
	{
		g_pLog->FastSaveLog( LOG_FILE_1, "CGEquipExChangePaiTypeHandler Equip posType error, posType=%d", pPacket->GetEquip1PosType()) ;
		return PACKET_EXE_ERROR;
	}

	if(pPacket->GetEquip1PosType() == ENUM_BAG)
	{
		ItemContainer* pItemContainer1 = HumanItemLogic::GetBagContainer(pHuman,pPacket->GetPos1());
		if( pItemContainer1 == NULL )
		{
			g_pLog->FastSaveLog( LOG_FILE_1, "CGEquipExChangePaiTypeHandler: BagIndex error, BagIndex=%d", pPacket->GetPos1()) ;
			return PACKET_EXE_ERROR;
		}
		if (!pItemContainer1->IsCanUse())
		{
			Result = EQUIPEXCHANGEPAITTYPE_BAG_INVALID;
			ResultPacket.SetResult(Result);
			pGamePlayer->SendPacket(&ResultPacket);;
			g_pLog->FastSaveLog( LOG_FILE_1, "CGEquipExChangePaiTypeHandler: ItemContainer is invalid, ContainerType=%d, BagIndex=%d", 
				pItemContainer1->GetContainerType(), pPacket->GetPos1()) ;
				return PACKET_EXE_ERROR;
		}

		pEquip1Item		=	pItemContainer1->GetItem(pItemContainer1->BagIndex2ConIndex(pPacket->GetPos1()));
		if(pEquip1Item->IsEmpty())
		{
			Result = EQUIPEXCHANGEPAITTYPE_EQUIP_FAIL;
			ResultPacket.SetResult(Result);
			pGamePlayer->SendPacket(&ResultPacket);
			g_pLog->FastSaveLog( LOG_FILE_1, "CGEquipExChangePaiTypeHandler Equip empyty, bagpos=%d", pPacket->GetPos1()) ;
			return PACKET_EXE_CONTINUE;
		}

		if(pEquip1Item->GetItemClass()!=ICLASS_EQUIP)
		{
			Result = EQUIPEXCHANGEPAITTYPE_EQUIP_FAIL;
			ResultPacket.SetResult(Result);
			pGamePlayer->SendPacket(&ResultPacket);
			g_pLog->FastSaveLog( LOG_FILE_1, "CGEquipExChangePaiTypeHandler is not ICLASS_EQUIP") ;
			return PACKET_EXE_CONTINUE;
		}

		if (pEquip1Item->GetItemType() > EQUIP_ADORN)
		{
			Result = EQUIPEXCHANGEPAITTYPE_EQUIP_FAIL;
			ResultPacket.SetResult(Result);
			pGamePlayer->SendPacket(&ResultPacket);
			g_pLog->FastSaveLog( LOG_FILE_1, "CGEquipExChangePaiTypeHandler is not ICLASS_EQUIP") ;
			return PACKET_EXE_CONTINUE;
		}
	}

	if(pPacket->GetEquip1PosType() == ENUM_EQUIP_POINT)
	{
		if(pPacket->GetPos1()>HEQUIP_ADORN2)
		{
			g_pLog->FastSaveLog( LOG_FILE_1, "CGEquipExChangePaiTypeHandler Item pos error") ;
			return PACKET_EXE_ERROR;
		}
		Equip1Point = pPacket->GetPos1();
		ItemContainer* pEquipContainer = pHuman->GetEquipContain();
		if(NULL==pEquipContainer)
		{
			AssertEx(FALSE,"[CGEquipExChangePaiTypeHandler]: NULL EquipContainer pointer found!");
		}
		pEquip1Item = pEquipContainer->GetItem((UINT)Equip1Point);
		Assert(pEquip1Item != NULL);
		if(pEquip1Item->IsEmpty())
		{
			Result = EQUIPEXCHANGEPAITTYPE_EQUIP_FAIL;
			ResultPacket.SetResult(Result);
			pGamePlayer->SendPacket(&ResultPacket);
			g_pLog->FastSaveLog( LOG_FILE_1, "CGEquipExChangePaiTypeHandler Equip empyty, bagpos=%d", pPacket->GetPos1()) ;
			return PACKET_EXE_CONTINUE;
		}

		Assert (pEquip1Item->GetItemClass() == ICLASS_EQUIP);
	}

	if(!(pEquip1Item->GetGUID() == pPacket->getItem1ID()))
	{
		Result = EQUIPEXCHANGEPAITTYPE_EQUIP_FAIL;
		ResultPacket.SetResult(Result);
		pGamePlayer->SendPacket(&ResultPacket);
		g_pLog->FastSaveLog( LOG_FILE_1, "CGEquipExChangePaiTypeHandler guid error") ;
		return PACKET_EXE_CONTINUE;
	}
	
	if(pPacket->GetEquip2PosType()>=INVALID_ITEM_POS_TYPE)
	{
		g_pLog->FastSaveLog( LOG_FILE_1, "CGEquipExChangePaiTypeHandler Equip posType error, posType=%d", pPacket->GetEquip1PosType()) ;
		return PACKET_EXE_ERROR;
	}

	if(pPacket->GetEquip2PosType() == ENUM_BAG)
	{
		ItemContainer* pItemContainer2 = HumanItemLogic::GetBagContainer(pHuman,pPacket->GetPos2());
		if( pItemContainer2 == NULL )
		{
			g_pLog->FastSaveLog( LOG_FILE_1, "CGEquipDecompoundHandler: BagIndex error, BagIndex=%d", pPacket->GetPos2()) ;
			return PACKET_EXE_ERROR;
		}
		if (!pItemContainer2->IsCanUse())
		{
			Result = EQUIPEXCHANGEPAITTYPE_BAG_INVALID;
			ResultPacket.SetResult(Result);
			pGamePlayer->SendPacket(&ResultPacket);;
			g_pLog->FastSaveLog( LOG_FILE_1, "CGEquipDecompoundHandler: ItemContainer is invalid, ContainerType=%d, BagIndex=%d", 
				pItemContainer2->GetContainerType(), pPacket->GetPos2()) ;
				return PACKET_EXE_ERROR;
		}

		pEquip2Item		=	pItemContainer2->GetItem(pItemContainer2->BagIndex2ConIndex(pPacket->GetPos2()));
		if(pEquip2Item->IsEmpty())
		{
			Result = EQUIPEXCHANGEPAITTYPE_EQUIP_FAIL;
			ResultPacket.SetResult(Result);
			pGamePlayer->SendPacket(&ResultPacket);
			g_pLog->FastSaveLog( LOG_FILE_1, "CGEquipExChangePaiTypeHandler Equip empyty, bagpos=%d", pPacket->GetPos2()) ;
			return PACKET_EXE_CONTINUE;
		}

		if(pEquip2Item->GetItemClass()!=ICLASS_EQUIP)
		{
			Result = EQUIPEXCHANGEPAITTYPE_EQUIP_FAIL;
			ResultPacket.SetResult(Result);
			pGamePlayer->SendPacket(&ResultPacket);
			g_pLog->FastSaveLog( LOG_FILE_1, "CGEquipExChangePaiTypeHandler is not ICLASS_EQUIP") ;
			return PACKET_EXE_CONTINUE;
		}

		if (pEquip2Item->GetItemType() > EQUIP_ADORN)
		{
			Result = EQUIPEXCHANGEPAITTYPE_EQUIP_FAIL;
			ResultPacket.SetResult(Result);
			pGamePlayer->SendPacket(&ResultPacket);
			g_pLog->FastSaveLog( LOG_FILE_1, "CGEquipExChangePaiTypeHandler is not ICLASS_EQUIP") ;
			return PACKET_EXE_CONTINUE;
		}
	}

	if(pPacket->GetEquip2PosType() == ENUM_EQUIP_POINT)
	{
		if(pPacket->GetPos2()>HEQUIP_ADORN2)
		{
			g_pLog->FastSaveLog( LOG_FILE_1, "CGEquipExChangePaiTypeHandler Item pos error") ;
			return PACKET_EXE_ERROR;
		}
		Equip2Point = pPacket->GetPos2();
		ItemContainer* pEquipContainer = pHuman->GetEquipContain();
		if(NULL==pEquipContainer)
		{
			AssertEx(FALSE,"[CGEquipExChangePaiTypeHandler]: NULL EquipContainer pointer found!");
		}
		pEquip2Item = pEquipContainer->GetItem((UINT)Equip2Point);
		Assert(pEquip2Item != NULL);
		if(pEquip2Item->IsEmpty())
		{
			Result = EQUIPEXCHANGEPAITTYPE_EQUIP_FAIL;
			ResultPacket.SetResult(Result);
			pGamePlayer->SendPacket(&ResultPacket);
			g_pLog->FastSaveLog( LOG_FILE_1, "CGEquipExChangePaiTypeHandler Equip empyty, bagpos=%d", pPacket->GetPos2()) ;
			return PACKET_EXE_CONTINUE;
		}

		Assert (pEquip2Item->GetItemClass() == ICLASS_EQUIP);
	}

	if(!(pEquip2Item->GetGUID() == pPacket->getItem2ID()))
	{
		Result = EQUIPEXCHANGEPAITTYPE_EQUIP_FAIL;
		ResultPacket.SetResult(Result);
		pGamePlayer->SendPacket(&ResultPacket);
		g_pLog->FastSaveLog( LOG_FILE_1, "CGEquipExChangePaiTypeHandler guid error") ;
		return PACKET_EXE_CONTINUE;
	}
	
	if ((!pEquip1Item->GetItemBind())||(!pEquip2Item->GetItemBind()))
	{
		Result = EQUIPEXCHANGEPAITTYPE_EQUIPBIND_FAIL;
		ResultPacket.SetResult(Result);
		pGamePlayer->SendPacket(&ResultPacket);
		g_pLog->FastSaveLog( LOG_FILE_1, "CGEquipExChangePaiTypeHandler no Bind") ;
		return PACKET_EXE_CONTINUE;
	}

	Result	= (EQUIPEXCHANGEPAITTYPE_RESULT)pHuman->EquipChangePai(pEquip1Item, pEquip2Item, pPacket->getGemBagPos());
	ResultPacket.SetResult(Result);
	pGamePlayer->SendPacket(&ResultPacket);

	//如果装备在身上
	if(((pPacket->GetEquip1PosType() == ENUM_EQUIP_POINT)&&(Equip1Point != INVALID_ITEM_POS))
		||((pPacket->GetEquip2PosType() == ENUM_EQUIP_POINT)&&(Equip2Point != INVALID_ITEM_POS)))
	{
		//设置装备版本
		pHuman->SetEquipVer(pHuman->GetEquipVer()+1);

		//刷新装备对人物的属性影响
		pHuman->ItemEffectFlush();

		//更新装备
		UINT RetPart = 0;
		GCDetailEquipList	SelfMsg;
		SelfMsg.setObjID( pHuman->GetID() );
		if (pPacket->GetEquip1PosType() == ENUM_EQUIP_POINT)
		{
			pEquip1Item = HumanItemLogic::GetEquip(pHuman,(HUMAN_EQUIP)Equip1Point);
			if(!pEquip1Item)
			{
				Assert(FALSE);
				return PACKET_EXE_CONTINUE;
			}
			if(pEquip1Item->IsEmpty()) 
			{
				g_pLog->FastSaveLog( LOG_FILE_1, "CGEquipExChangePaiTypeHandler: Equip_Point =%d Fail", Equip1Point ) ;
				return PACKET_EXE_CONTINUE;
			}

			pEquip1Item->SaveValueTo(SelfMsg.GetEquipData((HUMAN_EQUIP)Equip1Point));
			RetPart|=(1<<((UINT)Equip1Point));
		}
		
		if (pPacket->GetEquip2PosType() == ENUM_EQUIP_POINT)
		{
			pEquip2Item = HumanItemLogic::GetEquip(pHuman,(HUMAN_EQUIP)Equip2Point);
			if(!pEquip2Item)
			{
				Assert(FALSE);
				return PACKET_EXE_CONTINUE;
			}
			if(pEquip2Item->IsEmpty()) 
			{
				g_pLog->FastSaveLog( LOG_FILE_1, "CGEquipExChangePaiTypeHandler: Equip_Point =%d Fail", Equip2Point ) ;
				return PACKET_EXE_CONTINUE;
			}

			pEquip2Item->SaveValueTo(SelfMsg.GetEquipData((HUMAN_EQUIP)Equip2Point));
			RetPart|=(1<<((UINT)Equip2Point));
		}
		SelfMsg.SetAskPart(RetPart);
		pGamePlayer->SendPacket( &SelfMsg ) ;

		if (pPacket->GetEquip1PosType() != ENUM_EQUIP_POINT)
		{
			GCItemInfo  EquipMsg;
			EquipMsg.setIsNull(FALSE);
			EquipMsg.setID(pPacket->GetPos1());
			pEquip1Item->SaveValueTo(EquipMsg.getItem());
			pHuman->GetPlayer()->SendPacket(&EquipMsg);
		}

		if (pPacket->GetEquip2PosType() != ENUM_EQUIP_POINT)
		{
			GCItemInfo	EquipMsg;
			EquipMsg.setIsNull(FALSE);
			EquipMsg.setID(pPacket->GetPos2());
			pEquip2Item->SaveValueTo(EquipMsg.getItem());
			pHuman->GetPlayer()->SendPacket(&EquipMsg);
		}
	}

	else	//仅仅通知背包内物品改变
	{
		GCItemInfo  EquipMsg;
		EquipMsg.setIsNull(FALSE);
		EquipMsg.setID(pPacket->GetPos1());
		pEquip1Item->SaveValueTo(EquipMsg.getItem());
		pHuman->GetPlayer()->SendPacket(&EquipMsg);

		EquipMsg.setIsNull(FALSE);
		EquipMsg.setID(pPacket->GetPos2());
		pEquip2Item->SaveValueTo(EquipMsg.getItem());
		pHuman->GetPlayer()->SendPacket(&EquipMsg);
	}
	return PACKET_EXE_CONTINUE;

	__LEAVE_FUNCTION

		return PACKET_EXE_ERROR;
}