本文整理汇总了C++中CItem::IsContainer方法的典型用法代码示例。如果您正苦于以下问题:C++ CItem::IsContainer方法的具体用法?C++ CItem::IsContainer怎么用?C++ CItem::IsContainer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CItem
的用法示例。
在下文中一共展示了CItem::IsContainer方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ImportFix
void CImportFile::ImportFix()
{
ADDTOCALLSTACK("CImportFile::ImportFix");
// adjust all the containered items and eliminate duplicates.
CheckLast();
int iRemoved = 0;
CImportSer * pSerNext;
m_pCurSer = static_cast <CImportSer*> ( m_ListSer.GetHead());
for ( ; m_pCurSer != NULL; m_pCurSer = pSerNext )
{
pSerNext = static_cast <CImportSer*> ( m_pCurSer->GetNext());
if ( m_pCurSer->m_pObj == NULL ) // NEver created correctly
{
delete m_pCurSer;
continue;
}
// Make sure this item is not a dupe ?
CItem * pItemTest;
if ( m_pCurSer->IsTopLevel()) // top level only
{
if ( m_pCurSer->m_pObj->IsItem())
{
CItem * pItemCheck = dynamic_cast <CItem*>( m_pCurSer->m_pObj );
ASSERT(pItemCheck);
pItemCheck->SetAttr(ATTR_MOVE_NEVER);
CWorldSearch AreaItems( m_pCurSer->m_pObj->GetTopPoint());
for (;;)
{
CItem * pItem = AreaItems.GetItem();
if ( pItem == NULL )
break;
if ( ! pItem->IsSameType( m_pCurSer->m_pObj ))
continue;
pItem->SetName( m_pCurSer->m_pObj->GetName());
if ( ! ( m_pCurSer->m_pObj->GetTopZ() == pItem->GetTopZ()))
continue;
goto item_delete;
}
}
else
{
// dupe char ?
}
// Make sure the top level object is placed correctly.
m_pCurSer->m_pObj->MoveTo( m_pCurSer->m_pObj->GetTopPoint());
m_pCurSer->m_pObj->Update();
if ( ! m_pCurSer->m_pObj->IsContainer())
delete m_pCurSer;
continue;
}
pItemTest = dynamic_cast <CItem*> (m_pCurSer->m_pObj);
if ( pItemTest == NULL )
{
item_delete:
delete m_pCurSer->m_pObj;
delete m_pCurSer;
iRemoved ++;
continue;
}
// Find it's container.
CImportSer* pSerCont = static_cast <CImportSer*> ( m_ListSer.GetHead());
CObjBase * pObjCont = NULL;
for ( ; pSerCont != NULL; pSerCont = static_cast <CImportSer*> ( pSerCont->GetNext()))
{
if ( pSerCont->m_pObj == NULL )
continue;
if ( pSerCont->m_dwSer == m_pCurSer->m_dwContSer )
{
pObjCont = pSerCont->m_pObj;
if ( ! pItemTest->LoadSetContainer( pObjCont->GetUID(), m_pCurSer->m_layer ))
{
goto item_delete; // not in a cont ?
}
m_pCurSer->m_dwContSer = UID_UNUSED; // found it.
break;
}
}
if ( ! m_pCurSer->IsTopLevel() || pObjCont == NULL)
{
goto item_delete;
}
// Is it a dupe in the container or equipped ?
for ( CItem *pItem = dynamic_cast<CContainer*>(pObjCont)->GetContentHead(); pItem != NULL; pItem = pItem->GetNext() )
{
if ( pItemTest == pItem )
continue;
if ( pItemTest->IsItemEquipped())
{
if ( pItemTest->GetEquipLayer() != pItem->GetEquipLayer())
continue;
//.........这里部分代码省略.........
示例2: Migrate
void CImportFile::Migrate()
{
ADDTOCALLSTACK("CImportFile::Migrate");
// place and adjust all the containered items
CheckLast();
int iRemoved = 0;
CImportSer * pSerNext;
m_pCurSer = static_cast <CImportSer*> ( m_ListSer.GetHead());
for ( ; m_pCurSer != NULL; m_pCurSer = pSerNext )
{
pSerNext = static_cast <CImportSer*> ( m_pCurSer->GetNext());
if ( m_pCurSer->m_pObj == NULL ) // NEver created correctly
{
delete m_pCurSer;
continue;
}
CItem * pItemTest;
if ( m_pCurSer->IsTopLevel()) // top level only
{
// Make sure the top level object is placed correctly.
m_pCurSer->m_pObj->MoveTo( m_pCurSer->m_pObj->GetTopPoint());
m_pCurSer->m_pObj->Update();
if ( ! m_pCurSer->m_pObj->IsContainer())
delete m_pCurSer;
continue;
}
pItemTest = dynamic_cast <CItem*> (m_pCurSer->m_pObj);
if ( pItemTest == NULL )
{
item_delete:
delete m_pCurSer->m_pObj;
delete m_pCurSer;
iRemoved ++;
continue;
}
// Find it's container and add it to the correct container
CImportSer *pSerCont = static_cast<CImportSer *>(m_ListSer.GetHead());
CObjBase *pObjCont = NULL;
for ( ; pSerCont != NULL; pSerCont = static_cast<CImportSer *>(pSerCont->GetNext()) )
{
if ( pSerCont->m_pObj == NULL )
continue;
if ( pSerCont->m_dwSer == m_pCurSer->m_dwContSer )
{
pObjCont = pSerCont->m_pObj;
if ( !pItemTest->LoadSetContainer(pObjCont->GetUID(), m_pCurSer->m_layer) )
goto item_delete; // not in a cont ?
m_pCurSer->m_dwContSer = UID_UNUSED; // found it.
break;
}
}
// If neither top level nor in an existing container remove the item
if ( !m_pCurSer->IsTopLevel() || pObjCont == NULL )
goto item_delete;
/* Commented by Ares because this may causes errors while restoring player characters
Example:
- Items placed at the same positon in a container.
// Is it a dupe in the container or equipped ?
for ( CItem *pItem = dynamic_cast<CContainer *>(pObjCont)->GetContentHead(); pItem != NULL; pItem = pItem->GetNext() )
{
if ( pItemTest == pItem )
continue;
if ( pItemTest->IsItemEquipped() )
{
if ( pItemTest->GetEquipLayer() != pItem->GetEquipLayer() )
continue;
}
else
{
if ( !pItemTest->GetContainedPoint().IsSame2D(pItem->GetContainedPoint()) )
continue;
}
if ( !pItemTest->IsIdentical(pItem) )
continue;
goto item_delete;
}*/
// done with it if not a container.
if ( !pItemTest->IsContainer() )
delete m_pCurSer;
}
if ( iRemoved )
{
DEBUG_ERR(( "Import: removed %d bad items\n", iRemoved ));
}
m_ListSer.DeleteAll(); // done with the list now.
}