void CBaseEntityList::RemoveEntityAtSlot( int iSlot ) { Assert( iSlot >= 0 && iSlot < NUM_ENT_ENTRIES ); CEntInfo *pInfo = &m_EntPtrArray[iSlot]; if ( pInfo->m_pEntity ) { pInfo->m_pEntity->SetRefEHandle( INVALID_EHANDLE_INDEX ); // Notify the derived class that we're about to remove this entity. OnRemoveEntity( pInfo->m_pEntity, CBaseHandle( iSlot, pInfo->m_SerialNumber ) ); // Increment the serial # so ehandles go invalid. pInfo->m_pEntity = NULL; pInfo->m_SerialNumber = ( pInfo->m_SerialNumber+1)& SERIAL_MASK; m_activeList.Unlink( pInfo ); // Add the slot back to the free list if it's a non-networkable entity. if ( iSlot >= MAX_EDICTS ) { m_freeNonNetworkableList.AddToTail( pInfo ); } } }
void CClientTools::OnEntityDeleted( CBaseEntity *pEntity ) { if ( pEntity && pEntity->GetToolHandle() != (HTOOLHANDLE)0 ) { OnRemoveEntity( pEntity ); } }