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; }
uint CGShopSpecialRepairHandler::Execute( CGShopSpecialRepair* 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 ; } BYTE Opt = pPacket->GetOpt(); BYTE BagIndex = pPacket->GetBagIndex(); //包中的位置 Item* pCurItem = NULL; INT MoneySpent = 0; INT MoneyLast = 0; INT MoneyHave = pHuman->GetMoney(); INT RepairedIndex = 0; GCShopSpecialRepairResult MsgResult; GCShopSpecialRepairResult::REPAIRED_ITEM ItemList; if(Opt == CGShopSpecialRepair::FromBag) { //一定是修理单个 ItemContainer* pItemContainer = HumanItemLogic::GetBagContainer(pHuman, BagIndex); if (pItemContainer == NULL) { g_pLog->FastSaveLog( LOG_FILE_1, "CGShopSpecialRepairHandler BagIndex is invalid, BagIndex = %d", BagIndex) ; return PACKET_EXE_ERROR; } if (!pItemContainer->IsCanUse()) { g_pLog->FastSaveLog( LOG_FILE_1, "CGShopSpecialRepairHandler extrabag is invalid time BagIndex = %d", BagIndex) ; return PACKET_EXE_CONTINUE ; } pCurItem = pItemContainer->GetItem(pItemContainer->BagIndex2ConIndex(BagIndex)); if(!pCurItem->IsEmpty()) { if(pCurItem->GetItemClass() != ICLASS_EQUIP) { g_pLog->FastSaveLog( LOG_FILE_1, "CGShopSpecialRepairHandler pCurItem->GetItemClass() != ICLASS_EQUIP ") ; return PACKET_EXE_ERROR ; } EQUIP_SPECIALREPAIR_TB* pSpecialRepair = g_ItemTable.GetSpecialRepairTB(); Assert (pSpecialRepair != NULL); if (!pSpecialRepair) { g_pLog->FastSaveLog( LOG_FILE_1, "[CGShopSpecialRepairHandler::Execute] GetSpecialRepairTB index is error"); return PACKET_EXE_ERROR; } //获得Human背包中对应ItemIndex的物品位置 UINT nItemCount = HumanItemLogic::CalcBagItemCount(pHuman, pSpecialRepair->m_ItemID); if((nItemCount == 0)||(nItemCount < pPacket->GetItemNum())) { MsgResult.SetResult(EQUIPSPECIALREPAIR_ITEM); pGamePlayer->SendPacket(&MsgResult); g_pLog->FastSaveLog( LOG_FILE_1, "CGShopSpecialRepairHandler nItemIndex = %d", pSpecialRepair->m_ItemID) ; return PACKET_EXE_CONTINUE ; } FLOAT fCur = (FLOAT)pCurItem->GetDurPoints(); FLOAT fMax = (FLOAT)pCurItem->GetMaxDurPoint(); FLOAT fCurMax = (FLOAT)pCurItem->GetCurMaxDurPoint(); if(fMax != fCurMax) { UINT nUsedItem = 0; for (UINT i=0; i<pPacket->GetItemNum(); ++i) { ++nUsedItem; fCurMax = pSpecialRepair->m_RecoverPoint + fCurMax; if (fCurMax>=fMax) { fCurMax = fMax; break; } } HumanItemLogic::SetBagItemCurMaxDur(pHuman,(UINT)BagIndex, (INT)fCurMax); HumanItemLogic::SetBagItemDur(pHuman,(UINT)BagIndex, (INT)fCurMax); ITEM_LOG_PARAM LogParam; LogParam.OpType = ITEM_SPECIALREPAIR_CONSUME; LogParam.CharGUID = pHuman->GetGUID(); LogParam.XPos = pHuman->getWorldPos()->m_fX; LogParam.ZPos = pHuman->getWorldPos()->m_fZ; LogParam.SceneID = pHuman->getScene()->SceneID(); BOOL bOK = HumanItemLogic::EraseBagItem(&LogParam,pHuman, pSpecialRepair->m_ItemID, nUsedItem); Assert(bOK); SaveItemLog(&LogParam); ItemList.IsIn = GCShopSpecialRepairResult::BAG; ItemList.nCurDur = pCurItem->GetDurPoints(); ItemList.nCurMaxDur = pCurItem->GetCurMaxDurPoint(); ItemList.BagIndex = BagIndex; MsgResult.SetResult(EQUIPSPECIALREPAIR_SUCCESS); MsgResult.SetReList(&ItemList); pHuman->GetPlayer()->SendPacket(&MsgResult); return PACKET_EXE_CONTINUE ; } else { MsgResult.SetResult(EQUIPSPECIALREPAIR_NOREAPIR); pGamePlayer->SendPacket(&MsgResult); g_pLog->FastSaveLog( LOG_FILE_1, "CGShopSpecialRepairHandler needn't repair") ; return PACKET_EXE_CONTINUE ; } } else { g_pLog->FastSaveLog( LOG_FILE_1, "CGShopSpecialRepairHandler BagIndex = %d", BagIndex) ; return PACKET_EXE_CONTINUE ; } } else if(Opt == CGShopSpecialRepair::FromEquip) { pCurItem = HumanItemLogic::GetEquip(pHuman,(HUMAN_EQUIP)BagIndex); if(!pCurItem->IsEmpty()) {//有东西 if(pCurItem->GetItemClass() != ICLASS_EQUIP) { g_pLog->FastSaveLog( LOG_FILE_1, "CGShopSpecialRepairHandler pCurItem->GetItemClass() != ICLASS_EQUIP ") ; return PACKET_EXE_ERROR ; } EQUIP_SPECIALREPAIR_TB* pSpecialRepair = g_ItemTable.GetSpecialRepairTB(); Assert (pSpecialRepair != NULL); if (!pSpecialRepair) { g_pLog->FastSaveLog( LOG_FILE_1, "[CGShopSpecialRepairHandler::Execute] GetSpecialRepairTB index is error"); return PACKET_EXE_ERROR; } //获得Human背包中对应ItemIndex的物品位置 UINT nItemCount = HumanItemLogic::CalcBagItemCount(pHuman, pSpecialRepair->m_ItemID); if((nItemCount == 0)||(nItemCount < pPacket->GetItemNum())) { MsgResult.SetResult(EQUIPSPECIALREPAIR_ITEM); pGamePlayer->SendPacket(&MsgResult); g_pLog->FastSaveLog( LOG_FILE_1, "CGShopSpecialRepairHandler nItemIndex = %d", pSpecialRepair->m_ItemID) ; return PACKET_EXE_CONTINUE ; } FLOAT fCur = (FLOAT)pCurItem->GetDurPoints(); FLOAT fMax = (FLOAT)pCurItem->GetMaxDurPoint(); FLOAT fCurMax = (FLOAT)pCurItem->GetCurMaxDurPoint(); if(fMax != fCurMax) { UINT nUsedItem = 0; for (UINT i=0; i<pPacket->GetItemNum(); ++i) { ++nUsedItem; fCurMax = pSpecialRepair->m_RecoverPoint + fCurMax; if (fCurMax>=fMax) { fCurMax = fMax; break; } } HumanItemLogic::SetCurEquipMaxDur(pHuman,(HUMAN_EQUIP)BagIndex, (INT)fCurMax); HumanItemLogic::SetEquipDur(pHuman,(HUMAN_EQUIP)BagIndex, (INT)fCurMax); ITEM_LOG_PARAM LogParam; LogParam.OpType = ITEM_SPECIALREPAIR_CONSUME; LogParam.CharGUID = pHuman->GetGUID(); LogParam.XPos = pHuman->getWorldPos()->m_fX; LogParam.ZPos = pHuman->getWorldPos()->m_fZ; LogParam.SceneID = pHuman->getScene()->SceneID(); BOOL bOK = HumanItemLogic::EraseBagItem(&LogParam,pHuman, pSpecialRepair->m_ItemID,nUsedItem); Assert(bOK); SaveItemLog(&LogParam); ItemList.IsIn = GCShopSpecialRepairResult::EQUIP; ItemList.nCurDur = pCurItem->GetDurPoints(); ItemList.nCurMaxDur = pCurItem->GetCurMaxDurPoint(); ItemList.BagIndex = BagIndex; MsgResult.SetResult(EQUIPSPECIALREPAIR_SUCCESS); MsgResult.SetReList(&ItemList); pHuman->GetPlayer()->SendPacket(&MsgResult); if ((INT)fCur == 0) { pHuman->ItemEffectFlush(); } return PACKET_EXE_CONTINUE ; } else { MsgResult.SetResult(EQUIPSPECIALREPAIR_NOREAPIR); pGamePlayer->SendPacket(&MsgResult); g_pLog->FastSaveLog( LOG_FILE_1, "CGShopSpecialRepairHandler needn't repair") ; return PACKET_EXE_CONTINUE ; } } } g_pLog->FastSaveLog( LOG_FILE_1, "ERROR:CGShopSpecialRepairHandler error Opt=", Opt); return PACKET_EXE_ERROR; __LEAVE_FUNCTION return PACKET_EXE_ERROR ; }
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 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()) { return PACKET_EXE_CONTINUE; } ItemContainer* pExtraContainer = pHuman->GetExtraContain(); //将物品放入扩展包 ItemContainer* pExtraBagContainer = HumanItemLogic::GetBagByExtraContainPos(pHuman, index2); if (pExtraBagContainer == NULL) { g_pLog->FastSaveLog( LOG_FILE_1, "CGPackage_SwapItem: index2=%d, is invalid", index2) ; return PACKET_EXE_ERROR; } INT index_container1 = pBagContainer->BagIndex2ConIndex(index1); INT index_container2 = pExtraContainer->BagIndex2ConIndex(index2); //扩展包不存在 if (!pExtraBagContainer->IsValid()) { if (pItem1->GetItemClass() == ICLASS_EXTRABAG) { INT ret = g_ItemOperator.MoveItem(pBagContainer, index_container1, pExtraContainer, index_container2); if (ret>=0) { msg.SetResult(SWITCHITEM_SUCCESS); msg.SetPackageIndex1(index1); 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) { msg.SetResult(SWITCHITEM_SUCCESS); msg.SetPackageIndex1(index1); msg.SetPackageIndex2(pBagContainer->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; } //调用物品底层交换物品 Item* pItem1 = HumanItemLogic::GetBagItem(pHuman, index1); Item* pItem2 = HumanItemLogic::GetBagItem(pHuman, index2); if ((pItem1==NULL)||(pItem2==NULL)) { g_pLog->FastSaveLog( LOG_FILE_1, "CGPackage_SwapItem: index1=%d, index2=%d pos fail", index1, index2) ; return PACKET_EXE_ERROR; } //判断是否在同一个容器内 ItemContainer* pBagContainer = HumanItemLogic::GetBagContainer(pHuman, index1); if(pBagContainer != HumanItemLogic::GetBagContainer(pHuman, index2)) return PACKET_EXE_CONTINUE; if (!pBagContainer->IsCanUse()) { msg.SetResult(SWITCHITEM_SOURCEEXTRBAG_ITEM_FAIL); pGamePlayer->SendPacket(&msg); return PACKET_EXE_CONTINUE; } //转换Index基数 INT index_container1 = pBagContainer->BagIndex2ConIndex(index1); INT index_container2 = pBagContainer->BagIndex2ConIndex(index2); //两个物品格都是空格 if(pItem1->IsEmpty() && pItem2->IsEmpty()) { return PACKET_EXE_CONTINUE; } // Item1 -> Item2(EMPTY) else if(!(pItem1->IsEmpty()) && pItem2->IsEmpty()) { bSucc = g_ItemOperator.MoveItem(pBagContainer, index_container1, pBagContainer, index_container2) >= 0; } // Item1(EMPTY) <- Item2 else if(pItem1->IsEmpty() && !(pItem2->IsEmpty())) { bSucc = g_ItemOperator.MoveItem(pBagContainer, index_container2, pBagContainer, index_container1) >= 0; } // Item1 <-> Item2 else { ITEM_LOG_PARAM ItemLogParam; //合并相同的物品 //1、判断两个物品是不是可以叠加的 if(pItem1->GetItemTableIndex() == pItem2->GetItemTableIndex() && pItem1->IsCanLay()) { int Count = pItem1->GetLayedNum(); //2、转移物品 if(g_ItemOperator.MoveItem(pBagContainer, index_container1, index_container2) >= 0) { //合并成功,将结果通知客户端,不能只发送Index,需要包括内容; _ITEM temp1; pItem1->SaveValueTo(&temp1); GCItemInfo msg1; msg1.setID(index1); msg1.setIsNull(pItem1->IsEmpty()); msg1.setItem(&temp1); pGamePlayer->SendPacket(&msg1); _ITEM temp2; pItem2->SaveValueTo(&temp2); GCItemInfo msg2; msg2.setID(index2); msg2.setIsNull(pItem2->IsEmpty()); msg2.setItem(&temp2); pGamePlayer->SendPacket(&msg2); ITEM_LOG_PARAM ItemLogParam; ItemLogParam.OpType = ITEM_TILED_BAG_DEST; ItemLogParam.CharGUID = pHuman->GetGUID(); ItemLogParam.SceneID = pHuman->getScene()->SceneID(); ItemLogParam.XPos = pHuman->getWorldPos()->m_fX; ItemLogParam.ZPos = pHuman->getWorldPos()->m_fZ; ItemLogParam.ContainerPos = index2; ItemLogParam.Count = Count; ItemLogParam.ItemGuid = pItem2->GetGUID(); SaveItemLog(&ItemLogParam); ItemLogParam.OpType = ITEM_TILED_BAG_DEST; ItemLogParam.CharGUID = pHuman->GetGUID(); ItemLogParam.SceneID = pHuman->getScene()->SceneID(); ItemLogParam.XPos = pHuman->getWorldPos()->m_fX; ItemLogParam.ZPos = pHuman->getWorldPos()->m_fZ; ItemLogParam.ContainerPos = index1; ItemLogParam.Count = Count; ItemLogParam.ItemGuid = pItem1->GetGUID(); SaveItemLog(&ItemLogParam); return PACKET_EXE_CONTINUE ; } } // 交换两物品 bSucc = g_ItemOperator.ExchangeItem(pBagContainer, index_container1, pBagContainer, index_container2) == ITEMOE_SUCCESS; } 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 Succ=%s", index1, index2, bSucc?"TRUE":"FALSE" ) ; return PACKET_EXE_CONTINUE ; __LEAVE_FUNCTION return PACKET_EXE_ERROR ; }