当前位置: 首页>>代码示例>>C++>>正文


C++ CElement::CountChildren方法代码示例

本文整理汇总了C++中CElement::CountChildren方法的典型用法代码示例。如果您正苦于以下问题:C++ CElement::CountChildren方法的具体用法?C++ CElement::CountChildren怎么用?C++ CElement::CountChildren使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CElement的用法示例。


在下文中一共展示了CElement::CountChildren方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: RemovePlayersBelow

void CPerPlayerEntity::RemovePlayersBelow(CElement* pElement, std::set<CPlayer*>& Removed)
{
    assert(pElement);

    // Is this a player?
    if (IS_PLAYER(pElement))
    {
        // Remove the reference
        CPlayer* pPlayer = static_cast<CPlayer*>(pElement);
        RemovePlayerReference(pPlayer);

        // Did we just loose the last reference to that player? Add him to the list over removed players.
        if (!IsVisibleToPlayer(*pPlayer))
        {
            MapInsert(Removed, pPlayer);
        }
    }

    // Call ourself on all our children
    CChildListType ::const_iterator iterChildren = pElement->IterBegin();
    for (; iterChildren != pElement->IterEnd(); iterChildren++)
    {
        CElement* pElement = *iterChildren;
        if (pElement->CountChildren() || IS_PLAYER(pElement))            // This check reduces cpu usage when unloading large maps (due to recursion)
            RemovePlayersBelow(pElement, Removed);
    }
}
开发者ID:ccw808,项目名称:mtasa-blue,代码行数:27,代码来源:CPerPlayerEntity.cpp

示例2: AddPlayersBelow

void CPerPlayerEntity::AddPlayersBelow(CElement* pElement, std::set<CPlayer*>& Added)
{
    assert(pElement);

    // Is this a player?
    if (IS_PLAYER(pElement))
    {
        // Are we not already visible to that player? Add it to the list
        CPlayer* pPlayer = static_cast<CPlayer*>(pElement);
        if (!IsVisibleToPlayer(*pPlayer))
        {
            MapInsert(Added, pPlayer);
        }

        // Add it to our reference list
        AddPlayerReference(pPlayer);
    }

    // Call ourself on all its children elements
    CChildListType ::const_iterator iterChildren = pElement->IterBegin();
    for (; iterChildren != pElement->IterEnd(); iterChildren++)
    {
        CElement* pElement = *iterChildren;
        if (pElement->CountChildren() || IS_PLAYER(pElement))            // This check reduces cpu usage when loading large maps (due to recursion)
            AddPlayersBelow(pElement, Added);
    }
}
开发者ID:ccw808,项目名称:mtasa-blue,代码行数:27,代码来源:CPerPlayerEntity.cpp

示例3: BroadcastElementChildren

void CMapManager::BroadcastElementChildren ( CElement* pParentElement, CEntityAddPacket &Packet, std::vector < CPerPlayerEntity* > &pPerPlayerList, std::set < CElement* >& outDoneElements )
{
    CChildListType ::const_iterator iter = pParentElement->IterBegin ();
    for ( ; iter != pParentElement->IterEnd(); iter++ )
    {
        CElement* pChildElement = *iter;
        MapInsert( outDoneElements, pChildElement );

        // Is it a per-player entity
        if ( pChildElement->IsPerPlayerEntity () )
        {
            pPerPlayerList.push_back ( static_cast < CPerPlayerEntity* > ( pChildElement ) );
        }
        else
        {
            Packet.Add ( pChildElement );
        }

        if ( pChildElement->CountChildren() > 0 )
            BroadcastElementChildren ( pChildElement, Packet, pPerPlayerList, outDoneElements );
    }
}
开发者ID:AdiBoy,项目名称:mtasa-blue,代码行数:22,代码来源:CMapManager.cpp

示例4: BroadcastElementChildren

void CMapManager::BroadcastElementChildren ( CElement* pElement, CEntityAddPacket &Packet, list < CPerPlayerEntity* > &pPerPlayerList, bool bBroadcastAll )
{
    CElement * pTemp;
    CChildListType ::const_iterator iter = pElement->IterBegin ();
    for ( ; iter != pElement->IterEnd(); iter++ )
    {
        pTemp = *iter;
        // Is this a map created entity or our resource's root element
        if ( bBroadcastAll || ( pTemp->IsMapCreated () || ( pTemp->GetType () == CElement::DUMMY && !strcmp ( pTemp->GetTypeName ().c_str (), "map" ) ) ) )
        {
            // Is it a per-player entity
            if ( pTemp->IsPerPlayerEntity () )
            {
                pPerPlayerList.push_back ( static_cast < CPerPlayerEntity* > ( pTemp ) );
            }
            else
            {
                Packet.Add ( pTemp );
            }
        }
        if ( pTemp->CountChildren() > 0 ) BroadcastElementChildren ( pTemp, Packet, pPerPlayerList, bBroadcastAll );
    }
}
开发者ID:EagleShen,项目名称:MTA,代码行数:23,代码来源:CMapManager.cpp


注:本文中的CElement::CountChildren方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。