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


C++ CUtlDict::InvalidIndex方法代码示例

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


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

示例1:

NetworkedClass::~NetworkedClass()
{
	if( m_pServerClass )
	{
		m_pServerClass->m_bFree = true;
		m_pServerClass->SetupServerClass(PN_NONE);

		unsigned short lookup = m_ServerClassInfoDatabase.Find( m_pNetworkName );
		if ( lookup != m_ServerClassInfoDatabase.InvalidIndex() )
		{
			m_ServerClassInfoDatabase.Remove( m_pNetworkName );
		}
	}

	free( (void *)m_pNetworkName );
	m_pNetworkName = NULL;
}
开发者ID:detoxhby,项目名称:lambdawars,代码行数:17,代码来源:srcpy_server_class.cpp

示例2: CalcSequenceIndex

/**
 * Try to look up named sequences in a CUtlDict cache before falling back to the normal LookupSequence.  It's
 * best to avoid the normal LookupSequence when your models have 750+ sequences...
 */
int CCSPlayerAnimState::CalcSequenceIndex( const char *pBaseName, ... )
{
	VPROF( "CCSPlayerAnimState::CalcSequenceIndex" );

	CheckCachedSequenceValidity();

	char szFullName[512];
	va_list marker;
	va_start( marker, pBaseName );
	Q_vsnprintf( szFullName, sizeof( szFullName ), pBaseName, marker );
	va_end( marker );

	int iSequence = m_namedSequence.Find( szFullName );
	if ( iSequence == m_namedSequence.InvalidIndex() )
	{
		iSequence = GetOuter()->LookupSequence( szFullName );
		m_namedSequence.Insert( szFullName, iSequence );
	}
	else
	{
		iSequence = m_namedSequence[iSequence];
	}

#if defined(CLIENT_DLL) && defined(_DEBUG)
	int realSequence = GetOuter()->LookupSequence( szFullName );
	Assert( realSequence == iSequence );
#endif
	
	// Show warnings if we can't find anything here.
	if ( iSequence == -1 )
	{
		static CUtlDict<int,int> dict;
		if ( dict.Find( szFullName ) == -1 )
		{
			dict.Insert( szFullName, 0 );
			Warning( "CalcSequenceIndex: can't find '%s'.\n", szFullName );
		}

		iSequence = 0;
	}

	return iSequence;
}
开发者ID:Asunaya,项目名称:game,代码行数:47,代码来源:cs_playeranimstate.cpp

示例3: RestoreRenderTargets

//-----------------------------------------------------------------------------
// Restore just the render targets (cause we've got video memory again)
//-----------------------------------------------------------------------------
void CTextureManager::RestoreRenderTargets()
{
	// 360 should not have gotten here
	Assert( !IsX360() );

	for ( int i = m_TextureList.First(); i != m_TextureList.InvalidIndex(); i = m_TextureList.Next( i ) )
	{
		if ( m_TextureList[i]->IsRenderTarget() )
		{
			RestoreTexture( m_TextureList[i] );
		}
	}

	if ( m_pFullScreenTexture )
	{
		g_pShaderAPI->SetFullScreenTextureHandle( m_pFullScreenTexture->GetTextureHandle( 0 ) );
	}

	CacheExternalStandardRenderTargets();
}
开发者ID:DeadZoneLuna,项目名称:SourceEngine2007,代码行数:23,代码来源:texturemanager.cpp

示例4: AddTextureAlias

void CTextureManager::AddTextureAlias( const char *pAlias, const char *pRealName )
{
	if	( (pAlias == NULL) || (pRealName == NULL) )
		return; //invalid alias

	char szCleanName[MAX_PATH];
	int index = m_TextureAliases.Find( NormalizeTextureName( pAlias, szCleanName, sizeof( szCleanName ) ) );

	if	( index != m_TextureAliases.InvalidIndex() )
	{
		AssertMsg( Q_stricmp( pRealName, m_TextureAliases[index] ) == 0, "Trying to use one name to alias two different textures." );
		RemoveTextureAlias( pAlias ); //remove the old alias to make room for the new one.
	}

	size_t iRealNameLength = strlen( pRealName ) + 1;
	char *pRealNameCopy = new char [iRealNameLength];
	memcpy( pRealNameCopy, pRealName, iRealNameLength );

	m_TextureAliases.Insert( szCleanName, pRealNameCopy );
}
开发者ID:DeadZoneLuna,项目名称:SourceEngine2007,代码行数:20,代码来源:texturemanager.cpp

示例5: ForceAllTexturesIntoHardware

//-----------------------------------------------------------------------------
// Reloads all textures
//-----------------------------------------------------------------------------
void CTextureManager::ForceAllTexturesIntoHardware( void )
{
	if ( IsX360() )
		return;

	IMaterial *pMaterial = MaterialSystem()->FindMaterial( "engine/preloadtexture", "texture preload" );
	pMaterial = ((IMaterialInternal *)pMaterial)->GetRealTimeVersion(); //always work with the realtime material internally
	bool bFound;
	IMaterialVar *pBaseTextureVar = pMaterial->FindVar( "$basetexture", &bFound );
	if( !bFound )
	{
		return;
	}

	for ( int i = m_TextureList.First(); i != m_TextureList.InvalidIndex(); i = m_TextureList.Next( i ) )
	{
		// Put the texture back onto the board
		ForceTextureIntoHardware( m_TextureList[i], pMaterial, pBaseTextureVar );
	}
}
开发者ID:DeadZoneLuna,项目名称:SourceEngine2007,代码行数:23,代码来源:texturemanager.cpp

示例6: AddWeaponSet

void CGECreateServer::AddWeaponSet( const char *group, KeyValues *set )
{
	int grpIdx = m_WeaponSets.Find( group );
	if ( grpIdx == m_WeaponSets.InvalidIndex() )
		grpIdx = m_WeaponSets.Insert( group, new CUtlDict<char*, int>() );

	char *name = new char[32];
	Q_strncpy( name, set->GetString("print_name", "Unnamed"), 32 );
	
	int setIdx = m_WeaponSets[grpIdx]->Find( set->GetName() );
	if ( setIdx != m_WeaponSets[grpIdx]->InvalidIndex() )
	{
		// Replace the existing set with this one
		delete [] m_WeaponSets[grpIdx]->Element(setIdx);
		m_WeaponSets[grpIdx]->RemoveAt(grpIdx);
	}

	// Insert the set
	m_WeaponSets[grpIdx]->Insert( set->GetName(), name );
}
开发者ID:djoslin0,项目名称:ges-legacy-code,代码行数:20,代码来源:ge_createserver.cpp

示例7: Draw_DecalSetName

void Draw_DecalSetName( int decal, char *name )
{
	while ( decal >= g_DecalLookup.Count() )
	{
		int idx = g_DecalLookup.AddToTail();
		g_DecalLookup[ idx ] = 0;
	}

	int lookup = g_DecalDictionary.Find( name );
	if ( lookup == g_DecalDictionary.InvalidIndex() )
	{
		DecalEntry entry;
		entry.material = GL_LoadMaterial( name );
		entry.index = decal;

		lookup = g_DecalDictionary.Insert( name, entry );
	}

	g_DecalLookup[ decal ] = lookup;
}
开发者ID:RaisingTheDerp,项目名称:raisingthebar,代码行数:20,代码来源:decals.cpp

示例8: RemoveUnusedTextures

void CTextureManager::RemoveUnusedTextures( void )
{
	int iNext;
	for ( int i = m_TextureList.First(); i != m_TextureList.InvalidIndex(); i = iNext )
	{
		iNext = m_TextureList.Next( i );

#ifdef _DEBUG
		if ( m_TextureList[i]->GetReferenceCount() < 0 )
		{
			Warning( "RemoveUnusedTextures: pTexture->m_referenceCount < 0 for %s\n", m_TextureList[i]->GetName() );
		}
#endif
		if ( m_TextureList[i]->GetReferenceCount() <= 0 )
		{
			ITextureInternal::Destroy( m_TextureList[i] );
			m_TextureList.RemoveAt( i );
		}
	}
}
开发者ID:DeadZoneLuna,项目名称:SourceEngine2007,代码行数:20,代码来源:texturemanager.cpp

示例9: GetDecalIndexForName

//-----------------------------------------------------------------------------
// Purpose: 
// Input  : *decalname - 
// Output : int
//-----------------------------------------------------------------------------
int CDecalEmitterSystem::GetDecalIndexForName( char const *decalname )
{
	if ( !decalname  || !decalname[ 0 ] )
		return -1;

	int idx = m_Decals.Find( decalname );
	if ( idx == m_Decals.InvalidIndex() )
		return -1;

	DecalEntry *e = &m_Decals[ idx ];
	Assert( e );
	int count = e->indices.Count();
	if ( count <= 0 )
		return -1;

	float totalweight = 0.0f;
	int slot = 0;

	for ( int i = 0; i < count; i++ )
	{
		int idx = e->indices[ i ];
		DecalListEntry *item = &m_AllDecals[ idx ];
		Assert( item );
		
		if ( !totalweight )
		{
			slot = idx;
		}

		// Always assume very first slot will match
		totalweight += item->weight;
		if ( !totalweight || random->RandomFloat(0,totalweight) < item->weight )
		{
			slot = idx;
		}
	}

	return m_AllDecals[ slot ].precache_index;
}
开发者ID:KyleGospo,项目名称:City-17-Episode-One-Source,代码行数:44,代码来源:decals.cpp

示例10: strdup

//-----------------------------------------------------------------------------
// Purpose: Find a free PyServerClass and claim it
//			Send a message to the clients to claim a client class and set it to
//			the right type.
//-----------------------------------------------------------------------------
NetworkedClass::NetworkedClass( const char *pNetworkName, boost::python::object cls_type )
{
	m_pNetworkName = strdup( pNetworkName );
	m_pServerClass = NULL;
	PyServerClass *p;

	// See if there is already an entity with this network name
	unsigned short lookup = m_ServerClassInfoDatabase.Find( pNetworkName );
	if ( lookup != m_ServerClassInfoDatabase.InvalidIndex() )
	{
		Warning("NetworkedClass: %s already added. Replacing with new data. Element name: %s\n", pNetworkName, m_ServerClassInfoDatabase.Element(lookup) );
		p = FindPyServerClass( m_ServerClassInfoDatabase.Element(lookup) );
		if( !p )
		{
			Warning("NetworkedClass: ServerClass %s not found\n", m_ServerClassInfoDatabase.Element(lookup) );
			return;
		}
		if( p->m_pNetworkedClass )
			p->m_pNetworkedClass->m_pServerClass = NULL;
	}
	else
	{
		// Find a free server class and add it to the database
		p = FindFreePyServerClass();
		if( !p ) {
			Warning("Couldn't create PyServerClass %s: Out of free PyServerClasses\n", pNetworkName);
			return;
		}

		lookup = m_ServerClassInfoDatabase.Insert(pNetworkName, p->GetName());
	}

	m_pServerClass = p;
	m_PyClass = cls_type;
	p->m_bFree = false;
	p->m_pNetworkedClass = this;

	SetupServerClass();
}
开发者ID:detoxhby,项目名称:lambdawars,代码行数:44,代码来源:srcpy_server_class.cpp

示例11: FindNext

int CTextureManager::FindNext( int iIndex, ITextureInternal **pTexInternal )
{
	if ( iIndex == -1 && m_TextureList.Count() )
	{
		iIndex = m_TextureList.First();
	}
	else if ( !m_TextureList.Count() || !m_TextureList.IsValidIndex( iIndex ) )
	{
		*pTexInternal = NULL;
		return -1;
	}

	*pTexInternal = m_TextureList[iIndex];

	iIndex = m_TextureList.Next( iIndex );
	if ( iIndex == m_TextureList.InvalidIndex() )
	{
		// end of list
		iIndex = -1;
	}

	return iIndex;
}
开发者ID:DeadZoneLuna,项目名称:SourceEngine2007,代码行数:23,代码来源:texturemanager.cpp

示例12:

NetworkedClass::~NetworkedClass()
{
	unsigned short lookup;

	// Remove pointer
	lookup = m_NetworkClassDatabase.Find( m_pNetworkName );
	if ( lookup != m_NetworkClassDatabase.InvalidIndex() )
	{
		// Only remove if it's our pointer. Otherwise we are already replaced.
		if( m_NetworkClassDatabase.Element( lookup ) == this )
			m_NetworkClassDatabase.RemoveAt( lookup );
	}
	else
	{
		Warning("NetworkedClass destruction: invalid networkclass %s\n", m_pNetworkName);
	}

	if( m_pClientClass )
	{
		m_pClientClass->m_bFree = true;
	}
	free( (void *)m_pNetworkName );
	m_pNetworkName = NULL;
}
开发者ID:Sandern,项目名称:py-source-sdk-2013,代码行数:24,代码来源:srcpy_client_class.cpp

示例13: ProcessVCD

void ProcessVCD( CUtlDict< VCDList, int >& database, CUtlSymbol& vcdname )
{
    // vprint( 0, "Processing '%s'\n", g_Analysis.symbols.String( vcdname ) );

    // Load the .vcd
    char fullname[ 512 ];
    Q_snprintf( fullname, sizeof( fullname ), "%s", g_Analysis.symbols.String( vcdname ) );

    LoadScriptFile( fullname );

    CChoreoScene *scene = ChoreoLoadScene( fullname, NULL, &g_TokenProcessor, Con_Printf );
    if ( scene )
    {
        bool first = true;
        // Now iterate the events looking for speak events
        int c = scene->GetNumEvents();
        for ( int i = 0; i < c; i++ )
        {
            CChoreoEvent *e = scene->GetEvent( i );

            if ( e->GetType() == CChoreoEvent::MOVETO )
            {
                SpewMoveto( first, fullname, e );
                first = false;
            }

            if ( e->GetType() != CChoreoEvent::SPEAK )
                continue;

            // Look up sound in sound emitter system
            char const *wavename = soundemitter->GetWavFileForSound( e->GetParameters(), NULL );
            if ( !wavename || !wavename[ 0 ] )
            {
                continue;
            }

            char fullwavename[ 512 ];
            Q_snprintf( fullwavename, sizeof( fullwavename ), "%ssound\\%s",
                        gamedir, wavename );
            Q_FixSlashes( fullwavename );

            // Now add to proper slot
            VCDList *entry = NULL;

            // Add vcd to database
            int slot = database.Find( fullwavename );
            if ( slot == database.InvalidIndex() )
            {
                VCDList nullEntry;
                slot = database.Insert( fullwavename, nullEntry );
            }

            entry = &database[ slot ];
            if ( entry->vcds.Find( vcdname ) == entry->vcds.InvalidIndex() )
            {
                entry->vcds.AddToTail( vcdname );
            }
        }

        if ( vcdonly )
        {
            CheckForOverlappingFlexTracks( scene );
        }
    }

    delete scene;
}
开发者ID:steadyfield,项目名称:SourceEngine2007,代码行数:67,代码来源:vcd_sound_check.cpp

示例14: Correlate

void Correlate( CUtlRBTree< ReferencedFile, int >& referencedfiles, CUtlVector< FileEntry >& contentfiles, const char *modname )
{
	int i;
	int c = contentfiles.Count();
	
	double totalDiskSize = 0;
	double totalReferencedDiskSize = 0;
	double totalWhiteListDiskSize = 0;

	for ( i = 0; i < c; ++i )
	{
		totalDiskSize += contentfiles [ i ].size;
	}

	vprint( 0, "Content tree size on disk %s\n", Q_pretifymem( totalDiskSize, 3 ) );
	
	// Analysis is to walk tree and see which files on disk are referenced in the .lst files
	// Need a fast lookup from file symbol to referenced list
	CUtlRBTree< ReferencedFile, int >	tree( 0, 0, ReferencedFileLessFunc );
	c = referencedfiles.Count();
	for ( i = 0 ; i < c; ++i )
	{
		tree.Insert( referencedfiles[ i ] );
	}

	// Now walk the on disk file and see check off resources which are in referenced
	c = contentfiles.Count();
	int invalidindex = tree.InvalidIndex();
	unsigned int refcounted = 0;
	unsigned int whitelisted = 0;

	filesystem->RemoveFile( CFmtStr( "%swhitelist.lst", g_szReslistDir ), "GAME" );

	for ( i = 0; i < c; ++i )
	{
		FileEntry & entry = contentfiles[ i ];

		ReferencedFile foo;
		foo.sym = entry.sym;

		bool gameref = tree.Find( foo ) != invalidindex;
		char const *fn = g_Analysis.symbols.String( entry.sym );

		bool whitelist = g_WhiteList.Find( entry.sym ) != g_WhiteList.InvalidIndex();

		if ( gameref || whitelist )
		{
			entry.referenced = gameref ? REFERENCED_GAME : REFERENCED_WHITELIST;
			totalReferencedDiskSize += entry.size;
			if ( entry.referenced == REFERENCED_WHITELIST )
			{
				logprint( CFmtStr( "%swhitelist.lst", g_szReslistDir ), "\"%s\\%s\"\n", modname, fn );

				totalWhiteListDiskSize += entry.size;
				++whitelisted;
			}
			++refcounted;
		}
	}

	vprint( 0, "Found %i referenced (%i whitelist) files in tree, %s\n", refcounted, whitelisted, Q_pretifymem( totalReferencedDiskSize, 2 ) );
	vprint( 0, "%s appear unused\n", Q_pretifymem( totalDiskSize - totalReferencedDiskSize, 2 ) );

	// Now sort and dump the unreferenced ones..
	vprint( 0, "Sorting unreferenced files list...\n" );

	CUtlRBTree< FileEntry, int >	unreftree( 0, 0, FileEntryLessFunc );
	for ( i = 0; i < c; ++i )
	{
		FileEntry & entry = contentfiles[ i ];
		if ( entry.referenced != REFERENCED_NO )
			continue;

		unreftree.Insert( entry );
	}

	// Now walk the unref tree in order
	i = unreftree.FirstInorder();
	invalidindex = unreftree.InvalidIndex();
	int index = 0;
	while ( i != invalidindex )
	{
		FileEntry & entry = unreftree[ i ];

		if ( showreferencedfiles )
		{
			vprint( 1, "%6i %12s: %s\n", ++index, Q_pretifymem( entry.size, 2 ), g_Analysis.symbols.String( entry.sym ) );
		}
		
		i = unreftree.NextInorder( i );
	}

	if ( showmapfileusage )
	{
		vprint( 0, "Writing referenced.csv...\n" );

		// Now walk the list of referenced files and print out how many and which maps reference them
		i = tree.FirstInorder();
		invalidindex = tree.InvalidIndex();
		index = 0;
//.........这里部分代码省略.........
开发者ID:DeadZoneLuna,项目名称:SourceEngine2007,代码行数:101,代码来源:unusedcontent.cpp

示例15: Cmd_AddClientCmdCanExecuteVar

void Cmd_AddClientCmdCanExecuteVar( const char *pName )
{
	if ( g_ExtraClientCmdCanExecuteCvars.Find( pName ) == g_ExtraClientCmdCanExecuteCvars.InvalidIndex() )
		g_ExtraClientCmdCanExecuteCvars.Insert( pName );
}
开发者ID:Axitonium,项目名称:SourceEngine2007,代码行数:5,代码来源:cmd.cpp


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