// call this before and after each frame to delete all of the marked entities.
void CGlobalEntityList::CleanupDeleteList( void )
{
	VPROF( "CGlobalEntityList::CleanupDeleteList" );
	g_fInCleanupDelete = true;
	// clean up the vphysics delete list as well
	PhysOnCleanupDeleteList();

	g_bDisableEhandleAccess = true;
	for ( int i = 0; i < g_DeleteList.Count(); i++ )
	{
		g_DeleteList[i]->Release();
	}
	g_bDisableEhandleAccess = false;
	g_DeleteList.RemoveAll();

	g_fInCleanupDelete = false;
}
void CopyListPanelToClipboard( vgui::ListPanel *pListPanel )
{
	CUtlVector<char> textBuf;

	// Write the headers.
	int nColumns = pListPanel->GetNumColumnHeaders();
	for ( int i=0; i < nColumns; i++ )
	{
		if ( i != 0 )
			textBuf.AddToTail( '\t' );
		
		char tempText[512];
		if ( !pListPanel->GetColumnHeaderText( i, tempText, sizeof( tempText ) ) )
			Error( "GetColumHeaderText( %d ) failed", i );
		
		textBuf.AddMultipleToTail( strlen( tempText ), tempText );
	}
	textBuf.AddToTail( '\n' );

	// Now write the rows.
	int iCur = pListPanel->FirstItem();
	while ( iCur != pListPanel->InvalidItemID() )
	{
		// Write the columns for this row.
		for ( int i=0; i < nColumns; i++ )
		{
			if ( i != 0 )
				textBuf.AddToTail( '\t' );
		
			wchar_t tempTextWC[512];
			char tempText[512];

			pListPanel->GetCellText( iCur, i, tempTextWC, sizeof( tempTextWC ) );
			g_pVGuiLocalize->ConvertUnicodeToANSI( tempTextWC, tempText, sizeof( tempText ) );

			textBuf.AddMultipleToTail( strlen( tempText ), tempText );
		}
		textBuf.AddToTail( '\n' );

		iCur = pListPanel->NextItem( iCur );
	}
	textBuf.AddToTail( 0 );

	// Set the clipboard text.
	vgui::system()->SetClipboardText( textBuf.Base(), textBuf.Count() );
}
void CASW_Mission_Chooser_Source_Local::FindMissionsInCampaign( int iCampaignIndex, int nMissionOffset, int iNumSlots )
{
	if (!m_bBuiltMapList)
		BuildMapList();

	ASW_Mission_Chooser_Mission* pCampaign = GetCampaign( iCampaignIndex );
	if ( !pCampaign )
		return;

	KeyValues *pCampaignDetails = GetCampaignDetails( pCampaign->m_szMissionName );
	if ( !pCampaignDetails )
		return;

	CUtlVector<KeyValues*> aMissionKeys;
	bool bSkippedFirst = false;
	for ( KeyValues *pMission = pCampaignDetails->GetFirstSubKey(); pMission; pMission = pMission->GetNextKey() )
	{
		if ( !Q_stricmp( pMission->GetName(), "MISSION" ) )
		{
			if ( !bSkippedFirst )
			{
				bSkippedFirst = true;
			}
			else
			{
				aMissionKeys.AddToTail( pMission );
			}
		}
	}
	
	int max_items = aMissionKeys.Count();
	for ( int stored=0;stored<iNumSlots;stored++ )
	{
		int realoffset = nMissionOffset;
		if ( realoffset >= max_items || realoffset < 0 )
		{
			// no more missions...
			Q_snprintf( m_missions[stored].m_szMissionName, sizeof( m_missions[stored].m_szMissionName ), "" );
		}
		else
		{
			Q_snprintf( m_missions[stored].m_szMissionName, sizeof( m_missions[stored].m_szMissionName ), "%s", aMissionKeys[realoffset]->GetString( "MapName" ) );
		}
		nMissionOffset++;
	}
}
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
void CAI_Expresser::TestAllResponses()
{
	IResponseSystem *pResponseSystem = GetOuter()->GetResponseSystem();
	if ( pResponseSystem )
	{
		CUtlVector<AI_Response *> responses;
		pResponseSystem->GetAllResponses( &responses );
		for ( int i = 0; i < responses.Count(); i++ )
		{
			char response[ 256 ];
			responses[i]->GetResponse( response, sizeof( response ) );

			Msg( "Response: %s\n", response );
			SpeakDispatchResponse( "", responses[i] );
		}
	}
}
Esempio n. 5
0
//-----------------------------------------------------------------------------
// Computes the lighting origin
//-----------------------------------------------------------------------------
static bool ComputeLightingOrigin( StaticPropBuild_t const& build, Vector& lightingOrigin )
{
	for (int i = s_LightingInfo.Count(); --i >= 0; )
	{
		int entIndex = s_LightingInfo[i];

		// Check against all lighting info entities
		char const* pTargetName = ValueForKey( &entities[entIndex], "targetname" );
		if (!Q_strcmp(pTargetName, build.m_pLightingOrigin))
		{
			GetVectorForKey( &entities[entIndex], "origin", lightingOrigin );
			return true;
		}
	}

	return false;
}
Esempio n. 6
0
void C_CFPlayer::ShowHandMagic(C_BaseEntity* pEnt, CUtlVector<CNewParticleEffect*>& aHandComboEffects, element_t eElements, const char* pszAttachment)
{
	MDLCACHE_CRITICAL_SECTION();
	int i;
	for (i = 0; i < aHandComboEffects.Count(); i++)
		pEnt->ParticleProp()->StopEmission(aHandComboEffects[i]);

	aHandComboEffects.RemoveAll();

	for (i = 0; i < TOTAL_ELEMENTS; i++)
	{
		if (!(eElements&(1<<i)))
			continue;

		aHandComboEffects.AddToTail(pEnt->ParticleProp()->Create( VarArgs("hand_%s", ElementToString((element_t)(1<<i))), PATTACH_POINT_FOLLOW, pszAttachment ));
	}
}
Esempio n. 7
0
int CUtlVector<T, A>::AddVectorToTail(CUtlVector const &src)
{
    assert(&src != this);

    int base = Count();

    // Make space.
    int nSrcCount = src.Count();
    EnsureCapacity(base + nSrcCount);

    // Copy the elements.	
    m_Size += nSrcCount;
    for(int i = 0; i < nSrcCount; i++) {
        CopyConstruct(&Element(base + i), src[i]);
    }
    return base;
}
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void ParseParticleEffects( bool bLoadSheets )
{
	MEM_ALLOC_CREDIT();

	g_pParticleSystemMgr->ShouldLoadSheets( bLoadSheets );

	CUtlVector<CUtlString> files;
	GetParticleManifest( files );

	int nCount = files.Count();
	for ( int i = 0; i < nCount; ++i )
	{
		g_pParticleSystemMgr->ReadParticleConfigFile( files[i], false, false );
	}

	g_pParticleSystemMgr->DecommitTempMemory();
}
Esempio n. 9
0
	virtual void OnDragFailed( CUtlVector< KeyValues * >& msglist )
	{
		PropertySheet *sheet = IsDroppingSheet( msglist );
		if ( !sheet )
			return;

		// Create a new property sheet
		if ( m_pParent->IsDraggableTab() )
		{
			if ( msglist.Count() == 1 )
			{
				KeyValues *data = msglist[ 0 ];
                int screenx = data->GetInt( "screenx" );
				int screeny = data->GetInt( "screeny" );

				// m_pParent->ScreenToLocal( screenx, screeny );
				if ( !m_pParent->IsWithin( screenx, screeny ) )
				{
					Panel *page = reinterpret_cast< Panel * >( data->GetPtr( "propertypage" ) );
					PropertySheet *sheet = reinterpret_cast< PropertySheet * >( data->GetPtr( "propertysheet" ) );
					char const *title = data->GetString( "tabname", "" );
					if ( !page || !sheet )
						return;
					
					// Can only create if sheet was part of a ToolWindow derived object
					ToolWindow *tw = dynamic_cast< ToolWindow * >( sheet->GetParent() );
					if ( tw )
					{
						IToolWindowFactory *factory = tw->GetToolWindowFactory();
						if ( factory )
						{
							bool hasContextMenu = sheet->PageHasContextMenu( page );
							sheet->RemovePage( page );
							factory->InstanceToolWindow( tw->GetParent(), sheet->ShouldShowContextButtons(), page, title, hasContextMenu );

							if ( sheet->GetNumPages() == 0 )
							{
								tw->MarkForDeletion();
							}
						}
					}
				}
			}
		}
	}
void CSlideshowDisplayScreen::Update( C_SlideshowDisplay *pSlideshowDisplay )
{
	char szBuff[ 256 ];
	pSlideshowDisplay->GetDisplayText( szBuff );
	m_pDisplayTextLabel->SetText( szBuff );

	if ( m_pSlideshowImages.Count() == 0 )
	{
		// Build the list of image panels!
		for ( int iSlide = 0; iSlide < pSlideshowDisplay->NumMaterials(); ++iSlide )
		{
			m_pSlideshowImages.AddToTail( SETUP_PANEL( new ImagePanel( this, "SlideshowImage" ) ) );

			int iMatIndex = pSlideshowDisplay->GetMaterialIndex( iSlide );

			if ( iMatIndex > 0 )
			{
				const char *pMaterialName = GetMaterialNameFromIndex( iMatIndex );
				if ( pMaterialName )
				{
					pMaterialName = Q_strnchr( pMaterialName, '/', Q_strlen( pMaterialName ) );

					if ( pMaterialName )
					{
						pMaterialName = pMaterialName + 1;
						m_pSlideshowImages[ iSlide ]->SetImage( pMaterialName );
						m_pSlideshowImages[ iSlide ]->SetVisible( false );
						m_pSlideshowImages[ iSlide ]->SetZPos( -3 );
						m_pSlideshowImages[ iSlide ]->SetWide( GetWide() );
						m_pSlideshowImages[ iSlide ]->SetTall( GetTall() );
					}
				}
			}
		}
	}

	int iCurrentSlideIndex = pSlideshowDisplay->CurrentSlideIndex();

	if ( iCurrentSlideIndex != iLastSlideIndex )
	{
		m_pSlideshowImages[ iLastSlideIndex ]->SetVisible( false );
		m_pSlideshowImages[ iCurrentSlideIndex ]->SetVisible( true );
		iLastSlideIndex = iCurrentSlideIndex;
	}
}
Esempio n. 11
0
//-----------------------------------------------------------------------------
// Invokes a method on all installed game systems in proper order
//-----------------------------------------------------------------------------
void InvokeMethodTickProgress( GameSystemFunc_t f, char const *timed /*=0*/ )
{
	NOTE_UNUSED( timed );

	int i;
	int c = s_GameSystems.Count();
	for ( i = 0; i < c ; ++i )
	{
		IGameSystem *sys = s_GameSystems[i];

		MDLCACHE_COARSE_LOCK();
		MDLCACHE_CRITICAL_SECTION();
#if defined( CLIENT_DLL )
		engine->TickProgressBar();
#endif
		(sys->*f)();
	}
}
Esempio n. 12
0
//-----------------------------------------------------------------------------
// Purpose: Returns true if all handlers say we can quit the engine
//-----------------------------------------------------------------------------
bool CEngineTool::CanQuit()
{
	int c = m_QuitHandlers.Count();
	for ( int i = 0; i < c; ++i )
	{
		QuitHandler_t& qh = m_QuitHandlers[ i ];
		FnQuitHandler func = qh.func;
		if ( func )
		{
			if ( !func( qh.userdata ) )
			{
				return false;
			}
		}
	}

	return true;
}
Esempio n. 13
0
//-----------------------------------------------------------------------------
// Purpose: Computes the crc for all sendtables for the data sent in the class/table definitions
// Output : CRC32_t
//-----------------------------------------------------------------------------
CRC32_t SendTable_ComputeCRC()
{
	CRC32_t result;
	CRC32_Init( &result );

	// walk the tables and checksum them
	int c = g_SendTables.Count();
	for ( int i = 0 ; i < c; i++ )
	{
		SendTable *st = g_SendTables[ i ];
		result = SendTable_CRCTable( result, st );
	}


	CRC32_Final( &result );

	return result;
}
Esempio n. 14
0
disp_grid_t &FindOrInsertGrid( int gridIndex )
{
	// linear search is slow, but only a few grids will be present
	for ( int i = gDispGridList.Count()-1; i >= 0; i-- )
	{
		if ( gDispGridList[i].gridIndex == gridIndex )
		{
			return gDispGridList[i];
		}
	}
	int index = gDispGridList.AddToTail();
	gDispGridList[index].gridIndex = gridIndex;

	// must be empty
	Assert( gDispGridList[index].dispList.Count() == 0 );

	return gDispGridList[index];
}
Esempio n. 15
0
void C_SceneEntity::QueueStartEvent( float starttime, CChoreoScene *scene, CChoreoEvent *event )
{
	// Check for duplicates
	int c = m_QueuedEvents.Count();
	for ( int i = 0; i < c; ++i )
	{
		const QueuedEvents_t& check = m_QueuedEvents[ i ];
		if ( check.scene == scene && 
			 check.event == event )
			return;
	}

	QueuedEvents_t qe;
	qe.scene = scene;
	qe.event = event;
	qe.starttime = starttime;
	m_QueuedEvents.AddToTail( qe );
}
Esempio n. 16
0
int Open( lua_State *L )
{
	CByteScanner luaSharedScanner( LUA_SHARED_LIBRARY );

	// Scan & hook if this is the first state loading the module
	if ( g_LuaInterfaces.Count() == 0 )
	{
		if ( luaSharedScanner.FindCodePattern( CLuaInterface_ErrorFromLua_Signature, CLuaInterface_ErrorFromLua_Mask, (LPVOID *)&CLuaInterface_Hooks::ErrorFromLua_T ) )
			CLuaInterface_ErrorFromLua_Detour.Attach();
		else
			Lua()->ErrorNoHalt( "[gm_luaerror] CLuaInterface::ErrorFromLua signature scan failed. Please report this error.\n" );
	}
	
	// Store state
	g_LuaInterfaces.AddToTail( Lua() );

	return 0;
}
Esempio n. 17
0
bool CFuncAreaPortalWindow::IsWindowOpen( const CUtlVector< Vector > &vecOrigins, float fovDistanceAdjustFactor )
{
	float flClosestDistance = FLT_MAX;
	for ( int i = 0; i < vecOrigins.Count(); ++i )
	{
		float flDist = CollisionProp()->CalcDistanceFromPoint( vecOrigins[ i ] );
		if ( flDist < flClosestDistance )
		{
			flClosestDistance = flDist;
		}
	}

	if ( flClosestDistance == FLT_MAX )
		return false;

	flClosestDistance *= fovDistanceAdjustFactor;
	return ( flClosestDistance <= (m_flFadeDist + FADE_DIST_BUFFER) );
}
Esempio n. 18
0
DWORD WINAPI PortalMCThreadFn( LPVOID p )
{
	CUtlVector<char> data;
	data.SetSize( portalbytes + 128 );

	DWORD waitTime = 0;
	while ( WaitForSingleObject( g_MCThreadExitEvent.GetEventHandle(), waitTime ) != WAIT_OBJECT_0 )
	{
		CIPAddr ipFrom;
		int len = g_pPortalMCSocket->RecvFrom( data.Base(), data.Count(), &ipFrom );
		if ( len == -1 )
		{
			waitTime = 20;
		}
		else
		{
			// These lengths must match exactly what is sent in ReceivePortalFlow.
			if ( len == 2 + sizeof( g_PortalMCThreadUniqueID ) + sizeof( int ) + portalbytes )
			{
				// Perform more validation...
				if ( data[0] == VMPI_VVIS_PACKET_ID && data[1] == VMPI_PORTALFLOW_RESULTS )
				{
					if ( *((unsigned long*)&data[2]) == g_PortalMCThreadUniqueID )
					{
						int iWorkUnit = *((int*)&data[6]);
						if ( iWorkUnit >= 0 && iWorkUnit < g_numportals*2 )
						{
							portal_t *p = sorted_portals[iWorkUnit];
							if ( p )
							{
								++g_nMulticastPortalsReceived;
								memcpy( p->portalvis, &data[10], portalbytes );
								p->status = stat_done;
								waitTime = 0;
							}
						}
					}
				}
			}
		}
	}
	
	return 0;
}
Esempio n. 19
0
    bool SaveItem(specialitemload_t const &item)
    {
        unsigned long long profileid = item.steamid.ConvertToUint64();

        item.itemmutex->Lock();
        unsigned int index = item.itemlist->Find(profileid);
        if(item.itemlist->IsValidIndex(index))
        {
            char query[1024];
            char petname[512];

            CUtlVector<CSpecialItem *> *items = item.itemlist->Element(index);
            item.itemmutex->Unlock();

            //Msg("[ITEMDBG] Saving/deleting old item list.\n");
            for(int i = 0; i < items->Count(); i++)
            {
                //Msg("[ITEMDBG]  - Saving/deleting item %i\n", i);
                item.itemmutex->Lock();
                CSpecialItem *olditem = items->Element(i);

                m_SQL->EscapeString(petname, olditem->m_szPetName, strlen(olditem->m_szPetName));
                
                V_snprintf(query, sizeof(query), "UPDATE `specialitems` SET `petname` = '%s', `equipped` = %i WHERE `id` = %i LIMIT 1", petname, olditem->m_bEquipped, olditem->m_iIndex);
                item.itemmutex->Unlock();
                //Msg("[ITEMDBG] %s\n", query);
                m_SQL->Query(query);
                
                delete olditem->m_pItem;
                delete olditem;
            }

            item.itemmutex->Lock();
            item.itemlist->RemoveAt(index);
            item.itemmutex->Unlock();
            delete items;
        }
        else
        {
            item.itemmutex->Unlock();
        }

        return true;
    }
Esempio n. 20
0
//-----------------------------------------------------------------------------
// Purpose: loads per-map manifest!
//-----------------------------------------------------------------------------
void ParseParticleEffectsMap( const char *pMapName, bool bLoadSheets )
{
	MEM_ALLOC_CREDIT();

	g_pParticleSystemMgr->ShouldLoadSheets( bLoadSheets );

	CUtlVector<CUtlString> files;

	const char *mapManifestFilename = NULL;
	if ( pMapName && *pMapName )
	{
#ifdef CLIENT_DLL
#define UTIL_VarArgs VarArgs //Tony; goddamnit.
#endif
		mapManifestFilename = UTIL_VarArgs( "particles/particles_%s.txt", pMapName );
	}

	// Open the manifest file, and read the particles specified inside it
	KeyValues *manifest = new KeyValues( mapManifestFilename );
	if ( manifest->LoadFromFile( filesystem, mapManifestFilename, "GAME" ) )
	{
		for ( KeyValues *sub = manifest->GetFirstSubKey(); sub != NULL; sub = sub->GetNextKey() )
		{
			if ( !Q_stricmp( sub->GetName(), "file" ) )
			{
				files.AddToTail( sub->GetString() );
				continue;
			}

			Warning( "CParticleMgr::LevelInit:  Manifest '%s' with bogus file type '%s', expecting 'file'\n", mapManifestFilename, sub->GetName() );
		}
	}
	else
		//Tony; don't print a warning, and don't proceed any further if the file doesn't exist!
		return;

	int nCount = files.Count();
	for ( int i = 0; i < nCount; ++i )
	{
		g_pParticleSystemMgr->ReadParticleConfigFile( files[i], true, true );
	}

	g_pParticleSystemMgr->DecommitTempMemory();
}
Esempio n. 21
0
// look for dead/spectating players in our volume, to call touch on
void CTriggerSoundscape::PlayerUpdateThink()
{
	int i;
	SetNextThink( gpGlobals->curtime + 0.2 );

	CUtlVector<CBasePlayerHandle> oldSpectators;
	oldSpectators = m_spectators;
	m_spectators.RemoveAll();

	for ( i=1; i <= gpGlobals->maxClients; ++i )
	{
		CBasePlayer *player = UTIL_PlayerByIndex( i );

		if ( !player )
			continue;

		if ( player->IsAlive() )
			continue;

		// if the spectator is intersecting the trigger, track it, and start a touch if it is just starting to touch
		if ( Intersects( player ) )
		{
			if ( !oldSpectators.HasElement( player ) )
			{
				StartTouch( player );
			}
			m_spectators.AddToTail( player );
		}
	}

	// check for spectators who are no longer intersecting
	for ( i=0; i<oldSpectators.Count(); ++i )
	{
		CBasePlayer *player = oldSpectators[i];

		if ( !player )
			continue;

		if ( !m_spectators.HasElement( player ) )
		{
			EndTouch( player );
		}
	}
}
Esempio n. 22
0
//-----------------------------------------------------------------------------
// Purpose: Shuts down all tools
// Input  :  - 
//-----------------------------------------------------------------------------
void CToolFrameworkInternal::ShutdownTools()
{
	// Deactivate tool
	SwitchToTool( -1 );

	// Reverse order
	int i;
	int toolCount = m_ToolSystems.Count();
	for ( i = toolCount - 1; i >= 0; --i )
	{
		IToolSystem *system = m_ToolSystems[ i ];
		system->Shutdown();
	}

	m_ToolSystems.RemoveAll();

	ShutdownToolDictionaries();
	ShutdownModules();
}
Esempio n. 23
0
//--------------------------------------------------------------------------------------------------------
// Reevaluate all func_nav_cost entities and update the nav decoration accordingly.
// This is required to handle overlapping func_nav_cost entities.
void CFuncNavCost::UpdateAllNavCostDecoration( void )
{
	int i, j;

	// first, clear all avoid decoration from the mesh
	for( i=0; i<TheNavAreas.Count(); ++i )
	{
		TheNavAreas[i]->ClearAllNavCostEntities();
	}

	// now, mark all areas with active cost entities overlapping them
	for( i=0; i<gm_masterCostVector.Count(); ++i )
	{
		CFuncNavCost *cost = gm_masterCostVector[i];

		if ( !cost || !cost->IsEnabled() )
		{
			continue;
		}

		Extent extent;
		extent.Init( cost );

		CUtlVector< CNavArea * > overlapVector;
		TheNavMesh->CollectAreasOverlappingExtent( extent, &overlapVector );

		Ray_t ray;
		trace_t tr;
		ICollideable *pCollide = cost->CollisionProp();

		for( j=0; j<overlapVector.Count(); ++j )
		{
			ray.Init( overlapVector[j]->GetCenter(), overlapVector[j]->GetCenter() );

			enginetrace->ClipRayToCollideable( ray, MASK_ALL, pCollide, &tr );
			
			if ( tr.startsolid )
			{
				overlapVector[j]->AddFuncNavCostEntity( cost );
			}
		}
	}
}
Esempio n. 24
0
//-----------------------------------------------------------------------------
// Purpose: Run through all the Bots in the game and let them think.
//-----------------------------------------------------------------------------
void Bot_RunAll( void )
{
	if ( !botmanager )
		return;

	for ( int i = 0; i < s_Bots.Count(); i++ )
	{
		CPluginBot & bot = s_Bots[i];
		if ( bot.m_BotEdict->IsFree() || !bot.m_BotEdict->GetUnknown()|| !bot.m_PlayerInfo->IsConnected() )
		{
			s_Bots.Remove(i);
			--i;
		}
		else
		{
			Bot_Think( &bot );
		}
	}
}
bool CMoveHelperClient::AddToTouched( const trace_t& tr, const Vector& impactvelocity )
{
	int i;

	// Look for duplicates
	for (i = 0; i < m_TouchList.Count(); i++)
	{
		if (m_TouchList[i].trace.m_pEnt == tr.m_pEnt)
		{
			return false;
		}
	}

	i = m_TouchList.AddToTail();
	m_TouchList[i].trace = tr;
	VectorCopy( impactvelocity, m_TouchList[i].deltavelocity );

	return true;
}
void CStaticPropMgr::LevelShutdownClient()
{
	if ( !m_bClientInitialized )
		return;

	Assert( m_bLevelInitialized );

	for (int i = m_StaticProps.Count(); --i >= 0; )
	{
		m_StaticProps[i].CleanUpRenderHandle( );
	}

#ifndef SWDS
	// Make sure static prop lightcache is reset
	ClearStaticLightingCache();
#endif

	m_bClientInitialized = false;
}
Esempio n. 27
0
//-----------------------------------------------------------------------------
// Invokes a method on all installed game systems in reverse order
//-----------------------------------------------------------------------------
void InvokeMethodReverseOrder( GameSystemFunc_t f )
{
	int i;
	int c = s_GameSystems.Count();
	for ( i = c; --i >= 0; )
	{
		IGameSystem *sys = s_GameSystems[i];
#if (VPROF_LEVEL > 0) && defined(VPROF_ACCOUNT_GAMESYSTEMS)   // make sure each game system is individually attributed
		// because vprof nodes must really be constructed with a pointer to a static
		// string, we can't create a temporary char[] here and sprintf a distinctive
		// V_snprintf( buf, 63, "gamesys_preframe_%s", sys->Name() ). We'll have to
		// settle for just the system name, and distinguish between pre and post frame
		// in hierarchy.
		VPROF( sys->Name() );
#endif
		MDLCACHE_CRITICAL_SECTION();
		(sys->*f)();
	}
}
//-----------------------------------------------------------------------------
// Purpose: Frees all the template data. Called on level shutdown.
//-----------------------------------------------------------------------------
void Templates_RemoveAll(void)
{
	int nCount = g_Templates.Count();
	for (int i = 0; i < nCount; i++)
	{
		TemplateEntityData_t *pTemplate = g_Templates.Element(i);

		free((void *)pTemplate->pszName);
		free(pTemplate->pszMapData);
		if ( pTemplate->pszFixedMapData )
		{
			free(pTemplate->pszFixedMapData);
		}

		free(pTemplate);
	}

	g_Templates.RemoveAll();
}
//-----------------------------------------------------------------------------
// Purpose: Locks object and adds wavefile to thread
// Input  : *wavefile - 
//-----------------------------------------------------------------------------
void CFileLoaderThread::AddWaveFilesToThread( CUtlVector< CWaveFile * >& wavefiles )
{
	Lock();

	int c = wavefiles.Count();
	for ( int i = 0; i < c; i++ )
	{
		SentenceRequest *request = new SentenceRequest;
		request->wavefile = wavefiles[ i ];
		Q_strncpy( request->filename, request->wavefile->GetFileName(), sizeof( request->filename ) );
	

		m_FileList.AddToTail( request );

		m_nTotalAdds++;
	}

	Unlock();
}
IMaterialVar *CMaterialSubRect::FindVarFast( char const *pVarName, unsigned int *pToken )
{
	// Look for the var in the material page - it has precedence.
	IMaterialVar *pVar = m_pMaterialPage->FindVarFast( pVarName, pToken );
	if ( pVar )
		return pVar;

	if ( *pToken != UTL_INVAL_SYMBOL )
	{
		int nVarCount = m_aMaterialVars.Count();
		for ( int iVar = 0; iVar < nVarCount; ++iVar )
		{
			if ( m_aMaterialVars[iVar]->GetNameAsSymbol() == *pToken )
				return m_aMaterialVars[iVar];
		}
	}

	return NULL;
}