//----------------------------------------------------------------------------- // //----------------------------------------------------------------------------- void CDmeSingleIndexedComponent::GetComponents( CUtlVector< int > &components, CUtlVector< float > &weights ) const { if ( IsComplete() ) { const int nComponents = Count(); int *pComponents = reinterpret_cast< int * >( alloca( nComponents * sizeof( int ) ) ); float *pWeights = reinterpret_cast< float * >( alloca( nComponents * sizeof( float ) ) ); for ( int i = 0; i < nComponents; ++i ) { pComponents[ i ] = i; pWeights[ i ] = 1.0f; } components.CopyArray( pComponents, nComponents ); weights.CopyArray( pWeights, nComponents ); } else { components.RemoveAll(); components.CopyArray( m_Components.Base(), m_Components.Count() ); weights.RemoveAll(); weights.CopyArray( m_Weights.Base(), m_Weights.Count() ); } }
void CompactTexdataArray( texdatamap_t *pMap ) { CUtlVector<char> oldStringData; oldStringData.CopyArray( g_TexDataStringData.Base(), g_TexDataStringData.Count() ); g_TexDataStringData.RemoveAll(); CUtlVector<int> oldStringTable; oldStringTable.CopyArray( g_TexDataStringTable.Base(), g_TexDataStringTable.Count() ); g_TexDataStringTable.RemoveAll(); CUtlVector<dtexdata_t> oldTexData; oldTexData.CopyArray( dtexdata, numtexdata ); // clear current table and rebuild numtexdata = 0; for ( int i = 0; i < oldTexData.Count(); i++ ) { // unreferenced, note in map and skip if ( !pMap[i].refCount ) { pMap[i].outputIndex = -1; continue; } pMap[i].outputIndex = numtexdata; // get old string and re-add to table const char *pString = &oldStringData[oldStringTable[oldTexData[i].nameStringTableID]]; int nameIndex = TexDataStringTable_AddOrFindString( pString ); // copy old texdata and fixup with new name in compacted table dtexdata[numtexdata] = oldTexData[i]; dtexdata[numtexdata].nameStringTableID = nameIndex; numtexdata++; } }
int CMySQL::Execute( const char *pString ) { CancelIteration(); int result = mysql_query( m_pSQL, pString ); if ( result == 0 ) { // Is this a query with a result set? m_pResult = mysql_store_result( m_pSQL ); if ( m_pResult ) { // Store the field information. int count = mysql_field_count( m_pSQL ); MYSQL_FIELD *pFields = mysql_fetch_fields( m_pResult ); m_Fields.CopyArray( pFields, count ); return 0; } else { // No result set. Was a set expected? if ( mysql_field_count( m_pSQL ) != 0 ) return 1; // error! The query expected data but didn't get it. } } else { const char *pError = mysql_error( m_pSQL ); pError = pError; } return result; }
bool SendTable_Init( SendTable **pTables, int nTables ) { ErrorIfNot( g_SendTables.Count() == 0, ("SendTable_Init: called twice.") ); // Initialize them all. for ( int i=0; i < nTables; i++ ) { if ( !SendTable_InitTable( pTables[i] ) ) return false; } // Store off the SendTable list. g_SendTables.CopyArray( pTables, nTables ); g_SendTableCRC = SendTable_ComputeCRC( ); if ( CommandLine()->FindParm("-dti" ) ) { SendTable_PrintStats(); } return true; }
bool CRunTimeKeyValuesStringTable::ReadStringTable( int numStrings, CUtlBuffer& buf ) { Assert( m_Strings.Count() == 0 ); CUtlVector< int > offsets; offsets.EnsureCapacity( numStrings ); offsets.CopyArray( (int *)( buf.PeekGet() ), numStrings ); // Skip over data buf.SeekGet( CUtlBuffer::SEEK_HEAD, buf.TellGet() + numStrings * sizeof( int ) ); int stringSize = buf.GetInt(); // Read in the string table m_Strings.EnsureCapacity( numStrings ); int i; for ( i = 0 ; i < numStrings; ++i ) { m_Strings.AddToTail( (const char *)buf.PeekGet( offsets[ i ] ) ); } buf.SeekGet( CUtlBuffer::SEEK_HEAD, buf.TellGet() + stringSize ); return true; }
// Handle VRAD packets. bool VRAD_DispatchFn( MessageBuffer *pBuf, int iSource, int iPacketID ) { switch( pBuf->data[1] ) { case VMPI_SUBPACKETID_PLIGHTDATA_RESULTS: { const char *pFilename = &pBuf->data[2]; g_LightResultsFilename.CopyArray( pFilename, strlen( pFilename ) + 1 ); return true; } default: return false; } }
// Handle VVIS packets. bool VVIS_DispatchFn( MessageBuffer *pBuf, int iSource, int iPacketID ) { switch ( pBuf->data[1] ) { case VMPI_SUBPACKETID_MC_ADDR: { pBuf->setOffset( 2 ); pBuf->read( &g_PortalMCAddr, sizeof( g_PortalMCAddr ) ); g_bGotMCAddr = true; return true; } case VMPI_SUBPACKETID_DISCONNECT_NOTIFY: { // This is just used to cause nonblocking dispatches to jump out so loops like the one // in AppBarrier can handle the fact that there are disconnects. return true; } case VMPI_SUBPACKETID_BASEPORTALVIS_SYNC: { g_bBasePortalVisSync = true; return true; } case VMPI_SUBPACKETID_PORTALFLOW_SYNC: { g_bPortalFlowSync = true; return true; } case VMPI_BASEPORTALVIS_RESULTS: { const char *pFilename = &pBuf->data[2]; g_BasePortalVisResultsFilename.CopyArray( pFilename, strlen( pFilename ) + 1 ); return true; } default: { return false; } } }
bool CVRadDLL::DoIncrementalLight( char const *pVMFFile ) { char tempPath[MAX_PATH], tempFilename[MAX_PATH]; GetTempPath( sizeof( tempPath ), tempPath ); GetTempFileName( tempPath, "vmf_entities_", 0, tempFilename ); FileHandle_t fp = g_pFileSystem->Open( tempFilename, "wb" ); if( !fp ) return false; g_pFileSystem->Write( pVMFFile, strlen(pVMFFile)+1, fp ); g_pFileSystem->Close( fp ); // Parse the new entities. if( !LoadEntsFromMapFile( tempFilename ) ) return false; // Create lights. CreateDirectLights(); // set up sky cameras ProcessSkyCameras(); g_bInterrupt = false; if( RadWorld_Go() ) { // Save off the last finished lighting results for the BSP. g_LastGoodLightData.CopyArray( pdlightdata->Base(), pdlightdata->Count() ); if( g_pIncremental ) g_pIncremental->GetFacesTouched( g_FacesTouched ); return true; } else { g_iCurFace = 0; return false; } }
// Remove all unused texinfos and rebuild array void ComapctTexinfoArray( texinfomap_t *pMap ) { CUtlVector<texinfo_t> old; old.CopyArray( texinfo.Base(), texinfo.Count() ); texinfo.RemoveAll(); int firstSky = -1; int first2DSky = -1; for ( int i = 0; i < old.Count(); i++ ) { if ( !pMap[i].refCount ) { pMap[i].outputIndex = -1; continue; } // only add one sky texinfo + one 2D sky texinfo if ( old[i].flags & SURF_SKY2D ) { if ( first2DSky < 0 ) { first2DSky = texinfo.AddToTail( old[i] ); } pMap[i].outputIndex = first2DSky; continue; } if ( old[i].flags & SURF_SKY ) { if ( firstSky < 0 ) { firstSky = texinfo.AddToTail( old[i] ); } pMap[i].outputIndex = firstSky; continue; } pMap[i].outputIndex = texinfo.AddToTail( old[i] ); } }