本文整理汇总了C++中CUtlVector::Size方法的典型用法代码示例。如果您正苦于以下问题:C++ CUtlVector::Size方法的具体用法?C++ CUtlVector::Size怎么用?C++ CUtlVector::Size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CUtlVector
的用法示例。
在下文中一共展示了CUtlVector::Size方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: WriteRecordingFile
static void WriteRecordingFile()
{
// Store the command size
*(int*)&g_pRecordingBuffer[g_CommandStartIdx] =
g_pRecordingBuffer.Size() - g_CommandStartIdx;
#ifndef CRASH_RECORDING
// When not crash recording, flush when buffer gets too big,
// or when Present() is called
if ((g_pRecordingBuffer.Size() < COMMAND_BUFFER_SIZE) &&
(g_pRecordingBuffer[g_CommandStartIdx+4] != DX8_PRESENT))
return;
#endif
FILE* fp = OpenRecordingFile();
if (fp)
{
// store the command size
fwrite( g_pRecordingBuffer.Base(), 1, g_pRecordingBuffer.Size(), fp );
fflush( fp );
#ifndef CRASH_RECORDING
fclose( fp );
#endif
}
g_pRecordingBuffer.RemoveAll();
}
示例2: Shutdown
void CVradStaticPropMgr::Shutdown()
{
// Remove all static props from the tree
for (int i = m_StaticProps.Size(); --i >= 0; )
{
RemovePropFromTree( i );
}
// Remove all static prop model data
for (int i = m_StaticPropDict.Size(); --i >= 0; )
{
studiohdr_t *pStudioHdr = m_StaticPropDict[i].m_pStudioHdr;
if ( pStudioHdr )
{
if ( pStudioHdr->pVertexBase )
{
free( pStudioHdr->pVertexBase );
}
free( pStudioHdr );
}
}
m_pBSPTreeData->Shutdown();
m_StaticProps.Purge();
m_StaticPropDict.Purge();
}
示例3: StartRayTest
void CVradStaticPropMgr::StartRayTest( PropTested_t& propTested )
{
if (m_StaticProps.Size() > 0)
{
if (propTested.m_pTested == 0)
{
propTested.m_pTested = new int[m_StaticProps.Size()];
memset( propTested.m_pTested, 0, m_StaticProps.Size() * sizeof(int) );
propTested.m_Enum = 0;
propTested.pThreadedCollision = s_pPhysCollision->ThreadContextCreate();
}
++propTested.m_Enum;
}
}
示例4: Write
bool CConfigFile::Write( char const *pFilename )
{
FILE *fp = fopen( pFilename, "wt" );
if( !fp )
return false;
fprintf( fp, "ssdatabase %s\n", m_SSDatabase );
fprintf( fp, "resourcepath %s\n", m_SSResourcePath );
fprintf( fp, "bsppath %s\n", m_SSBSPPath );
for( int i=0; i < m_Entries.Size(); i++ )
{
CConfigFile::Entry *pEntry = &m_Entries[i];
fprintf( fp, "file %s %s %d", pEntry->m_Filename, pEntry->m_VMFPath, pEntry->m_VMFTime );
for( int e=0; e < pEntry->m_nEMailAddresses; e++ )
fprintf( fp, " -email %s", pEntry->m_EMailAddresses[e].m_EMailAddress );
if( pEntry->m_bFastVis )
fprintf( fp, " -fast" );
fprintf( fp, "\n" );
}
fclose( fp );
return true;
}
示例5: WriteDetailLightingLump
//-----------------------------------------------------------------------------
// Writes the detail lighting lump
//-----------------------------------------------------------------------------
static void WriteDetailLightingLump( int lumpID, int lumpVersion, CUtlVector<DetailPropLightstylesLump_t> &lumpData )
{
GameLumpHandle_t handle = g_GameLumps.GetGameLumpHandle(lumpID);
if (handle != g_GameLumps.InvalidGameLump())
g_GameLumps.DestroyGameLump(handle);
int lightsize = lumpData.Size() * sizeof(DetailPropLightstylesLump_t);
int lumpsize = lightsize + sizeof(int);
handle = g_GameLumps.CreateGameLump( lumpID, lumpsize, 0, lumpVersion );
// Serialize the data
CUtlBuffer buf( g_GameLumps.GetGameLump(handle), lumpsize );
buf.PutInt( lumpData.Size() );
if (lightsize)
buf.Put( lumpData.Base(), lightsize );
}
示例6: AddToTouched
bool CMoveHelperServer::AddToTouched( const trace_t &tr, const Vector& impactvelocity )
{
Assert( m_pHostPlayer );
// Trace missed
if ( !tr.m_pEnt )
return false;
if ( tr.m_pEnt == m_pHostPlayer )
{
Assert( !"CMoveHelperServer::AddToTouched: Tried to add self to touchlist!!!" );
return false;
}
// Check for duplicate entities
for ( int j = m_TouchList.Size(); --j >= 0; )
{
if ( m_TouchList[j].trace.m_pEnt == tr.m_pEnt )
{
return false;
}
}
int i = m_TouchList.AddToTail();
m_TouchList[i].trace = tr;
VectorCopy( impactvelocity, m_TouchList[i].deltavelocity );
return true;
}
示例7: ComputeConvexHull
//-----------------------------------------------------------------------------
// 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() );
}
示例8: CalculateSlowMoForPlayer
void CSDKGameRules::CalculateSlowMoForPlayer(CSDKPlayer* pPlayer)
{
if (!pPlayer)
return;
if (!pPlayer->IsAlive())
{
pPlayer->SetSlowMoType(SLOWMO_NONE);
return;
}
// If I activated slow then I get to keep my slow level.
if (pPlayer->GetSlowMoType() == SLOWMO_ACTIVATED)
return;
if (pPlayer->GetSlowMoType() == SLOWMO_STYLESKILL)
return;
// Players who haven't activated anything are at the whims of those who have.
bool bOtherInSlow = false;
CUtlVector<CSDKPlayer*> apOthersInPVS;
CBaseEntity* pOther = NULL;
while ((pOther = UTIL_EntitiesInPVS(pPlayer, pOther)) != NULL)
{
CSDKPlayer* pOtherPlayer = ToSDKPlayer(pOther);
if (!pOtherPlayer)
continue;
if (pOtherPlayer == pPlayer)
continue;
apOthersInPVS.AddToTail(pOtherPlayer);
}
for (int i = 0; i < apOthersInPVS.Size(); i++)
{
CSDKPlayer* pOtherPlayer = apOthersInPVS[i];
if (!pOtherPlayer->IsAlive())
continue;
if (pOtherPlayer->GetSlowMoType() != SLOWMO_NONE)
{
bOtherInSlow = true;
break;
}
}
// If any of these players are in slow then I'm in slow too.
if (bOtherInSlow)
pPlayer->SetSlowMoType(SLOWMO_PASSIVE);
else
pPlayer->SetSlowMoType(SLOWMO_NONE);
}
示例9: ClearAllFades
//-----------------------------------------------------------------------------
// Purpose: Purge & delete all fades in the queue
//-----------------------------------------------------------------------------
void CViewEffects::ClearAllFades( void )
{
int iSize = m_FadeList.Size();
for (int i = iSize-1; i >= 0; i-- )
{
delete m_FadeList[i];
}
m_FadeList.Purge();
}
示例10: FindEntryByFilename
CConfigFile::Entry* CConfigFile::FindEntryByFilename( char const *pFilename )
{
for( int i=0; i < m_Entries.Size(); i++ )
{
if( stricmp( m_Entries[i].m_Filename, pFilename ) == 0 )
return &m_Entries[i];
}
return NULL;
}
示例11:
//-----------------------------------------------------------------------------
// Purpose: Get the team of the specified player
//-----------------------------------------------------------------------------
C_Team *GetPlayersTeam( int iPlayerIndex )
{
for (int i = 0; i < g_Teams.Size(); i++ )
{
if ( g_Teams[i]->ContainsPlayer( iPlayerIndex ) )
return g_Teams[i];
}
return NULL;
}
示例12: ArePlayersOnSameTeam
//-----------------------------------------------------------------------------
// Purpose: Returns true if the two specified players are on the same team
//-----------------------------------------------------------------------------
bool ArePlayersOnSameTeam( int iPlayerIndex1, int iPlayerIndex2 )
{
for (int i = 0; i < g_Teams.Size(); i++ )
{
if ( g_Teams[i]->ContainsPlayer( iPlayerIndex1 ) && g_Teams[i]->ContainsPlayer( iPlayerIndex2 ) )
return true;
}
return false;
}
示例13: ComputePropOpacity
//-----------------------------------------------------------------------------
// System to update prop opacity
//-----------------------------------------------------------------------------
void CStaticPropMgr::ComputePropOpacity( const Vector &viewOrigin )
{
// We need to recompute translucency information for all static props
int i;
#ifndef SWDS
for (i = m_StaticPropDict.Size(); --i >= 0; )
{
if (modelinfoclient->ModelHasMaterialProxy( m_StaticPropDict[i].m_pModel ))
{
modelinfoclient->RecomputeTranslucency( m_StaticPropDict[i].m_pModel );
}
}
#endif
// Distance-based fading.
// Step over the list of all things that want to be faded out and recompute alpha
// Not sure if this is a fast enough way of doing it
// but it's easy for now; we'll have to test later how large this list gets.
// If it's <100 or so, we should be fine
Vector v;
for ( i = m_StaticPropFade.Count(); --i >= 0; )
{
StaticPropFade_t& fade = m_StaticPropFade[i];
CStaticProp& prop = m_StaticProps[fade.m_Model];
// Calculate distance (badly)
VectorSubtract( prop.GetRenderOrigin(), viewOrigin, v );
#ifndef SWDS
ClientRenderHandle_t renderHandle = prop.GetRenderHandle();
float sqDist = v.LengthSqr();
if ( sqDist < fade.m_MaxDistSq )
{
if ((fade.m_MinDistSq >= 0) && (sqDist > fade.m_MinDistSq))
{
clientleafsystem->ChangeRenderableRenderGroup( renderHandle, RENDER_GROUP_TRANSLUCENT_ENTITY );
prop.SetAlpha( fade.m_FalloffFactor * (fade.m_MaxDistSq - sqDist) );
}
else
{
// We can stick the prop into the opaque list
clientleafsystem->ChangeRenderableRenderGroup( renderHandle, RENDER_GROUP_OPAQUE_ENTITY );
prop.SetAlpha( 255 );
}
}
else
{
// We can stick the prop into the opaque list now; we're not drawing it!
clientleafsystem->ChangeRenderableRenderGroup( renderHandle, RENDER_GROUP_OPAQUE_ENTITY );
prop.SetAlpha( 0 );
}
#endif
}
}
示例14: ProcessImpacts
//-----------------------------------------------------------------------------
// After we built the touch list, deal with all the impacts...
//-----------------------------------------------------------------------------
void CMoveHelperServer::ProcessImpacts( void )
{
Assert( m_pHostPlayer );
// Relink in order to build absorigin and absmin/max to reflect any changes
// from prediction. Relink will early out on SOLID_NOT
engine->RelinkEntity( m_pHostPlayer->pev, true );
// Don't bother if the player ain't solid
if ( m_pHostPlayer->IsSolidFlagSet( FSOLID_NOT_SOLID ) )
{
return;
}
// Save off the velocity, cause we need to temporarily reset it
Vector vel = m_pHostPlayer->GetAbsVelocity();
// Touch other objects that were intersected during the movement.
for (int i = 0 ; i < m_TouchList.Size(); i++)
{
CBaseHandle entindex = m_TouchList[i].trace.m_pEnt->GetRefEHandle();
// We should have culled negative indices by now
Assert( entindex.IsValid() );
edict_t* ent = GetEdict( entindex );
if (!ent)
continue;
// Run the impact function as if we had run it during movement.
CBaseEntity *entity = GetContainingEntity( ent );
if ( !entity )
continue;
Assert( entity != m_pHostPlayer );
// Don't ever collide with self!!!!
if ( entity == m_pHostPlayer )
continue;
// Reconstruct trace results.
m_TouchList[i].trace.m_pEnt = CBaseEntity::Instance( ent );
// Use the velocity we had when we collided, so boxes will move, etc.
m_pHostPlayer->SetAbsVelocity( m_TouchList[i].deltavelocity );
entity->PhysicsImpact( m_pHostPlayer, m_TouchList[i].trace );
}
// Restore the velocity
m_pHostPlayer->SetAbsVelocity( vel );
// So no stuff is ever left over, sigh...
ResetTouchList();
}
示例15: GiveSlowMoToNearbyPlayers
void CSDKGameRules::GiveSlowMoToNearbyPlayers(CSDKPlayer* pPlayer)
{
if (!pPlayer)
return;
if (!pPlayer->IsAlive())
{
pPlayer->SetSlowMoType(SLOWMO_NONE);
return;
}
if (pPlayer->GetSlowMoType() == SLOWMO_NONE)
return;
// I have some slowmo on me. Pass it to other players nearby.
CUtlVector<CSDKPlayer*> apOthersInPVS;
CBaseEntity* pOther = NULL;
while ((pOther = UTIL_EntitiesInPVS(pPlayer, pOther)) != NULL)
{
CSDKPlayer* pOtherPlayer = ToSDKPlayer(pOther);
if (!pOtherPlayer)
continue;
if (pOtherPlayer == pPlayer)
continue;
// If they already have slow mo, we don't need to pass it to them.
if (pOtherPlayer->GetSlowMoType() == SLOWMO_STYLESKILL)
continue;
if (pOtherPlayer->GetSlowMoType() == SLOWMO_ACTIVATED)
continue;
if (pOtherPlayer->GetSlowMoType() == SLOWMO_PASSIVE)
continue;
apOthersInPVS.AddToTail(pOtherPlayer);
}
for (int i = 0; i < apOthersInPVS.Size(); i++)
{
CSDKPlayer* pOtherPlayer = apOthersInPVS[i];
// It could have been already done by a previous iteration of the recursion below.
if (pOtherPlayer->GetSlowMoType() != SLOWMO_NONE)
continue;
pOtherPlayer->SetSlowMoType(SLOWMO_PASSIVE);
GiveSlowMoToNearbyPlayers(pOtherPlayer);
}
}