本文整理汇总了C++中ItemContainer::GetContainerSize方法的典型用法代码示例。如果您正苦于以下问题:C++ ItemContainer::GetContainerSize方法的具体用法?C++ ItemContainer::GetContainerSize怎么用?C++ ItemContainer::GetContainerSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ItemContainer
的用法示例。
在下文中一共展示了ItemContainer::GetContainerSize方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Execute
uint CGAskMyBagListHandler::Execute(CGAskMyBagList* 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 ) ;
ASK_BAG_MODE mode = pPacket->GetAskMode();
GCMyBagList Msg;
switch(mode)
{
case ASK_ALL:
{
_BAG_ITEM ItemIterator;
_ITEM_GUID NullGuid;
uint AllAskCount = 0;
uint nItemCount = 0;
memset(&NullGuid,0,sizeof(_ITEM_GUID));
Msg.SetAskMode(ASK_ALL);
//读取扩展容器
ItemContainer* pExtraContainer = pHuman->GetExtraContain();
Assert(pExtraContainer);
for( INT i=0; i<pExtraContainer->GetContainerSize(); i++ )
{
//临时代码
Item* pItem = HumanItemLogic::GetExtraContainerItem(pHuman,pExtraContainer->ConIndex2BagIndex(i));
Assert(pItem);
if(!(pItem->IsEmpty()))
{
ItemIterator.m_nndex = pExtraContainer->ConIndex2BagIndex(i);
pItem->SaveValueTo(&ItemIterator.m_nItemData);
Msg.SetAskItemData(&ItemIterator,nItemCount);
++nItemCount;
}
}
//读取基本背包
ItemContainer* pBaseContainer = pHuman->GetBaseContain();
Assert(pBaseContainer);
for( INT i=0; i<pBaseContainer->GetContainerSize(); i++ )
{
//临时代码
Item* pItem = pBaseContainer->GetItem(i);
Assert(pItem);
if(!(pItem->IsEmpty()))
{
ItemIterator.m_nndex = pBaseContainer->ConIndex2BagIndex(i);
pItem->SaveValueTo(&ItemIterator.m_nItemData);
Msg.SetAskItemData(&ItemIterator,nItemCount);
++nItemCount;
}
}
//读取扩展背包
for (INT j=0; j<MAX_EXTRA_BAG_NUM; ++j)
{
ItemContainer* pBaseContainer = pHuman->GetExtraBagContain(j);
Assert(pBaseContainer);
if (pBaseContainer->IsValid())
{
for( INT i=0; i<pBaseContainer->GetContainerSize(); i++ )
{
//临时代码
Item* pItem = pBaseContainer->GetItem(i);
Assert(pItem);
if(!(pItem->IsEmpty()))
{
ItemIterator.m_nndex = pBaseContainer->ConIndex2BagIndex(i);
pItem->SaveValueTo(&ItemIterator.m_nItemData);
Msg.SetAskItemData(&ItemIterator,nItemCount);
++nItemCount;
}
}
}
}
Msg.SetItemCount(nItemCount);
//.........这里部分代码省略.........
示例2: Execute
UINT CGUnEquipHandler::Execute( CGUnEquip* 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 ) ;
HUMAN_EQUIP EquipPoint = (HUMAN_EQUIP)pPacket->getEquipPoint();
//Assert( pHuman->GetDB()->GetEquipDB()->IsSet(EquipPoint) ) ;
Item* pEquipItem = HumanItemLogic::GetEquip(pHuman,EquipPoint);
if(!pEquipItem)
{
Assert(pEquipItem);
return PACKET_EXE_CONTINUE;
}
if(pEquipItem->IsEmpty())
{
return PACKET_EXE_CONTINUE;
}
UCHAR itemClass = pEquipItem->GetItemClass();
if(itemClass == ICLASS_EQUIP)
{
INT BagIndex;// = pHuman->GetFirstEmptyBagIndex();
ItemContainer* pEquipContainer = pHuman->GetEquipContain();
ItemContainer* pBaseContainer = pHuman->GetBaseContain();
if(!pEquipContainer)
{
Assert(pEquipItem);
return PACKET_EXE_CONTINUE;
}
BYTE DeliverBagIndex = pPacket->getBagIndex();
if(DeliverBagIndex<pBaseContainer->GetContainerSize())
{
BagIndex = g_ItemOperator.MoveItem(pEquipContainer,
EquipPoint,
pBaseContainer,DeliverBagIndex);
}
else
{
BagIndex = g_ItemOperator.MoveItem(pEquipContainer,
EquipPoint,
pBaseContainer);
}
GCUnEquipResult Msg;
if(BagIndex>=0
&& BagIndex<pBaseContainer->GetContainerSize())
{
Msg.setEquipPoint(EquipPoint);
Msg.setBagIndex(BagIndex);
Msg.setItemID(pEquipItem->GetGUID());
Msg.setItemTableIndex(pEquipItem->GetItemTableIndex());
Msg.setResult(UNEQUIP_SUCCESS);
pHuman->SetEquipVer(pHuman->GetEquipVer()+1);
pHuman->ItemEffectFlush();
pGamePlayer->SendPacket( &Msg ) ;
//如果可见
if(pHuman->IsVisualPart(EquipPoint))
{
GCCharEquipment OtherMsg;
OtherMsg.setObjID(pHuman->GetID());
//if(EquipPoint == HEQUIP_WEAPON)
//{
// UINT uGemID = GetEquipmentMaxLevelGemID(pEquipItem);
// OtherMsg.setID(EquipPoint,pEquipItem->GetItemTableIndex(), uGemID);
//}
//else
//{
OtherMsg.setID(EquipPoint,pEquipItem->GetItemTableIndex(), -1);
//}
pScene->BroadCast(&OtherMsg,pHuman,TRUE);
}
}
else
//.........这里部分代码省略.........
示例3: Execute
uint CGStallOpenHandler::Execute( CGStallOpen* 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 ) ;
ObjID_t ObjId = pPacket->GetObjID();
//临时数组
GCStallOpen::_STALL_ITEM StallItem[STALL_BOX_SIZE+STALL_PET_BOX_SIZE];
if(ObjId == pHuman->GetID())
{//自己打开自己,肯定打开
//摊主container
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: CGStallOpenHandler::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();
//循环写入
UINT k = 0;
for(INT i = 0; i<pStallContainer->GetContainerSize(); i++)
{
if( pHuman->m_StallBox.GetSerialByIndex(i) != 0 )
{//这个格子里的东西更改过,需要通知客户端它的序列号
StallItem[k].nIndex = i;
StallItem[k].nPrice = pHuman->m_StallBox.GetPriceByIndex(i);
StallItem[k].nSerial = pHuman->m_StallBox.GetSerialByIndex(i);
if(pStallContainer->GetItem(i)->IsEmpty() == FALSE)
{
pStallContainer->GetItem(i)->SaveValueTo(&(StallItem[k].item));
}
k++;
}
}
for(INT i = 0; i<pStallPetContainer->GetContainerSize(); i++)
{
if( pHuman->m_StallBox.GetPetSerialByIndex(i) != 0 )
{//有东西
StallItem[k].bIsPet = TRUE;
StallItem[k].nIndex = i;
StallItem[k].nPrice = pHuman->m_StallBox.GetPetPriceByIndex(i);
StallItem[k].nSerial = pHuman->m_StallBox.GetPetSerialByIndex(i);
if(pStallPetContainer->GetItem(i)->IsEmpty() == FALSE)
{
StallItem[k].PetGuid = pStallPetContainer->GetItem(i)->GetPetGUID();
}
k++;
}
}
pHuman->StallNameChanged();
//消息填充
GCStallOpen Msg;
Msg.SetFirstPage( pHuman->m_StallBox.GetFirstPage());
Msg.SetMerchadiseNum(k);
Msg.SetMerchadiseList(StallItem);
Msg.SetShopName(pHuman->m_StallBox.GetStallName(), (UINT)strlen(pHuman->m_StallBox.GetStallName()));
Msg.SetObjID(ObjId);
Msg.SetGUID(pHuman->GetGUID());
//发还本人Q
pGamePlayer->SendPacket(&Msg);
}
else
{//别人
//判断距离是否可以打开
Obj_Human* pTargetHuman = pScene->GetHumanManager()->GetHuman( ObjId );
if( pTargetHuman == NULL )
{
GCStallError Msg;
Msg.SetID(STALL_MSG::ERR_OWNER_INVALID);
pHuman->GetPlayer()->SendPacket(&Msg);
g_pLog->FastSaveLog( LOG_FILE_1, "ERROR: CGStallOpenHandler::ObjName=%s, ERR_OWNER_INVALID: ObjId = %d"
,pHuman->GetName(), ObjId) ;
return PACKET_EXE_CONTINUE;
//.........这里部分代码省略.........