本文整理汇总了C++中P_CHAR::content方法的典型用法代码示例。如果您正苦于以下问题:C++ P_CHAR::content方法的具体用法?C++ P_CHAR::content怎么用?C++ P_CHAR::content使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类P_CHAR
的用法示例。
在下文中一共展示了P_CHAR::content方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: equipItem
// Tries to equip an item
// if that fails it tries to put the item in the users backpack
// if *that* fails it puts it at the characters feet
// That works for NPCs as well
void equipItem( P_CHAR wearer, P_ITEM item )
{
tile_st tile = TileCache::instance()->getTile( item->id() );
// User cannot wear the item
if ( tile.layer == 0 )
{
if ( wearer->objectType() == enPlayer )
{
P_PLAYER pp = dynamic_cast<P_PLAYER>( wearer );
if ( pp->socket() )
pp->socket()->sysMessage( tr( "You cannot wear that item." ) );
}
item->toBackpack( wearer );
return;
}
cBaseChar::ItemContainer container = wearer->content();
cBaseChar::ItemContainer::const_iterator it( container.begin() );
for ( ; it != container.end(); ++it )
{
P_ITEM equip = *it;
// Unequip the item and free the layer that way
if ( equip && ( equip->layer() == tile.layer ) )
equip->toBackpack( wearer );
}
// *finally* equip the item
wearer->addItem( static_cast<cBaseChar::enLayer>( item->layer() ), item );
}
示例2: DeleteChar
void cCharStuff::DeleteChar (P_CHAR pc_k) // Delete character
{
if( !pc_k )
return;
P_PLAYER pp_k = dynamic_cast<P_PLAYER>(pc_k);
P_NPC pn_k = dynamic_cast<P_NPC>(pc_k);
if( pn_k )
{
pn_k->setOwner( 0 );
}
pc_k->setGuarding( 0 );
// We need to remove the equipment here.
cBaseChar::ItemContainer container(pc_k->content());
cBaseChar::ItemContainer::const_iterator it (container.begin());
cBaseChar::ItemContainer::const_iterator end(container.end());
for (; it != end; ++it )
{
P_ITEM pItem = *it;
if( !pItem )
continue;
Items->DeleItem( pItem );
}
// multi check
if( pc_k->multis() != INVALID_SERIAL )
{
cMulti* pMulti = dynamic_cast< cMulti* >( FindItemBySerial( pc_k->multis() ) );
if( pMulti )
{
pMulti->removeChar( pc_k );
}
}
pc_k->removeFromView( false ); // Remove the character from all in-range sockets view
MapObjects::instance()->remove( pc_k ); // taking it out of mapregions BEFORE x,y changed
pc_k->del(); // Remove from Database
pc_k->free = true;
World::instance()->deleteObject( pc_k );
}