virtual int Run() { while ( true ) { WaitForCall(); if ( GetCallParam() == MBC_SHUTDOWN ) { // exit cleanly return 0; } else { #ifdef SUPPORT_VBSP_2 char filename[MAX_PATH]; // Safe to access m_szVBSP2MapName because it will not be changed by the main thread while this is happening. Q_snprintf( filename, sizeof( filename ), "maps\\%s", m_pMapBuilder->m_szVBSP2MapName ); CSimpleMapFile *pSimpleMapFile; m_pMapBuilder->m_nVBSP2Progress = g_ProgressAmounts[1]; CSimpleMapFile::LoadFromFile( g_pFullFileSystem, filename, &pSimpleMapFile ); m_pMapBuilder->m_nVBSP2Progress = g_ProgressAmounts[2]; pSimpleMapFile->ResolveInstances( CSimpleMapFile::CONVERT_STRUCTURAL_TO_DETAIL, FixupInstance, m_pMapBuilder ); m_pMapBuilder->m_nVBSP2Progress = g_ProgressAmounts[3]; // mess with the pSimpleMapFile here /* CMapLayout *pLayout = m_pMapBuilder->GetCurrentlyBuildingMapLayout(); // find the alien floor texture int iBrushes = pSimpleMapFile->GetBrushCount(); const MapBrush_t *pBrushes = pSimpleMapFile->GetBrushes(); const MapBrushSide_t *pBrushSides = pSimpleMapFile->GetBrushSides(); MapTextureInfo_t *pTextureInfos = pSimpleMapFile->GetTextureInfos(); MapTextureData_t *pTextureDatas = pSimpleMapFile->GetTextureData(); const MapTextureInfo_t *pAlienFloorTextureInfo = NULL; // a texture info that's using the alien floor material for ( int i = 0; i < iBrushes; i++ ) { for ( int side = pBrushes[i].m_nFirstSideIndex; side < pBrushes[i].m_nFirstSideIndex + pBrushes[i].m_nNumSides; side++ ) { const MapTextureInfo_t *pTextureInfo = &pTextureInfos[ pBrushSides[ side ].m_nTextureInfoIndex ]; const MapTextureData_t *pTextureData = &pTextureDatas[ pTextureInfo->m_nTextureDataIndex ]; if ( !Q_stricmp( pTextureData->m_MaterialName, asw_alien_floor_texture.GetString() ) ) { pAlienFloorTextureInfo = pTextureInfo; break; } } } if ( pAlienFloorTextureInfo ) { // now find all sides using the regular floor texture for ( int i = 0; i < iBrushes; i++ ) { // is this brush in an encounter room? - just check the center for now Vector vecCenter = ( pBrushes[i].m_vMinBounds + pBrushes[i].m_vMaxBounds ) * 0.5f; CRoom *pRoom = pLayout->GetRoom( vecCenter ); if ( !pRoom || !pRoom->HasAlienEncounter() ) continue; for ( int side = pBrushes[i].m_nFirstSideIndex; side < pBrushes[i].m_nFirstSideIndex + pBrushes[i].m_nNumSides; side++ ) { MapTextureInfo_t *pTextureInfo = &pTextureInfos[ pBrushSides[ side ].m_nTextureInfoIndex ]; MapTextureData_t *pTextureData = &pTextureDatas[ pTextureInfo->m_nTextureDataIndex ]; if ( !Q_stricmp( pTextureData->m_MaterialName, asw_regular_floor_texture.GetString() ) ) { // switch regular floor over to using the new texture index pTextureInfo->m_nTextureDataIndex = pAlienFloorTextureInfo->m_nTextureDataIndex; } } } } else { Warning( "Couldn't find alien floor texture in map\n" ); } */ // re-resolve if necessary //pSimpleMapFile->ResolveInstances( CSimpleMapFile::CONVERT_STRUCTURAL_TO_DETAIL, NULL, NULL ); char bspFilename[MAX_PATH]; Q_strncpy( bspFilename, filename, MAX_PATH ); Q_SetExtension( bspFilename, ".bsp", MAX_PATH ); CUtlStreamBuffer outputBSPFile( bspFilename, NULL ); CSimpleBSPFile *pBSPFile = new CSimpleBSPFile(); pBSPFile->CreateFromMapFile( pSimpleMapFile ); m_pMapBuilder->m_nVBSP2Progress = g_ProgressAmounts[4]; SaveToFile( &outputBSPFile, pBSPFile ); outputBSPFile.Close(); delete pBSPFile; delete pSimpleMapFile; // Commit all reads/writes before ending task ThreadMemoryBarrier(); m_pMapBuilder->m_nVBSP2Progress = g_ProgressAmounts[5]; Reply( 0 ); #else return 0; #endif } } return 0; }
bool CWorkerThread::WaitForCall(unsigned * pResult) { return WaitForCall(TT_INFINITE, pResult); }