当前位置: 首页>>代码示例>>C++>>正文


C++ CUtlVector::Size方法代码示例

本文整理汇总了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();
}
开发者ID:DeadZoneLuna,项目名称:SourceEngine2007,代码行数:27,代码来源:recording.cpp

示例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();
}
开发者ID:chrizonix,项目名称:RCBot2,代码行数:27,代码来源:vradstaticprops.cpp

示例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;
	}
}
开发者ID:RaisingTheDerp,项目名称:raisingthebar,代码行数:14,代码来源:vradstaticprops.cpp

示例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;
}
开发者ID:RaisingTheDerp,项目名称:raisingthebar,代码行数:27,代码来源:vmapbuilder.cpp

示例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 );
}
开发者ID:hitmen047,项目名称:CM2013,代码行数:19,代码来源:vraddetailprops.cpp

示例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;
}
开发者ID:RaisingTheDerp,项目名称:raisingthebar,代码行数:29,代码来源:movehelper_server.cpp

示例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() );
}
开发者ID:chrizonix,项目名称:RCBot2,代码行数:28,代码来源:vradstaticprops.cpp

示例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);
}
开发者ID:,项目名称:,代码行数:58,代码来源:

示例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();
}
开发者ID:SizzlingStats,项目名称:hl2sdk-ob-valve,代码行数:12,代码来源:view_effects.cpp

示例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;
}
开发者ID:RaisingTheDerp,项目名称:raisingthebar,代码行数:10,代码来源:vmapbuilder.cpp

示例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;
}
开发者ID:RaisingTheDerp,项目名称:raisingthebar,代码行数:13,代码来源:c_team.cpp

示例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;
}
开发者ID:RaisingTheDerp,项目名称:raisingthebar,代码行数:13,代码来源:c_team.cpp

示例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
	}
}
开发者ID:RaisingTheDerp,项目名称:raisingthebar,代码行数:58,代码来源:staticpropmgr.cpp

示例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();
}
开发者ID:RaisingTheDerp,项目名称:raisingthebar,代码行数:57,代码来源:movehelper_server.cpp

示例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);
	}
}
开发者ID:,项目名称:,代码行数:54,代码来源:


注:本文中的CUtlVector::Size方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。