//----------------------------------------------------------------------------- // Purpose: Constructor //----------------------------------------------------------------------------- void CSDK_Loading_Panel::Init( void ) { m_pBackdrop = new vgui::ImagePanel( this, "LoadingImage" ); m_pBackdrop->SetShouldScaleImage( true ); m_pBlackBar[0] = new vgui::Panel( this, "LoadingImageBlackBar0" ); m_pBlackBar[1] = new vgui::Panel( this, "LoadingImageBlackBar1" ); m_pDetailsPanel = new LoadingMissionDetailsPanel( this, "LoadingMissionDetailsPanel" ); m_pDetailsPanel->SetProportional( true ); m_pDetailsPanel->SetVisible( false ); // choose pic static char pics[14][64] = { "console/hl2wars_bg1_widescreen", /* //"swarm/loading/Loading_Vereon", "swarm/loading/Loading_Labs1", "swarm/loading/Loading_Labs2", "swarm/loading/Loading_LandingBay", "swarm/loading/Loading_Mine1", "swarm/loading/Loading_Mine2", "swarm/loading/Loading_Mine3", "swarm/loading/Loading_Office", "swarm/loading/Loading_Plant1", "swarm/loading/Loading_Plant2", "swarm/loading/Loading_Plant3", "swarm/loading/Loading_Sewers1", "swarm/loading/Loading_Sewers2", "swarm/loading/Loading_Sewers3", "swarm/loading/Loading_Sewers4"*/ }; int iChosen = RandomInt(0,13); Q_snprintf(m_szLoadingPic, sizeof(m_szLoadingPic), pics[iChosen]); ListenForGameEvent( "server_spawn" ); g_vecLoadingPanels.AddToTail( this ); }
int CASW_Marine_Hint_Manager::FindHints(const Vector &position, CASW_Marine *pLeader, const float flMinDistance, const float flMaxDistance, CUtlVector<HintData_t *> &result) { VPROF_BUDGET("CASW_Marine_Hint_Manager::FindHints", "SquadFormation"); Assert(pLeader); const float flMinDistSqr = Square(flMinDistance); const float flMaxDistSqr = Square(flMaxDistance); int nCount = m_Hints.Count(); for ( int i = 0; i < nCount; i++ ) { HintData_t *pHint = m_Hints[i]; float flDistSqr = position.DistToSqr(pHint->m_vecPosition); if (flDistSqr < flMinDistSqr || flDistSqr > flMaxDistSqr) { continue; } AI_Waypoint_t *pPath = pLeader->GetPathfinder()->BuildRoute(position, pHint->m_vecPosition, NULL, 0, NAV_GROUND, bits_BUILD_NO_LOCAL_NAV); if (!pPath) { continue; } pHint->m_flDistance = position.DistTo(pPath->GetPos()); AI_Waypoint_t *pCur = pPath; while (pCur->GetNext()) { AI_Waypoint_t *pNext = pCur->GetNext(); pHint->m_flDistance += pCur->GetPos().DistTo(pNext->GetPos()); pCur = pNext; } DeleteAll(pPath); if (pHint->m_flDistance > flMaxDistance) { continue; } result.AddToTail( pHint ); } return result.Count(); }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- Vector CEditorSystem::GetSelectionCenter() { if ( !IsAnythingSelected() ) { Assert( 0 ); return vec3_origin; } if ( m_bSelectionCenterLocked ) return m_vecSelectionCenterCache; CUtlVector< Vector > positions; FOR_EACH_VEC( m_hSelectedEntities, i ) { if( !m_hSelectedEntities[ i ] ) continue; positions.AddToTail( m_hSelectedEntities[ i ]->GetAbsOrigin() ); } if( positions.Count() == 0 ) { return m_vecSelectionCenterCache; } #if 1 // median Vector min, max; CalcBoundaries( positions.Base(), positions.Count(), min, max ); return min + ( max - min ) * 0.5f; #else // arth mean Vector center = vec3_origin; FOR_EACH_VEC( positions, i ) center += positions[ i ]; return center / positions.Count(); #endif }
void virtualmodel_t::AppendNodes( int group, const studiohdr_t *pStudioHdr ) { AUTO_LOCK_( CThreadTerminalMutex<CThreadFastMutex>, m_Lock ); int numCheck = m_node.Count(); CUtlVector< virtualgeneric_t > node; node = m_node; MEM_ALLOC_CREDIT(); int j, k; m_group[ group ].masterNode.SetCount( pStudioHdr->numlocalnodes ); for (j = 0; j < pStudioHdr->numlocalnodes; j++) { char *s1 = pStudioHdr->pszLocalNodeName( j ); for (k = 0; k < numCheck; k++) { char *s2 = m_group[ node[k].group ].GetStudioHdr()->pszLocalNodeName( node[k].index ); if (stricmp( s1, s2 ) == 0) { break; } } // no duplication if (k == numCheck) { virtualgeneric_t tmp; tmp.group = group; tmp.index = j; k = node.AddToTail( tmp ); } m_group[ group ].masterNode[ j ] = k; } m_node = node; }
//----------------------------------------------------------------------------- // Builds the list of all controls in the animation set contributing to facial animation //----------------------------------------------------------------------------- void CSFMGenApp::BuildFacialControlList( CDmeFilmClip *pShot, CDmeAnimationSet *pAnimationSet, CUtlVector< LogPreview_t > &list ) { const CDmaElementArray< CDmElement > &controls = pAnimationSet->GetControls(); int nCount = controls.Count(); for ( int i = 0; i < nCount; ++i ) { CDmElement *pControl = controls[i]; if ( !pControl || pControl->GetValue<bool>( "transform" ) ) continue; LogPreview_t preview; preview.m_hControl = pControl; preview.m_hShot = pShot; preview.m_bActiveLog = preview.m_bSelected = false; if ( pControl->GetValue< bool >( "combo" ) ) { preview.m_hChannels[ LOG_PREVIEW_VALUE ] = pControl->GetValueElement< CDmeChannel >( "valuechannel" ); preview.m_hChannels[ LOG_PREVIEW_BALANCE ] = pControl->GetValueElement< CDmeChannel >( "balancechannel" ); } else { preview.m_hChannels[ LOG_PREVIEW_VALUE ] = pControl->GetValueElement< CDmeChannel >( "channel" ); preview.m_hChannels[ LOG_PREVIEW_BALANCE ] = NULL; } if ( pControl->GetValue< bool >( "multi" ) ) { preview.m_hChannels[ LOG_PREVIEW_MULTILEVEL ] = pControl->GetValueElement< CDmeChannel >( "multilevelchannel" ); } else { preview.m_hChannels[ LOG_PREVIEW_MULTILEVEL ] = NULL; } preview.m_hOwner = preview.m_hChannels[ LOG_PREVIEW_VALUE ]->FindOwnerClipForChannel( pShot ); list.AddToTail( preview ); } }
static void ConvertWorldBrushesToPhysCollide( CUtlVector<CPhysCollisionEntry *> &collisionList, float shrinkSize, float mergeTolerance, int contentsMask ) { CPlaneList planes( shrinkSize, mergeTolerance ); planes.m_contentsMask = contentsMask; VisitLeaves_r( planes, dmodels[0].headnode ); planes.AddBrushes(); int count = planes.m_convex.Count(); if ( count ) { CPhysCollide *pCollide = physcollision->ConvertConvexToCollide( planes.m_convex.Base(), count ); ICollisionQuery *pQuery = physcollision->CreateQueryModel( pCollide ); int convex = pQuery->ConvexCount(); for ( int i = 0; i < convex; i++ ) { int triCount = pQuery->TriangleCount( i ); int brushIndex = pQuery->GetGameData( i ); Vector points[3]; for ( int j = 0; j < triCount; j++ ) { pQuery->GetTriangleVerts( i, j, points ); Vector normal = TriangleNormal( points[0], points[1], points[2] ); dbrushside_t *pside = FindBrushSide( brushIndex, normal ); if ( pside->texinfo != TEXINFO_NODE ) { int prop = g_SurfaceProperties[texinfo[pside->texinfo].texdata]; pQuery->SetTriangleMaterialIndex( i, j, RemapWorldMaterial( prop ) ); } } } physcollision->DestroyQueryModel( pQuery ); pQuery = NULL; collisionList.AddToTail( new CPhysCollisionEntryStaticSolid( pCollide, contentsMask ) ); } }
//----------------------------------------------------------------------------- // Purpose: Calls the autocompletion method to get autocompletion suggestions //----------------------------------------------------------------------------- int ConCommand::AutoCompleteSuggest( const char *partial, CUtlVector< CUtlString > &commands ) { if ( m_bUsingCommandCallbackInterface ) { if ( !m_pCommandCompletionCallback ) return 0; return m_pCommandCompletionCallback->CommandCompletionCallback( partial, commands ); } Assert( m_fnCompletionCallback ); if ( !m_fnCompletionCallback ) return 0; char rgpchCommands[ COMMAND_COMPLETION_MAXITEMS ][ COMMAND_COMPLETION_ITEM_LENGTH ]; int iret = ( m_fnCompletionCallback )( partial, rgpchCommands ); for ( int i = 0 ; i < iret; ++i ) { CUtlString str = rgpchCommands[ i ]; commands.AddToTail( str ); } return iret; }
// Called by the ImpactSound function. void ShotgunImpactSoundGroup( const char *pSoundName, const Vector &vEndPos ) { // Don't play the sound if it's too close to another impact sound. for ( int i=0; i < g_GroupedSounds.Count(); i++ ) { CGroupedSound *pSound = &g_GroupedSounds[i]; if ( vEndPos.DistToSqr( pSound->m_vPos ) < 300*300 ) { if ( Q_stricmp( pSound->m_SoundName, pSoundName ) == 0 ) return; } } // Ok, play the sound and add it to the list. CLocalPlayerFilter filter; C_BaseEntity::EmitSound( filter, NULL, pSoundName, &vEndPos ); int j = g_GroupedSounds.AddToTail(); g_GroupedSounds[j].m_SoundName = pSoundName; g_GroupedSounds[j].m_vPos = vEndPos; }
//--------------------------------------------------------- //--------------------------------------------------------- void CVisibilityMonitor::AddEntity( CBaseEntity *pEntity, float flMinDist, VisibilityMonitorCallback pfnCallback, VisibilityMonitorEvaluator pfnEvaluator ) { Assert( pEntity != NULL ); if( !IsTrackingEntity( pEntity ) ) { visibility_target_t newTarget; newTarget.entity = pEntity; newTarget.minDistSqr = Square(flMinDist); newTarget.memory = NO_VISIBILITY_MEMORY; newTarget.pfnCallback = pfnCallback; newTarget.pfnEvaluator = pfnEvaluator; m_Entities.AddToTail( newTarget ); if( debug_visibility_monitor.GetBool() ) { Msg("VisMon: Added Entity: %s (%s)\n", pEntity->GetClassname(), pEntity->GetDebugName() ); } } }
// picks a number of spawners randomly from this spawngroup void CASW_Spawn_Group::PickSpawnersRandomly( int nNumSpawners, bool bIncludeRecentlySpawned, CUtlVector< CASW_Base_Spawner* > *pSpawners ) { pSpawners->RemoveAll(); CUtlVector< CASW_Base_Spawner* > candidates; for ( int i = 0; i < m_hSpawners.Count(); i++ ) { if ( !m_hSpawners[i].Get() || !m_hSpawners[i]->IsEnabled() ) continue; if ( !bIncludeRecentlySpawned && m_hSpawners[i]->HasRecentlySpawned() ) continue; candidates.AddToTail( m_hSpawners[i].Get() ); } for ( int i = 0; ( (i < nNumSpawners) && (candidates.Count() > 0) ); i++ ) { int nChosen = RandomInt( 0, candidates.Count() - 1 ); pSpawners->AddToTail( candidates[ nChosen ] ); candidates.Remove( nChosen ); } }
//----------------------------------------------------------------------------- // Restores the sound patch + associated commands //----------------------------------------------------------------------------- void CSoundControllerImp::RestoreSoundPatch( CSoundPatch **ppSoundPatch, IRestore *pRestore ) { CSoundPatch *pPatch = new CSoundPatch; // read the sound patch data from the memory block pRestore->StartBlock(); bool bOk = ( pRestore->ReadAll( pPatch ) != 0 ); pRestore->EndBlock(); bOk = (bOk && pPatch->IsPlaying()) ? true : false; if (bOk) { m_soundList.AddToTail( pPatch ); } // Count the number of commands that refer to the sound patch pRestore->StartBlock(); if ( bOk ) { int nCount; pRestore->ReadInt( &nCount ); while ( --nCount >= 0 ) { SoundCommand_t *pCommand = new SoundCommand_t; pRestore->StartBlock(); if ( pRestore->ReadAll( pCommand ) ) { CommandInsert( pCommand ); } pRestore->EndBlock(); } } pRestore->EndBlock(); *ppSoundPatch = pPatch; }
//----------------------------------------------------------------------------- // Purpose: Message hook to parse ScreenShake messages // Input : pszName - // iSize - // pbuf - // Output : //----------------------------------------------------------------------------- void CViewEffects::Shake( ScreenShake_t &data ) { if ( ( data.command == SHAKE_START || data.command == SHAKE_START_RUMBLEONLY ) && ( m_ShakeList.Count() < MAX_SHAKES ) ) { screenshake_t *pNewShake = new screenshake_t; pNewShake->amplitude = data.amplitude; pNewShake->frequency = data.frequency; pNewShake->duration = data.duration; pNewShake->nextShake = 0; pNewShake->endtime = gpGlobals->curtime + data.duration; pNewShake->command = data.command; m_ShakeList.AddToTail( pNewShake ); } else if ( data.command == SHAKE_STOP) { ClearAllShakes(); } else if ( data.command == SHAKE_AMPLITUDE ) { // Look for the most likely shake to modify. screenshake_t *pShake = FindLongestShake(); if ( pShake ) { pShake->amplitude = data.amplitude; } } else if ( data.command == SHAKE_FREQUENCY ) { // Look for the most likely shake to modify. screenshake_t *pShake = FindLongestShake(); if ( pShake ) { pShake->frequency = data.frequency; } } }
// Populate with cubemaps that were skipped void Cubemap_AddUnreferencedCubemaps() { char pTextureName[1024]; char pFileName[1024]; PatchInfo_t info; dcubemapsample_t *pSample; int i,j; for ( i=0; i<g_nCubemapSamples; ++i ) { pSample = &g_CubemapSamples[i]; // generate the formatted texture name based on cubemap origin info.m_pMapName = mapbase; info.m_pOrigin[0] = pSample->origin[0]; info.m_pOrigin[1] = pSample->origin[1]; info.m_pOrigin[2] = pSample->origin[2]; GeneratePatchedName( "c", info, false, pTextureName, 1024 ); // find or add for ( j=0; j<s_DefaultCubemapNames.Count(); ++j ) { if ( !stricmp( s_DefaultCubemapNames[j], pTextureName ) ) { // already added break; } } if ( j == s_DefaultCubemapNames.Count() ) { int nLen = Q_snprintf( pFileName, 1024, "materials/%s.vtf", pTextureName ); int id = s_DefaultCubemapNames.AddToTail(); s_DefaultCubemapNames[id] = new char[nLen + 1]; strcpy( s_DefaultCubemapNames[id], pFileName ); } } }
void CJobWatchDlg::FillGraph() { // Get all the graph samples. unsigned long jobWorkerID; if ( !GetCurJobWorkerID( jobWorkerID ) ) return; CMySQLQuery query; query.Format( "select * from graph_entry where JobWorkerID=%lu", jobWorkerID ); GetMySQL()->Execute( query ); int iMSTime = GetMySQL()->GetColumnIndex( "MSSinceJobStart" ); int iBytesSent = GetMySQL()->GetColumnIndex( "BytesSent" ); int iBytesReceived = GetMySQL()->GetColumnIndex( "BytesReceived" ); // See if there's anything new. CUtlVector<CGraphEntry> entries; int highest = m_CurGraphTime; while ( GetMySQL()->NextRow() ) { CGraphEntry entry; entry.m_msTime = GetMySQL()->GetColumnValue( iMSTime ).Int32(); entry.m_nBytesSent = GetMySQL()->GetColumnValue( iBytesSent ).Int32(); entry.m_nBytesReceived = GetMySQL()->GetColumnValue( iBytesReceived ).Int32(); entries.AddToTail( entry ); highest = max( highest, entry.m_msTime ); } if ( highest > m_CurGraphTime ) { m_CurGraphTime = highest; m_GraphControl.Clear(); m_GraphControl.Fill( entries ); } }
//----------------------------------------------------------------------------- // ExcludePathsDlg_Setup // //----------------------------------------------------------------------------- void ExcludePathsDlg_Setup( HWND hWnd ) { TreeView_SetBkColor( GetDlgItem( hWnd, IDC_PATHS_TREE ), g_backgroundColor ); CheckDlgButton( hWnd, IDC_PATHS_LINKGAMEDIRS, g_bLinkGameDirs ? BST_CHECKED : BST_UNCHECKED ); // read the exisiting exclude paths g_ExcludePaths.Purge(); char szFilename[MAX_PATH]; V_ComposeFileName( g_localPath, EXCLUDEPATHS_FILE, szFilename, sizeof( szFilename ) ); if ( Sys_Exists( szFilename ) ) { Sys_LoadScriptFile( szFilename ); while ( 1 ) { char *pToken = Sys_GetToken( true ); if ( !pToken || !pToken[0] ) { break; } Sys_StripQuotesFromToken( pToken ); if ( !stricmp( pToken, "*" ) ) { pToken = ""; } else if ( pToken[0] == '\\' ) { pToken++; } char szPath[MAX_PATH]; V_ComposeFileName( ROOT_NAME, pToken, szPath, sizeof( szPath ) ); V_FixSlashes( szPath ); g_ExcludePaths.AddToTail( szPath ); } } }
//----------------------------------------------------------------------------- // Find clips at, intersecting or within a particular time interval //----------------------------------------------------------------------------- void CDmeTrack::FindClipsAtTime( DmeTime_t time, DmeClipSkipFlag_t flags, CUtlVector< CDmeClip * >& clips ) const { if ( ( flags & DMESKIP_INVISIBLE ) && IsCollapsed() ) return; if ( ( flags & DMESKIP_MUTED ) && IsMute() ) return; int nClipCount = GetClipCount(); for ( int j = 0; j < nClipCount; ++j ) { CDmeClip *pSubClip = GetClip( j ); if ( !pSubClip ) continue; if ( ( flags & DMESKIP_MUTED ) && pSubClip->IsMute() ) continue; if ( time.IsInRange( pSubClip->GetStartTime(), pSubClip->GetEndTime() ) ) { clips.AddToTail( pSubClip ); } } }
void CPhysicsMotionController::AttachObject( IPhysicsObject *pObject ) { Assert(pObject); // BUGBUG: Sometimes restore comes back with a NULL, REVISIT if ( !pObject || pObject->IsStatic() ) return; CPhysicsObject *pPhys = static_cast<CPhysicsObject *>(pObject); IVP_Real_Object *pIVP = pPhys->GetObject(); IVP_Core *pCore = pIVP->get_core(); #if DEBUG int index = m_coreList.Find(pCore); if ( m_coreList.IsValidIndex(index) ) { Msg("Attached core twice!!!\n"); return; } #endif m_coreList.AddToTail( pCore ); pCore->add_core_controller( (IVP_Controller *)this ); }
//----------------------------------------------------------------------------- // Purpose: Adds the panel to a tick signal list, so the panel receives a message every frame //----------------------------------------------------------------------------- void CVGui::AddTickSignal(VPANEL panel, int intervalMilliseconds /*=0*/ ) { Tick_t *t; // See if it's already in list int count = m_TickSignalVec.Count(); for (int i = 0; i < count; i++ ) { Tick_t *t = m_TickSignalVec[i]; if ( t->panel == panel ) { // Go ahead and update intervals t->interval = intervalMilliseconds; t->nexttick = g_pSystem->GetTimeMillis() + t->interval; return; } } // Add to list t = new Tick_t; t->panel = panel; t->interval = intervalMilliseconds; t->nexttick = g_pSystem->GetTimeMillis() + t->interval; if ( strlen( ((VPanel *)panel)->Client()->GetName() ) > 0 ) { strncpy( t->panelname, ((VPanel *)panel)->Client()->GetName(), sizeof( t->panelname ) ); } else { strncpy( t->panelname, ((VPanel *)panel)->Client()->GetClassName(), sizeof( t->panelname ) ); } // simply add the element to the list m_TickSignalVec.AddToTail( t ); // panel is removed from list when deleted }
//----------------------------------------------------------------------------- // Computes a convex hull from the studio model //----------------------------------------------------------------------------- CPhysCollide* ComputeConvexHull( studiohdr_t* pStudioHdr ) { CUtlVector<CPhysConvex*> convexHulls; for (int body = 0; body < pStudioHdr->numbodyparts; ++body ) { mstudiobodyparts_t *pBodyPart = pStudioHdr->pBodypart( body ); for( int model = 0; model < pBodyPart->nummodels; ++model ) { mstudiomodel_t *pStudioModel = pBodyPart->pModel( model ); for( int mesh = 0; mesh < pStudioModel->nummeshes; ++mesh ) { // Make a convex hull for each mesh // NOTE: This won't work unless the model has been compiled // with $staticprop mstudiomesh_t *pStudioMesh = pStudioModel->pMesh( mesh ); convexHulls.AddToTail( ComputeConvexHull( pStudioMesh ) ); } } } // Convert an array of convex elements to a compiled collision model // (this deletes the convex elements) return s_pPhysCollision->ConvertConvexToCollide( convexHulls.Base(), convexHulls.Size() ); }
void ListFiles( const char *dir, CUtlVector< char* > &hFiles, const char *pszExtension = NULL, pFnFilenameMask( pCheck ) = NULL ) { int dirlen = Q_strlen( dir ); FileFindHandle_t _handle; char tmp[MASTERPATH_MAXLEN]; // Q_snprintf( tmp, MAX_PATH, "%s\\*_preview_*.*", dir ); Q_snprintf( tmp, sizeof( tmp ), "%s\\*.%s", dir, (pszExtension ? pszExtension : "*") ); char curFile[ MASTERPATH_MAXLEN ] = { '\0' }; const char *tmpFile = g_pFullFileSystem->FindFirst( tmp, &_handle ); if ( tmpFile ) Q_strncpy( curFile, tmpFile, sizeof(curFile) ); while ( curFile[0] ) { bool bAddFile = pCheck ? pCheck( curFile ) : true; if ( bAddFile ) { int len = Q_strlen( curFile ); len = len + dirlen + 2; char *Addme = new char [len]; Q_snprintf( Addme, len, "%s\\%s", dir, curFile ); hFiles.AddToTail( Addme ); } const char *tmpFile = g_pFullFileSystem->FindNext( _handle ); if ( tmpFile ) Q_strncpy( curFile, tmpFile, sizeof(curFile) ); else curFile[0] = '\0'; } g_pFullFileSystem->FindClose( _handle ); }
void virtualmodel_t::AppendIKLocks( int group, const studiohdr_t *pStudioHdr ) { AUTO_LOCK_( CThreadTerminalMutex<CThreadFastMutex>, m_Lock ); int numCheck = m_iklock.Count(); CUtlVector< virtualgeneric_t > iklock; iklock = m_iklock; int j, k; for (j = 0; j < pStudioHdr->numlocalikautoplaylocks; j++) { int chain1 = pStudioHdr->pLocalIKAutoplayLock( j )->chain; for (k = 0; k < numCheck; k++) { int chain2 = m_group[ iklock[k].group ].GetStudioHdr()->pLocalIKAutoplayLock( iklock[k].index )->chain; if (chain1 == chain2) { break; } } // no duplication if (k == numCheck) { MEM_ALLOC_CREDIT(); virtualgeneric_t tmp; tmp.group = group; tmp.index = j; k = iklock.AddToTail( tmp ); } } m_iklock = iklock; }
//----------------------------------------------------------------------------- // Purpose: // Input : list - //----------------------------------------------------------------------------- void GetParticleManifest( CUtlVector<CUtlString>& list ) { // Open the manifest file, and read the particles specified inside it KeyValues *manifest = new KeyValues( PARTICLES_MANIFEST_FILE ); if ( manifest->LoadFromFile( filesystem, PARTICLES_MANIFEST_FILE, "GAME" ) ) { for ( KeyValues *sub = manifest->GetFirstSubKey(); sub != NULL; sub = sub->GetNextKey() ) { if ( !Q_stricmp( sub->GetName(), "file" ) ) { list.AddToTail( sub->GetString() ); continue; } Warning( "CParticleMgr::Init: Manifest '%s' with bogus file type '%s', expecting 'file'\n", PARTICLES_MANIFEST_FILE, sub->GetName() ); } } else { Warning( "PARTICLE SYSTEM: Unable to load manifest file '%s'\n", PARTICLES_MANIFEST_FILE ); } manifest->deleteThis(); }
void ReadCheatCommandsFromFile( char *pchFileName ) { KeyValues *pCheatCodeKeys = new KeyValues( "cheat_codes" ); pCheatCodeKeys->LoadFromFile( g_pFullFileSystem, pchFileName, NULL ); KeyValues *pKey = NULL; for ( pKey = pCheatCodeKeys->GetFirstTrueSubKey(); pKey; pKey = pKey->GetNextTrueSubKey() ) { int iCheat = s_CheatCodeCommands.AddToTail(); CheatCodeData_t *pNewCheatCode = &(s_CheatCodeCommands[ iCheat ]); Q_strncpy( pNewCheatCode->szName, pKey->GetName(), CHEAT_NAME_MAX_LEN ); // Get the name pNewCheatCode->bDevOnly = ( pKey->GetInt( "dev", 0 ) != 0 ); // Get developer only flag pNewCheatCode->iCodeLength = 0; // Start at zero code elements Q_strncpy( pNewCheatCode->szCommand, pKey->GetString( "command", "echo \"Cheat code has no command!\"" ), CHEAT_COMMAND_MAX_LEN ); KeyValues *pSubKey = NULL; for ( pSubKey = pKey->GetFirstSubKey(); pSubKey; pSubKey = pSubKey->GetNextKey() ) { const char *pchType = pSubKey->GetName(); if ( Q_strcmp( pchType, "code" ) == 0 ) { AssertMsg( ( pNewCheatCode->iCodeLength < CHEAT_NAME_MAX_LEN ), "Cheat code elements exceeded max!" ); pNewCheatCode->pButtonCodes[ pNewCheatCode->iCodeLength ] = g_pInputSystem->StringToButtonCode( pSubKey->GetString() ); ++pNewCheatCode->iCodeLength; } } if ( pNewCheatCode->iCodeLength < CHEAT_NAME_MAX_LEN ) { // If it's activation is a subsequence of another cheat, the longer cheat can't be activated! DevWarning( "Cheat code \"%s\" has less than %i code elements!", pKey->GetName(), CHEAT_NAME_MAX_LEN ); } } }
//----------------------------------------------------------------------------- // Purpose: Draws a colored, filled rectangle // Input : *rect - // *color - // alpha - //----------------------------------------------------------------------------- void CNetGraphPanel::DrawLine2( vrect_t *rect, unsigned char *color, unsigned char *color2, unsigned char alpha, unsigned char alpha2 ) { VPROF( "CNetGraphPanel::DrawLine2" ); int idx = m_Rects.AddToTail(); CLineSegment *seg = &m_Rects[ idx ]; seg->color[0] = color[0]; seg->color[1] = color[1]; seg->color[2] = color[2]; seg->color[3] = alpha; seg->color2[0] = color2[0]; seg->color2[1] = color2[1]; seg->color2[2] = color2[2]; seg->color2[3] = alpha2; if ( rect->width == 1 ) { seg->x1 = rect->x; seg->y1 = rect->y; seg->x2 = rect->x; seg->y2 = rect->y + rect->height; } else if ( rect->height == 1 ) { seg->x1 = rect->x; seg->y1 = rect->y; seg->x2 = rect->x + rect->width; seg->y2 = rect->y; } else { Assert( 0 ); m_Rects.Remove( idx ); } }
//----------------------------------------------------------------------------- // Unserialization //----------------------------------------------------------------------------- static void UnserializeModelDict( CUtlBuffer& buf ) { // Get origin offset for each model... int count = buf.GetInt(); while ( --count >= 0 ) { DetailObjectDictLump_t lump; buf.Get( &lump, sizeof(DetailObjectDictLump_t) ); int i = g_ModelCenterOffset.AddToTail(); CUtlBuffer mdlbuf; if (LoadStudioModel( lump.m_Name, mdlbuf )) { studiohdr_t* pHdr = (studiohdr_t*)mdlbuf.Base(); VectorAdd( pHdr->hull_min, pHdr->hull_max, g_ModelCenterOffset[i] ); g_ModelCenterOffset[i] *= 0.5f; } else { g_ModelCenterOffset[i].Init(0,0,0); } } }
//----------------------------------------------------------------------------- // Display portal error //----------------------------------------------------------------------------- static void DisplayPortalError( portal_t *p, int viscontents ) { char contents[3][1024]; PrintBrushContentsToString( p->nodes[0]->contents, contents[0], sizeof( contents[0] ) ); PrintBrushContentsToString( p->nodes[1]->contents, contents[1], sizeof( contents[1] ) ); PrintBrushContentsToString( viscontents, contents[2], sizeof( contents[2] ) ); Vector center; WindingCenter( p->winding, center ); Warning( "\nFindPortalSide: Couldn't find a good match for which brush to assign to a portal near (%.1f %.1f %.1f)\n", center.x, center.y, center.z); Warning( "Leaf 0 contents: %s\n", contents[0] ); Warning( "Leaf 1 contents: %s\n", contents[1] ); Warning( "viscontents (node 0 contents ^ node 1 contents): %s\n", contents[2] ); Warning( "This means that none of the brushes in leaf 0 or 1 that touches the portal has %s\n", contents[2] ); Warning( "Check for a huge brush enclosing the coordinates above that has contents %s\n", contents[2] ); Warning( "Candidate brush IDs: " ); CUtlVector<int> listed; for (int j=0 ; j<2 ; j++) { node_t *n = p->nodes[j]; for (bspbrush_t *bb=n->brushlist ; bb ; bb=bb->next) { mapbrush_t *brush = bb->original; if ( brush->contents & viscontents ) { if ( listed.Find( brush->brushnum ) == -1 ) { listed.AddToTail( brush->brushnum ); Warning( "Brush %d: ", brush->id ); } } } } Warning( "\n\n" ); }
void SendPatchCommandToUIs( DWORD dwInstallerProcessId ) { Msg( "SendPatchCommandToUIs\n "); CUtlVector<char> data; data.AddToTail( VMPI_SERVICE_UI_PROTOCOL_VERSION ); data.AddToTail( VMPI_SERVICE_TO_UI_PATCHING ); // This arg tells the UI whether to exit after running the command or not. data.AddToTail( 1 ); // First argument is the working directory, which is the cache path in this case. data.AddMultipleToTail( V_strlen( g_FileCachePath ) + 1, g_FileCachePath ); // Second argument is the command line. char waitAndRestartExe[MAX_PATH], serviceUIExe[MAX_PATH], commandLine[1024 * 8]; V_ComposeFileName( g_FileCachePath, "WaitAndRestart.exe", waitAndRestartExe, sizeof( waitAndRestartExe ) ); V_ComposeFileName( g_BaseAppPath, "vmpi_service_ui.exe", serviceUIExe, sizeof( serviceUIExe ) ); // We're running the UI from the same directory this exe is in. char strSeconds[64]; V_snprintf( strSeconds, sizeof( strSeconds ), "*%lu", dwInstallerProcessId ); // IMPORTANT to use BuildCommandLineFromArgs here because it'll handle slashes and quotes correctly. // If we don't do that, the command often won't work. CUtlVector<char*> args; args.AddToTail( waitAndRestartExe ); args.AddToTail( strSeconds ); args.AddToTail( g_BaseAppPath ); args.AddToTail( serviceUIExe ); BuildCommandLineFromArgs( args, commandLine, sizeof( commandLine ) ); data.AddMultipleToTail( V_strlen( commandLine ) + 1, commandLine ); if ( g_pConnMgr ) { g_pConnMgr->SendPacket( -1, data.Base(), data.Count() ); Sleep( 1000 ); // Make sure this packet goes out. } }
//----------------------------------------------------------------------------- // Purpose: // Input : *pFace - input face to test // *pbrush - brush to clip face against // **pOutputList - list of faces clipped from pFace // Output : Returns true if the brush completely clips the face //----------------------------------------------------------------------------- // NOTE: This assumes the brushes have already been chopped so that no solid space // is enclosed by more than one brush!! bool ClipFaceToBrush( face_t *pFace, bspbrush_t *pbrush, face_t **pOutputList ) { int planenum = pFace->planenum & (~1); int foundSide = -1; CUtlVector<int> sortedSides; int i; for ( i = 0; i < pbrush->numsides && foundSide < 0; i++ ) { int bplane = pbrush->sides[i].planenum & (~1); if ( bplane == planenum ) foundSide = i; } Vector offset = -0.5f * (pbrush->maxs + pbrush->mins); face_t *currentface = CopyFace( pFace ); if ( foundSide >= 0 ) { sortedSides.RemoveAll(); for ( i = 0; i < pbrush->numsides; i++ ) { // don't clip to bevels if ( pbrush->sides[i].bevel ) continue; if ( g_MainMap->mapplanes[pbrush->sides[i].planenum].type <= PLANE_Z ) { sortedSides.AddToHead( i ); } else { sortedSides.AddToTail( i ); } } for ( i = 0; i < sortedSides.Size(); i++ ) { int index = sortedSides[i]; if ( index == foundSide ) continue; plane_t *plane = &g_MainMap->mapplanes[pbrush->sides[index].planenum]; winding_t *frontwinding, *backwinding; ClipWindingEpsilon_Offset(currentface->w, plane->normal, plane->dist, 0.001, &frontwinding, &backwinding, offset); // only clip if some part of this face is on the back side of all brush sides if ( !backwinding || WindingIsTiny(backwinding)) { FreeFaceList( *pOutputList ); *pOutputList = NULL; break; } if ( frontwinding && !WindingIsTiny(frontwinding) ) { // add this fragment to the return list // make a face for the fragment face_t *f = NewFaceFromFace( pFace ); f->w = frontwinding; // link the fragment in f->next = *pOutputList; *pOutputList = f; } // update the current winding to be the part behind each plane FreeWinding( currentface->w ); currentface->w = backwinding; } // free the bit that is left in solid or not clipped (if we broke out early) FreeFace( currentface ); // if we made it all the way through and didn't produce any fragments then the whole face was clipped away if ( !*pOutputList && i == sortedSides.Size() ) { return true; } } return false; }
void CloseCaptionTool::ComputeStreamWork( CChoreoWidgetDrawHelper &helper, int available_width, CCloseCaptionItem *item ) { // Start with a clean param block WorkUnitParams params; const wchar_t *curpos = item->GetStream(); CUtlVector< COLORREF > colorStack; for ( ; curpos && *curpos != L'\0'; ++curpos ) { wchar_t cmd[ 256 ]; wchar_t args[ 256 ]; if ( SplitCommand( &curpos, cmd, args ) ) { if ( !wcscmp( cmd, L"cr" ) ) { params.newline = true; AddWorkUnit( item, params); } else if ( !wcscmp( cmd, L"clr" ) ) { AddWorkUnit( item, params ); if ( args[0] == 0 && colorStack.Count()>= 2) { colorStack.Remove( colorStack.Count() - 1 ); params.clr = colorStack[ colorStack.Count() - 1 ]; } else { int r, g, b; COLORREF newcolor; if ( 3 == swscanf( args, L"%i,%i,%i", &r, &g, &b ) ) { newcolor = RGB( r, g, b ); colorStack.AddToTail( newcolor ); params.clr = colorStack[ colorStack.Count() - 1 ]; } } } else if ( !wcscmp( cmd, L"playerclr" ) ) { AddWorkUnit( item, params ); if ( args[0] == 0 && colorStack.Count()>= 2) { colorStack.Remove( colorStack.Count() - 1 ); params.clr = colorStack[ colorStack.Count() - 1 ]; } else { // player and npc color selector // e.g.,. 255,255,255:200,200,200 int pr, pg, pb, nr, ng, nb; COLORREF newcolor; if ( 6 == swscanf( args, L"%i,%i,%i:%i,%i,%i", &pr, &pg, &pb, &nr, &ng, &nb ) ) { // FIXME: nothing in .vcds is ever from the player... newcolor = /*item->IsFromPlayer()*/ false ? RGB( pr, pg, pb ) : RGB( nr, ng, nb ); colorStack.AddToTail( newcolor ); params.clr = colorStack[ colorStack.Count() - 1 ]; } } } else if ( !wcscmp( cmd, L"I" ) ) { AddWorkUnit( item, params ); params.italic = !params.italic; } else if ( !wcscmp( cmd, L"B" ) ) { AddWorkUnit( item, params ); params.bold = !params.bold; } continue; } HFONT useF = m_hFonts[ params.GetFontNumber() ]; int w = helper.CalcTextWidthW( useF, L"%c", *curpos ); if ( ( params.x + params.width ) + w > available_width ) { params.newline = true; AddWorkUnit( item, params ); } *params.out++ = *curpos; params.width += w; } // Add the final unit. params.newline = true; AddWorkUnit( item, params ); item->SetSizeComputed( true ); // DumpWork( item ); }
void CloseCaptionTool::redraw() { if ( !ToolCanDraw() ) return; CChoreoWidgetDrawHelper drawHelper( this ); HandleToolRedraw( drawHelper ); RECT rcOutput; drawHelper.GetClientRect( rcOutput ); RECT rcText = rcOutput; drawHelper.DrawFilledRect( RGB( 0, 0, 0 ), rcText ); drawHelper.DrawOutlinedRect( RGB( 200, 245, 150 ), PS_SOLID, 2, rcText ); InflateRect( &rcText, -4, 0 ); int avail_width = rcText.right - rcText.left; int totalheight = 0; int i; CUtlVector< VisibleStreamItem > visibleitems; int c = m_Items.Count(); for ( i = 0; i < c; i++ ) { CCloseCaptionItem *item = m_Items[ i ]; // Not ready for display yet. if ( item->GetPreDisplayTime() > 0.0f ) { continue; } if ( !item->GetSizeComputed() ) { ComputeStreamWork( drawHelper, avail_width, item ); } int itemheight = item->GetHeight(); totalheight += itemheight; VisibleStreamItem si; si.height = itemheight; si.item = item; visibleitems.AddToTail( si ); } rcText.bottom -= 2; rcText.top = rcText.bottom - totalheight; // Now draw them c = visibleitems.Count(); for ( i = 0; i < c; i++ ) { VisibleStreamItem *si = &visibleitems[ i ]; int height = si->height; CCloseCaptionItem *item = si->item; rcText.bottom = rcText.top + height; DrawStream( drawHelper, rcText, item ); OffsetRect( &rcText, 0, height ); if ( rcText.top >= rcOutput.bottom ) break; } }