void CClientEntity::_GetEntitiesFromRoot ( unsigned int uiTypeHash, std::map < CClientEntity*, int >& mapResults ) { t_mapEntitiesFromRoot::iterator find = ms_mapEntitiesFromRoot.find ( uiTypeHash ); if ( find != ms_mapEntitiesFromRoot.end () ) { const std::list < CClientEntity* >& listEntities = find->second; CClientEntity* pEntity; unsigned int uiIndex = 0; for ( std::list < CClientEntity* >::const_reverse_iterator i = listEntities.rbegin (); i != listEntities.rend (); ++i ) { pEntity = *i; assert ( pEntity ); ElementID ID = pEntity->GetID (); assert ( ID != INVALID_ELEMENT_ID ); assert ( pEntity == CElementIDs::GetElement ( ID ) ); if ( pEntity->IsBeingDeleted () ) OutputDebugString ( SString ( "Client: 0x%08x %s is flagged as IsBeingDeleted() but is still in GetEntitiesFromRoot\n", pEntity, pEntity->GetTypeName () ) ); assert ( mapResults.find ( pEntity ) == mapResults.end () ); mapResults [ pEntity ] = 1; } } }
void CClientEntity::GetEntitiesFromRoot ( unsigned int uiTypeHash, lua_State* luaVM, bool bStreamedIn ) { #if CHECK_ENTITIES_FROM_ROOT _CheckEntitiesFromRoot ( uiTypeHash ); #endif t_mapEntitiesFromRoot::iterator find = ms_mapEntitiesFromRoot.find ( uiTypeHash ); if ( find != ms_mapEntitiesFromRoot.end () ) { CFromRootListType& listEntities = find->second; CClientEntity* pEntity; unsigned int uiIndex = 0; for ( CFromRootListType::reverse_iterator i = listEntities.rbegin (); i != listEntities.rend (); ++i ) { pEntity = *i; // Only streamed in elements? if ( !bStreamedIn || !pEntity->IsStreamingCompatibleClass() || reinterpret_cast < CClientStreamElement* > ( pEntity )->IsStreamedIn() ) { if ( !pEntity->IsBeingDeleted ( ) ) { // Add it to the table lua_pushnumber ( luaVM, ++uiIndex ); lua_pushelement ( luaVM, pEntity ); lua_settable ( luaVM, -3 ); } } } } }
void CClientEntity::CallEventNoParent ( const char* szName, const CLuaArguments& Arguments, CClientEntity* pSource ) { // Call it on us if this isn't the same class it was raised on //TODO not sure why the null check is necessary (eAi) if ( pSource != this && m_pEventManager != NULL && m_pEventManager->HasEvents () ) { m_pEventManager->Call ( szName, Arguments, pSource, this ); } // Call it on all our children if ( ! m_Children.empty () ) { CElementListSnapshot* pList = GetChildrenListSnapshot(); pList->AddRef(); // Keep list alive during use for ( CElementListSnapshot::const_iterator iter = pList->begin() ; iter != pList->end() ; iter++ ) { CClientEntity* pEntity = *iter; if ( !pEntity->IsBeingDeleted() ) { if ( !pEntity->m_pEventManager || pEntity->m_pEventManager->HasEvents () || !pEntity->m_Children.empty () ) { pEntity->CallEventNoParent ( szName, Arguments, pSource ); if ( m_bBeingDeleted ) break; } } } pList->Release(); } }
CClientEntity* lua_toelement ( lua_State* luaVM, int iArgument ) { if ( lua_type ( luaVM, iArgument ) == LUA_TLIGHTUSERDATA ) { ElementID ID = TO_ELEMENTID ( lua_touserdata ( luaVM, iArgument ) ); CClientEntity* pEntity = CElementIDs::GetElement ( ID ); if ( !pEntity || pEntity->IsBeingDeleted () ) return NULL; return pEntity; } else if ( lua_type ( luaVM, iArgument ) == LUA_TUSERDATA ) { ElementID ID = TO_ELEMENTID ( * ( ( void ** ) lua_touserdata ( luaVM, iArgument ) ) ); CClientEntity* pEntity = CElementIDs::GetElement ( ID ); if ( !pEntity || pEntity->IsBeingDeleted () ) return NULL; return pEntity; } return NULL; }
void CClientGUIManager::FlushQueuedUpdates() { map<ElementID, bool>::iterator iter = m_QueuedGridListUpdates.begin(); for (; iter != m_QueuedGridListUpdates.end(); ++iter) { CClientEntity* pEntity = CElementIDs::GetElement(iter->first); if (pEntity && !pEntity->IsBeingDeleted() && pEntity->GetType() == CCLIENTGUI) { CClientGUIElement* pGUIElement = static_cast<CClientGUIElement*>(pEntity); if (pGUIElement && IS_CGUIELEMENT_GRIDLIST(pGUIElement)) { CGUIGridList* pGUIGridList = static_cast<CGUIGridList*>(pGUIElement->GetCGUIElement()); pGUIGridList->ForceUpdate(); } } } m_QueuedGridListUpdates.clear(); }