本文整理汇总了C++中ItemContainer::IsCanUse方法的典型用法代码示例。如果您正苦于以下问题:C++ ItemContainer::IsCanUse方法的具体用法?C++ ItemContainer::IsCanUse怎么用?C++ ItemContainer::IsCanUse使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ItemContainer
的用法示例。
在下文中一共展示了ItemContainer::IsCanUse方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Execute
//.........这里部分代码省略.........
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));
示例2: Execute
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));
//.........这里部分代码省略.........
示例3: if
//.........这里部分代码省略.........
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)
{