本文整理汇总了C++中CUtlVector::Base方法的典型用法代码示例。如果您正苦于以下问题:C++ CUtlVector::Base方法的具体用法?C++ CUtlVector::Base怎么用?C++ CUtlVector::Base使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CUtlVector
的用法示例。
在下文中一共展示了CUtlVector::Base方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SetLumpData
//-----------------------------------------------------------------------------
// Places Detail Objects in the lump
//-----------------------------------------------------------------------------
static void SetLumpData( )
{
// Sort detail props by leaf
qsort( s_DetailObjectLump.Base(), s_DetailObjectLump.Count(), sizeof(DetailObjectLump_t), SortFunc );
GameLumpHandle_t handle = GetGameLumpHandle(GAMELUMP_DETAIL_PROPS);
if (handle != InvalidGameLump())
DestroyGameLump(handle);
int nDictSize = s_DetailObjectDictLump.Count() * sizeof(DetailObjectDictLump_t);
int nSpriteDictSize = s_DetailSpriteDictLump.Count() * sizeof(DetailSpriteDictLump_t);
int nObjSize = s_DetailObjectLump.Count() * sizeof(DetailObjectLump_t);
int nSize = nDictSize + nSpriteDictSize + nObjSize + 3 * sizeof(int);
handle = CreateGameLump( GAMELUMP_DETAIL_PROPS, nSize, 0, GAMELUMP_DETAIL_PROPS_VERSION );
// Serialize the data
CUtlBuffer buf( GetGameLump(handle), nSize );
buf.PutInt( s_DetailObjectDictLump.Count() );
if (nDictSize)
buf.Put( s_DetailObjectDictLump.Base(), nDictSize );
buf.PutInt( s_DetailSpriteDictLump.Count() );
if (nSpriteDictSize)
buf.Put( s_DetailSpriteDictLump.Base(), nSpriteDictSize );
buf.PutInt( s_DetailObjectLump.Count() );
if (nObjSize)
buf.Put( s_DetailObjectLump.Base(), nObjSize );
}
示例2: CmdLib_FPrintf
void CmdLib_FPrintf( FileHandle_t hFile, const char *pFormat, ... )
{
static CUtlVector<char> buf;
if ( buf.Count() == 0 )
buf.SetCount( 1024 );
va_list marker;
va_start( marker, pFormat );
while ( 1 )
{
int ret = Q_vsnprintf( buf.Base(), buf.Count(), pFormat, marker );
if ( ret >= 0 )
{
// Write the string.
g_pFileSystem->Write( buf.Base(), ret, hFile );
break;
}
else
{
// Make the buffer larger.
int newSize = buf.Count() * 2;
buf.SetCount( newSize );
if ( buf.Count() != newSize )
{
Error( "CmdLib_FPrintf: can't allocate space for text." );
}
}
}
va_end( marker );
}
示例3: RunInDLL
void RunInDLL( const char *pFilename, CUtlVector<char*> &newArgv )
{
if ( g_pConnMgr )
g_pConnMgr->SetAppState( VMPI_SERVICE_STATE_BUSY );
bool bSuccess = false;
CSysModule *pModule = Sys_LoadModule( pFilename );
if ( pModule )
{
CreateInterfaceFn fn = Sys_GetFactory( pModule );
if ( fn )
{
ILaunchableDLL *pDLL = (ILaunchableDLL*)fn( LAUNCHABLE_DLL_INTERFACE_VERSION, NULL );
if( pDLL )
{
// Do this here because the executables we would have launched usually would do it.
CommandLine()->CreateCmdLine( newArgv.Count(), newArgv.Base() );
pDLL->main( newArgv.Count(), newArgv.Base() );
bSuccess = true;
SpewOutputFunc( MySpewOutputFunc );
}
}
Sys_UnloadModule( pModule );
}
if ( !bSuccess )
{
Msg( "Error running VRAD (or VVIS) out of DLL '%s'\n", pFilename );
}
if ( g_pConnMgr )
g_pConnMgr->SetAppState( VMPI_SERVICE_STATE_IDLE );
}
示例4: Intersection
//-----------------------------------------------------------------------------
//
//-----------------------------------------------------------------------------
void CDmeSingleIndexedComponent::Intersection( const CDmeSingleIndexedComponent &rhs )
{
const int nLhs = Count();
const int nRhs = rhs.Count();
int l = 0;
int r = 0;
if ( IsComplete() )
{
// TODO
Assert( 0 );
}
else
{
CUtlVector< int > newComponents;
newComponents.EnsureCapacity( nLhs );
CUtlVector< float > newWeights;
newWeights.EnsureCapacity( nLhs );
while ( l < nLhs || r < nRhs )
{
// In LHS but not RHS
while ( l < nLhs && ( r >= nRhs || m_Components[ l ] < rhs.m_Components[ r ] ) )
{
++l;
}
// In RHS but not LHS
while ( r < nRhs && ( l >= nLhs || m_Components[ l ] > rhs.m_Components[ r ] ) )
{
++r;
}
// In Both LHS & RHS
while ( l < nLhs && r < nRhs && m_Components[ l ] == rhs.m_Components[ r ] )
{
newComponents.AddToTail( m_Components[ l ] );
newWeights.AddToTail( m_Weights[ l ] );
++l;
++r;
}
}
m_Components.CopyArray( newComponents.Base(), newComponents.Count() );
m_Weights.CopyArray( newWeights.Base(), newWeights.Count() );
}
m_CompleteCount.Set( 0 );
m_bComplete.Set( false );
}
示例5: 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() );
}
示例6: PerfThread_SendSpewText
void PerfThread_SendSpewText()
{
// Send the spew text to the database.
CCriticalSectionLock csLock( &g_SpewTextCS );
csLock.Lock();
if ( g_SpewText.Count() > 0 )
{
g_SpewText.AddToTail( 0 );
if ( g_bMPI_StatsTextOutput )
{
g_pDB->AddCommandToQueue( new CSQLDBCommand_TextMessage( g_SpewText.Base() ), NULL );
}
else
{
// Just show one message in the vmpi_job_watch window to let them know that they need
// to use a command line option to get the output.
static bool bFirst = true;
if ( bFirst )
{
char msg[512];
V_snprintf( msg, sizeof( msg ), "%s not enabled", VMPI_GetParamString( mpi_Stats_TextOutput ) );
bFirst = false;
g_pDB->AddCommandToQueue( new CSQLDBCommand_TextMessage( msg ), NULL );
}
}
g_SpewText.RemoveAll();
}
csLock.Unlock();
}
示例7: createAccleratorTable
void mx::createAccleratorTable( int numentries, Accel_t *entries )
{
CUtlVector< ACCEL > accelentries;
for ( int i = 0; i < numentries; ++i )
{
const Accel_t& entry = entries[ i ];
ACCEL add;
add.key = entry.key;
add.cmd = entry.command;
add.fVirt = 0;
if ( entry.flags & ACCEL_ALT )
{
add.fVirt |= FALT;
}
if ( entry.flags & ACCEL_CONTROL )
{
add.fVirt |= FCONTROL;
}
if ( entry.flags & ACCEL_SHIFT )
{
add.fVirt |= FSHIFT;
}
if ( entry.flags & ACCEL_VIRTKEY )
{
add.fVirt |= FVIRTKEY;
}
accelentries.AddToTail( add );
}
g_hAcceleratorTable = ::CreateAcceleratorTable( accelentries.Base(), accelentries.Count() );
}
示例8: FrameUpdatePostEntityThink
void CEntityTouchManager::FrameUpdatePostEntityThink()
{
VPROF( "CEntityTouchManager::FrameUpdatePostEntityThink" );
// Loop through all entities again, checking their untouch if flagged to do so
int count = m_updateList.Count();
if ( count )
{
// copy off the list
CBaseEntity **ents = (CBaseEntity **)stackalloc( sizeof(CBaseEntity *) * count );
memcpy( ents, m_updateList.Base(), sizeof(CBaseEntity *) * count );
// clear it
m_updateList.RemoveAll();
// now update those ents
for ( int i = 0; i < count; i++ )
{
//Assert( ents[i]->GetCheckUntouch() );
if ( ents[i]->GetCheckUntouch() )
{
ents[i]->PhysicsCheckForEntityUntouch();
}
}
stackfree( ents );
}
}
示例9: 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();
}
示例10: SendProxy_UtlVectorElement
void SendProxy_UtlVectorElement(
const SendProp *pProp,
const void *pStruct,
const void *pData,
DVariant *pOut,
int iElement,
int objectID )
{
CSendPropExtra_UtlVector *pExtra = (CSendPropExtra_UtlVector*)pProp->GetExtraData();
Assert( pExtra );
// Kind of lame overloading element stride to hold the element index,
// but we can easily move it into its SetExtraData stuff if we need to.
iElement = pProp->GetElementStride();
// NOTE: this is cheesy, but it does the trick.
CUtlVector<int> *pUtlVec = (CUtlVector<int>*)((char*)pStruct + pExtra->m_Offset);
if ( iElement >= pUtlVec->Count() )
{
// Pass in zero value.
memset( pOut, 0, sizeof( *pOut ) );
}
else
{
// Call through to the proxy they passed in, making pStruct=the CUtlVector and forcing iElement to 0.
pExtra->m_ProxyFn( pProp, pData, (char*)pUtlVec->Base() + iElement*pExtra->m_ElementStride, pOut, 0, objectID );
}
}
示例11: GetBSPInfo
void CVRadDLL::GetBSPInfo( CBSPInfo *pInfo )
{
pInfo->dlightdata = pdlightdata->Base();
pInfo->lightdatasize = pdlightdata->Count();
pInfo->dfaces = dfaces;
pInfo->m_pFacesTouched = g_FacesTouched.Base();
pInfo->numfaces = numfaces;
pInfo->dvertexes = dvertexes;
pInfo->numvertexes = numvertexes;
pInfo->dedges = dedges;
pInfo->numedges = numedges;
pInfo->dsurfedges = dsurfedges;
pInfo->numsurfedges = numsurfedges;
pInfo->texinfo = texinfo.Base();
pInfo->numtexinfo = texinfo.Count();
pInfo->g_dispinfo = g_dispinfo.Base();
pInfo->g_numdispinfo = g_dispinfo.Count();
pInfo->dtexdata = dtexdata;
pInfo->numtexdata = numtexdata;
pInfo->texDataStringData = g_TexDataStringData.Base();
pInfo->nTexDataStringData = g_TexDataStringData.Count();
pInfo->texDataStringTable = g_TexDataStringTable.Base();
pInfo->nTexDataStringTable = g_TexDataStringTable.Count();
}
示例12: Execute
void CTilegenAction_AddRoomCandidates::Execute( CLayoutSystem *pLayoutSystem )
{
if ( m_pLevelTheme == NULL )
{
const char *pThemeName = m_pThemeNameExpression->Evaluate( pLayoutSystem->GetFreeVariables() );
m_pLevelTheme = CLevelTheme::FindTheme( pThemeName );
if ( m_pLevelTheme == NULL )
{
Log_Warning( LOG_TilegenLayoutSystem, "Theme %s not found.\n", pThemeName );
pLayoutSystem->OnError();
return;
}
}
CUtlVector< const CRoomTemplate * > validRoomTemplates;
BuildRoomTemplateList( pLayoutSystem, m_pLevelTheme, m_pRoomTemplateFilter, m_bExcludeGlobalFilters, &validRoomTemplates );
const CRoomTemplate **ppRoomTemplates = const_cast< const CRoomTemplate ** >( validRoomTemplates.Base() );
BuildRoomCandidateList(
pLayoutSystem,
ppRoomTemplates,
validRoomTemplates.Count(),
m_pExitFilter,
m_pRoomCandidateFilter,
m_pRoomCandidateFilterAction,
m_pRoomCandidateFilterCondition,
m_bExcludeGlobalFilters );
}
示例13: Format
void CMySQLQuery::Format( const char *pFormat, ... )
{
#define QUERYTEXT_GROWSIZE 1024
// This keeps growing the buffer and calling _vsnprintf until the buffer is
// large enough to hold all the data.
m_QueryText.SetSize( QUERYTEXT_GROWSIZE );
while ( 1 )
{
va_list marker;
va_start( marker, pFormat );
int ret = _vsnprintf( m_QueryText.Base(), m_QueryText.Count(), pFormat, marker );
va_end( marker );
if ( ret < 0 )
{
m_QueryText.SetSize( m_QueryText.Count() + QUERYTEXT_GROWSIZE );
}
else
{
m_QueryText[ m_QueryText.Count() - 1 ] = 0;
break;
}
}
}
示例14: ResizeAnimationLayerCallback
void ResizeAnimationLayerCallback( void *pStruct, int offsetToUtlVector, int len )
{
C_BaseAnimatingOverlay *pEnt = (C_BaseAnimatingOverlay*)pStruct;
CUtlVector < CAnimationLayer > *pVec = &pEnt->m_AnimOverlay;
CUtlVector< CInterpolatedVar< CAnimationLayer > > *pVecIV = &pEnt->m_iv_AnimOverlay;
Assert( (char*)pVec - (char*)pEnt == offsetToUtlVector );
Assert( pVec->Count() == pVecIV->Count() );
Assert( pVec->Count() <= C_BaseAnimatingOverlay::MAX_OVERLAYS );
int diff = len - pVec->Count();
if ( diff != 0 )
{
// remove all entries
for ( int i=0; i < pVec->Count(); i++ )
{
pEnt->RemoveVar( &pVec->Element( i ) );
}
pEnt->InvalidatePhysicsRecursive( BOUNDS_CHANGED );
// adjust vector sizes
if ( diff > 0 )
{
for ( int i = 0; i < diff; ++i )
{
int j = pVec->AddToTail( );
(*pVec)[j].SetOwner( pEnt );
}
pVecIV->AddMultipleToTail( diff );
}
else
{
pVec->RemoveMultiple( len, -diff );
pVecIV->RemoveMultiple( len, -diff );
}
// Rebind all the variables in the ent's list.
for ( int i=0; i < len; i++ )
{
IInterpolatedVar *pWatcher = &pVecIV->Element( i );
pWatcher->SetDebugName( s_m_iv_AnimOverlayNames[i] );
pEnt->AddVar( &pVec->Element( i ), pWatcher, LATCH_ANIMATION_VAR, true );
}
}
// FIXME: need to set historical values of nOrder in pVecIV to MAX_OVERLAY
// Ensure capacity
pVec->EnsureCapacity( len );
int nNumAllocated = pVec->NumAllocated();
// This is important to do because EnsureCapacity doesn't actually call the constructors
// on the elements, but we need them to be initialized, otherwise it'll have out-of-range
// values which will piss off the datatable encoder.
UtlVector_InitializeAllocatedElements( pVec->Base() + pVec->Count(), nNumAllocated - pVec->Count() );
}
示例15: AddConsoleOutput
void CVMPIServiceConnMgr::AddConsoleOutput( const char *pMsg )
{
// Tell clients of the new text string.
CUtlVector<char> data;
data.AddToTail( VMPI_SERVICE_UI_PROTOCOL_VERSION );
data.AddToTail( VMPI_SERVICE_TO_UI_CONSOLE_TEXT );
data.AddMultipleToTail( strlen( pMsg ) + 1, pMsg );
SendPacket( -1, data.Base(), data.Count() );
}