本文整理汇总了C++中P_ITEM::content方法的典型用法代码示例。如果您正苦于以下问题:C++ P_ITEM::content方法的具体用法?C++ P_ITEM::content怎么用?C++ P_ITEM::content使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类P_ITEM
的用法示例。
在下文中一共展示了P_ITEM::content方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: onSpeechInput
void Human_Stablemaster::onSpeechInput( P_PLAYER pTalker, const QString& message )
{
if ( !pTalker->socket() )
return;
if ( m_npc->inRange( pTalker, 4 ) && ( VendorChkName( m_npc, message ) || message.contains( tr( "STABLEMASTER" ) ) ) )
{
if ( message.contains( tr( " STABLE" ) ) )
{
m_npc->talk( tr( "Which pet do you want me to stable?" ) );
pTalker->socket()->attachTarget( new cStableTarget( m_npc ) );
}
else if ( message.contains( tr( " RELEASE" ) ) )
{
int gold = pTalker->countBankGold() + pTalker->countGold();
P_ITEM pPack = m_npc->getBankbox();
cItem::ContainerContent stableitems;
if ( pPack )
{
cItem::ContainerContent content = pPack->content();
cItem::ContainerContent::const_iterator it( content.begin() );
while ( it != content.end() )
{
if ( !( *it )->hasTag( "player" ) || !( *it )->hasTag( "pet" ) )
continue;
if ( ( *it ) && ( uint )( *it )->getTag( "player" ).toInt() == pTalker->serial() )
stableitems.push_back( ( *it ) );
++it;
}
}
if ( !stableitems.empty() )
{
cItem::ContainerContent::const_iterator it( stableitems.begin() );
while ( it != stableitems.end() )
{
if ( ( *it ) )
{
P_NPC pPet = dynamic_cast<P_NPC>( World::instance()->findChar( ( *it )->getTag( "pet" ).toInt() ) );
if ( pPet )
{
pPet->free = false;
// we need this for db saves
pPet->setStablemasterSerial( INVALID_SERIAL );
pPet->moveTo( m_npc->pos() );
pPet->resend();
}
( *it )->remove();
}
++it;
}
pPack->update();
m_npc->talk( tr( "Here's your pet back!" ) );
}
}
}
}
示例2: cont_has_spell
static bool cont_has_spell( P_ITEM pCont, UINT8 spell )
{
if( pCont->objectID() == "cSpellBook" )
{
cSpellBook *pBook = dynamic_cast< cSpellBook* >( pCont );
if( pBook )
return pBook->hasSpell( spell );
return false;
}
else if( pCont->content().size() > 0 )
{
cItem::ContainerContent content = pCont->content();
cItem::ContainerContent::const_iterator iter;
cItem::ContainerContent::const_iterator end = content.end();
for( iter = content.begin(); iter != end; ++iter )
if( cont_has_spell( *iter, spell ) )
return true;
}
return false;
}