コード例 #1
0
//-----------------------------------------------------------------------------
// Finds and/or creates a symbol based on the string
//-----------------------------------------------------------------------------
void CLocalizedStringTable::AddString(char const *pString, wchar_t *pValue, const char *fileName)
{
	if (!pString) 
		return;

	wchar_t *str = Find(pString);
	
	// it's already in the table
	if (str)
		return;

	// didn't find, insert the string into the vector.
	int len = strlen(pString) + 1;
	int stridx = m_Names.AddMultipleToTail( len );
	memcpy( &m_Names[stridx], pString, len * sizeof(char) );

	len = wcslen(pValue) + 1;
	int valueidx = m_Values.AddMultipleToTail( len );
	memcpy( &m_Values[valueidx], pValue, len * sizeof(wchar_t) );

	localizedstring_t stringMapItem;
	stringMapItem.nameIndex = stridx;
	stringMapItem.valueIndex = valueidx;
	if (fileName)
	{
		stringMapItem.filename = fileName;
	}
	else
	{
		stringMapItem.filename = m_CurrentFile;
	}
	m_Lookup.Insert( stringMapItem );
}
コード例 #2
0
void CVMPIServiceConnMgr::SendCurStateTo( int id )
{
	CUtlVector<char> data;
	data.AddToTail( VMPI_SERVICE_UI_PROTOCOL_VERSION );
	data.AddToTail( VMPI_SERVICE_TO_UI_STATE );
	data.AddMultipleToTail( sizeof( g_iCurState ), (char*)&g_iCurState );
	data.AddToTail( (char)g_bScreensaverMode );
	
	if ( g_pPassword )
		data.AddMultipleToTail( strlen( g_pPassword ) + 1, g_pPassword );
	else
		data.AddToTail( 0 );

	SendPacket( -1, data.Base(), data.Count() );
}
コード例 #3
0
bool CJobWatchDlg::GetCurrentWorkerText( 
	CUtlVector<char> &text, 
	unsigned long &curMessageIndex )
{
	text.SetSize( 0 );

	unsigned long jobWorkerID;
	if ( !GetCurJobWorkerID( jobWorkerID ) )
		return false;

	// Now copy all the text out.
	CMySQLQuery query;
	if ( curMessageIndex == 0 )
		query.Format( "select * from text_messages where JobWorkerID=%lu", jobWorkerID );
	else
		query.Format( "select * from text_messages where JobWorkerID=%lu and MessageIndex >= %lu", jobWorkerID, curMessageIndex );
	
	GetMySQL()->Execute( query );

	while ( GetMySQL()->NextRow() )
	{
		const char *pTextStr = GetMySQL()->GetColumnValue( "text" ).String();
		int len = strlen( pTextStr );
		text.AddMultipleToTail( len, pTextStr );

		curMessageIndex = GetMySQL()->GetColumnValue( "MessageIndex" ).UInt32() + 1;
	}

	text.AddToTail( 0 );
	return true;
}
コード例 #4
0
void VMPI_Stats_SpewHook( const char *pMsg )
{
	CCriticalSectionLock csLock( &g_SpewTextCS );
	csLock.Lock();

		// Queue the text up so we can send it to the DB right away when we connect.
		g_SpewText.AddMultipleToTail( strlen( pMsg ), pMsg );
}
コード例 #5
0
void CopyListPanelToClipboard( vgui::ListPanel *pListPanel )
{
	CUtlVector<char> textBuf;

	// Write the headers.
	int nColumns = pListPanel->GetNumColumnHeaders();
	for ( int i=0; i < nColumns; i++ )
	{
		if ( i != 0 )
			textBuf.AddToTail( '\t' );
		
		char tempText[512];
		if ( !pListPanel->GetColumnHeaderText( i, tempText, sizeof( tempText ) ) )
			Error( "GetColumHeaderText( %d ) failed", i );
		
		textBuf.AddMultipleToTail( strlen( tempText ), tempText );
	}
	textBuf.AddToTail( '\n' );

	// Now write the rows.
	int iCur = pListPanel->FirstItem();
	while ( iCur != pListPanel->InvalidItemID() )
	{
		// Write the columns for this row.
		for ( int i=0; i < nColumns; i++ )
		{
			if ( i != 0 )
				textBuf.AddToTail( '\t' );
		
			wchar_t tempTextWC[512];
			char tempText[512];

			pListPanel->GetCellText( iCur, i, tempTextWC, sizeof( tempTextWC ) );
			g_pVGuiLocalize->ConvertUnicodeToANSI( tempTextWC, tempText, sizeof( tempText ) );

			textBuf.AddMultipleToTail( strlen( tempText ), tempText );
		}
		textBuf.AddToTail( '\n' );

		iCur = pListPanel->NextItem( iCur );
	}
	textBuf.AddToTail( 0 );

	// Set the clipboard text.
	vgui::system()->SetClipboardText( textBuf.Base(), textBuf.Count() );
}
コード例 #6
0
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() );
}
コード例 #7
0
void ResizeAnimationLayerCallback( void *pStruct, int offsetToUtlVector, int len )
{
	C_BaseAnimatingOverlay *pEnt = (C_BaseAnimatingOverlay*)pStruct;
	CUtlVector < C_AnimationLayer > *pVec = &pEnt->m_AnimOverlay;
	CUtlVector< CInterpolatedVar< C_AnimationLayer > > *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 )
		return;

	// remove all entries
	for ( int i=0; i < pVec->Count(); i++ )
	{
		pEnt->RemoveVar( &pVec->Element( i ) );
	}

	// adjust vector sizes
	if ( diff > 0 )
	{
		pVec->AddMultipleToTail( diff );
		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
	
}
コード例 #8
0
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() );
}
コード例 #9
0
void CStaticPropMgr::UnserializeLeafList( CUtlBuffer& buf )
{
	int nCount = buf.GetInt();
	m_StaticPropLeaves.Purge();
	if ( nCount > 0 )
	{
		m_StaticPropLeaves.AddMultipleToTail( nCount );
		buf.Get( m_StaticPropLeaves.Base(), nCount * sizeof(StaticPropLeafLump_t) );
	}
}
コード例 #10
0
int CALLBACK SetPasswordDlgProc(
  HWND hwndDlg,  // handle to dialog box
  UINT uMsg,     // message
  WPARAM wParam, // first message parameter
  LPARAM lParam  // second message parameter
)
{
	switch( uMsg )
	{
		case WM_INITDIALOG:
		{
			if ( g_pPassword )
			{
				HWND hWnd = GetDlgItem( hwndDlg, IDC_PASSWORD );
				SetWindowText( hWnd, g_pPassword );
			}
		}
		break;

		case WM_COMMAND:
		{
			switch( wParam )
			{
				case IDOK:
				{
					// Set our new password.
					HWND hWnd = GetDlgItem( hwndDlg, IDC_PASSWORD );
					if ( hWnd )
					{
						char tempBuf[512];
						GetWindowText( hWnd, tempBuf, sizeof( tempBuf ) );

						// Send it to the service.
						CUtlVector<char> data;
						data.AddToTail( VMPI_SERVICE_UPDATE_PASSWORD );
						data.AddMultipleToTail( strlen( tempBuf ) + 1, tempBuf );
						g_ConnMgr.SendPacket( -1, data.Base(), data.Count() );
					}
					EndDialog( hwndDlg, 0 );
				}
				break;
			
				case IDCANCEL:
				{
					EndDialog( hwndDlg, 0 );
				}
				break;
			}
		}
		break;
	}

	return FALSE;
}
コード例 #11
0
static void AddFuncInstance( CSimpleMapFile *pInstanceMapFile, CInstanceSpawn *pInstanceSpawn, const Vector &vPosition )
{
	CUtlVector< MapEntityKeyValuePair_t > replacePairs;
	replacePairs.AddMultipleToTail( pInstanceSpawn->GetAdditionalKeyValueCount() );
	for ( int i = 0; i < pInstanceSpawn->GetAdditionalKeyValueCount(); ++ i )
	{
		replacePairs[i].m_pKey = pInstanceSpawn->GetAdditionalKeyValues()[i].m_Key;
		replacePairs[i].m_pValue = pInstanceSpawn->GetAdditionalKeyValues()[i].m_Value;
	}
	pInstanceMapFile->AddFuncInstance( pInstanceSpawn->GetInstanceFilename(), QAngle( 0, 0, 0 ), vPosition, replacePairs.Base(), replacePairs.Count() );
}
コード例 #12
0
ファイル: unifylods.cpp プロジェクト: Bubbasacs/FinalProj
static void LoadModelLODSource( s_model_t *pSrcModel )
{
	CUtlVector<s_source_t *> lods;
	int numLODs = g_ScriptLODs.Size();
	lods.AddMultipleToTail( numLODs );
	
	if( stricmp( pSrcModel->name, "blank" ) == 0 )
	{
		return;
	}
	
	GetLODSources( lods, pSrcModel );
}
コード例 #13
0
void RecordArgument( void const* pMemory, int size )
{
	if( !g_bDoRecord )
	{
		return;
	}
	Assert( g_ArgsRemaining > 0 );
	int tail = g_pRecordingBuffer.Size();
	g_pRecordingBuffer.AddMultipleToTail( size );
	memcpy( &g_pRecordingBuffer[tail], pMemory, size );
	if (--g_ArgsRemaining == 0)
		WriteRecordingFile();
}
コード例 #14
0
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.
	}
}
コード例 #15
0
//-----------------------------------------------------------------------------
// Purpose: Generate a list of file matching mask
//-----------------------------------------------------------------------------
int CScriptLib::FindFiles( char* pFileMask, bool bRecurse, CUtlVector<fileList_t> &fileList )
{
	char	dirPath[MAX_PATH];
	char	pattern[MAX_PATH];
	char	extension[MAX_PATH];

	// get path only
	strcpy( dirPath, pFileMask );
	V_StripFilename( dirPath );

	// get pattern only
	V_FileBase( pFileMask, pattern, sizeof( pattern ) );
	V_ExtractFileExtension( pFileMask, extension, sizeof( extension ) );
	if ( extension[0] )
	{
		strcat( pattern, "." );
		strcat( pattern, extension );
	}

	if ( !bRecurse )
	{
		GetFileList( dirPath, pattern, fileList );
	}
	else
	{
		// recurse and get the tree
		CUtlVector< fileList_t > tempList;
		CUtlVector< CUtlString > dirList;
		RecurseFileTree_r( dirPath, 0, dirList );
		for ( int i=0; i<dirList.Count(); i++ )
		{
			// iterate each directory found
			tempList.Purge();
			tempList.EnsureCapacity( dirList.Count() );

			GetFileList( dirList[i].String(), pattern, tempList );

			int start = fileList.AddMultipleToTail( tempList.Count() );
			for ( int j=0; j<tempList.Count(); j++ )
			{
				fileList[start+j] = tempList[j];
			}
		}	
	}

	return fileList.Count();
}
コード例 #16
0
void RecordCommand( RecordingCommands_t cmd, int numargs )
{
	if( !g_bDoRecord )
	{
		return;
	}
	Assert( g_ArgsRemaining == 0 );

	g_CommandStartIdx = g_pRecordingBuffer.AddMultipleToTail( 6 );

	// save space for the total command size
	g_pRecordingBuffer[g_CommandStartIdx+4] = cmd;
	g_pRecordingBuffer[g_CommandStartIdx+5] = numargs;
	g_ArgsRemaining = numargs;
	if (g_ArgsRemaining == 0)
		WriteRecordingFile();
}
コード例 #17
0
ファイル: unifylods.cpp プロジェクト: Bubbasacs/FinalProj
//-----------------------------------------------------------------------------
// This fills out boneMap, which is a mapping from src bone to src bone replacement (or to itself
// if there is no bone replacement.
//-----------------------------------------------------------------------------
static void BuildBoneLODMapping( CUtlVector<int> &boneMap, int lodID )
{
	boneMap.AddMultipleToTail( g_numbones );

	Assert( lodID < g_ScriptLODs.Size() );
	LodScriptData_t& scriptLOD = g_ScriptLODs[lodID];

	// First, create a direct mapping where no bones are collapsed
	int i;
	for( i = 0; i < g_numbones; i++ )
	{
		boneMap[i] = i;
	}

	for( i = 0; i < scriptLOD.boneReplacements.Size(); i++ )
	{
		const char *src, *dst;
		src = scriptLOD.boneReplacements[i].GetSrcName();
		dst = scriptLOD.boneReplacements[i].GetDstName();
		int j = findGlobalBone( src );
		int k = findGlobalBone( dst );

		if ( j != -1 && k != -1)
		{
			boneMap[j] = k;
		}
		else if ( j == -1)
		{
			// FIXME: is this really an error?  It could just be  replacement command for bone that doesnt' exist anymore.
			if (g_verbose)
			{
				MdlWarning( "Couldn't replace unknown bone \"%s\" with \"%s\"\n", src, dst );
			}
		}
		else
		{
			// FIXME: is this really an error?  It could just be  replacement command for bone that doesnt' exist anymore.
			if (g_verbose)
			{
				MdlWarning( "Couldn't replace bone \"%s\" with unknown \"%s\"\n", src, dst );
			}
		}
	}
}
コード例 #18
0
void EatTextModeKeyPresses()
{
	if ( !g_bTextMode )
		return;
	
	static bool bFirstRun = true;
	if ( bFirstRun )
	{
		bFirstRun = false;
		MoveConsoleWindowToFront();
	}

	char ch;
	while ( (ch = NextGetch()) != -1 )
	{
		if ( ch == 8 )
		{
			// Backspace..
			if ( g_TextModeLine.Count() )
			{
				g_TextModeLine.Remove( g_TextModeLine.Count() - 1 );
			}
		}
		else if ( ch == '\r' )
		{
			// Finish the line.
			if ( g_TextModeLine.Count() )
			{
				g_TextModeLine.AddMultipleToTail( 2, "\n" );
				Cbuf_AddText( g_TextModeLine.Base() );
				g_TextModeLine.Purge();
			}
			printf( "\n" );
		}
		else
		{
			g_TextModeLine.AddToTail( ch );
		}

		printf( "%c", ch );
	}	
}
コード例 #19
0
void CStaticPropMgr::UnserializeModels( CUtlBuffer& buf )
{
	// Version check
	if ( Mod_GameLumpVersion( GAMELUMP_STATIC_PROPS ) < 4 )
	{
		Warning("Really old map format! Static props can't be loaded...\n");
		return;
	}

	int count = buf.GetInt();

	// Gotta preallocate the static props here so no rellocations take place
	// the leaf list stores pointers to these tricky little guys.
	m_StaticProps.AddMultipleToTail(count);
	for ( int i = 0; i < count; ++i )
	{
		StaticPropLump_t lump;
		buf.Get( &lump, sizeof(StaticPropLump_t) );
 		m_StaticProps[i].Init( i, lump, m_StaticPropDict[lump.m_PropType].m_pModel );

		// For distance-based fading, keep a list of the things that need
		// to be faded out. Not sure if this is the optimal 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
		if (lump.m_Flags & STATIC_PROP_FLAG_FADES)
		{
			int idx = m_StaticPropFade.AddToTail();
			StaticPropFade_t& fade = m_StaticPropFade[idx];
			fade.m_Model = i;
			fade.m_MinDistSq = lump.m_FadeMinDist * lump.m_FadeMinDist;
			fade.m_MaxDistSq = lump.m_FadeMaxDist * lump.m_FadeMaxDist;
			if (fade.m_MaxDistSq != fade.m_MinDistSq)
				fade.m_FalloffFactor = 255.0f / (fade.m_MaxDistSq - fade.m_MinDistSq);
			else
				fade.m_FalloffFactor = 255.0f;
		}

		// Add the prop to the K-D tree for collision
		m_StaticProps[i].InsertPropIntoKDTree( );
	}
}
コード例 #20
0
void CVradStaticPropMgr::UnserializeModels( CUtlBuffer& buf )
{
	int count = buf.GetInt();

	m_StaticProps.AddMultipleToTail(count);
	for ( int i = 0; i < count; ++i )
	{
		StaticPropLump_t lump;
		buf.Get( &lump, sizeof(StaticPropLump_t) );
		
		VectorCopy( lump.m_Origin, m_StaticProps[i].m_Origin );
		VectorCopy( lump.m_Angles, m_StaticProps[i].m_Angles );
		m_StaticProps[i].m_ModelIdx = lump.m_PropType;
		m_StaticProps[i].m_Handle = TREEDATA_INVALID_HANDLE;

		// Add the prop to the tree for collision, but only if it isn't
		// marked as not casting a shadow
		if ((lump.m_Flags & STATIC_PROP_NO_SHADOW) == 0)
			InsertPropIntoTree( i );
	}
}
コード例 #21
0
//-----------------------------------------------------------------------------
// Purpose: sets the value in the index
//-----------------------------------------------------------------------------
void CLocalizedStringTable::SetValueByIndex(StringIndex_t index, wchar_t *newValue)
{
	// get the existing string
	localizedstring_t &lstr = m_Lookup[index];
	wchar_t *wstr = &m_Values[lstr.valueIndex];

	// see if the new string will fit within the old memory
	int newLen = wcslen(newValue);
	int oldLen = wcslen(wstr);

	if (newLen > oldLen)
	{
		// it won't fit, so allocate new memory - this is wasteful, but only happens in edit mode
		lstr.valueIndex = m_Values.AddMultipleToTail(newLen + 1);
		memcpy(&m_Values[lstr.valueIndex], newValue, (newLen + 1) * sizeof(wchar_t));
	}
	else
	{
		// copy the string into the old position
		wcscpy(wstr, newValue);		
	}
}
コード例 #22
0
ファイル: disp_vrad.cpp プロジェクト: Bubbasacs/FinalProj
void BlendCorners( CCoreDispInfo **ppListBase, int listSize )
{
	CUtlVector<int> nbCornerVerts;

	for ( int iDisp=0; iDisp < listSize; iDisp++ )
	{
		CCoreDispInfo *pDisp = ppListBase[iDisp];

		int iNeighbors[512];
		int nNeighbors = GetAllNeighbors( pDisp, iNeighbors );

		// Make sure we have room for all the neighbors.
		nbCornerVerts.RemoveAll();
		nbCornerVerts.EnsureCapacity( nNeighbors );
		nbCornerVerts.AddMultipleToTail( nNeighbors );
		
		// For each corner.
		for ( int iCorner=0; iCorner < 4; iCorner++ )
		{
			// Has it been touched?
			CVertIndex cornerVert = pDisp->GetCornerPointIndex( iCorner );
			int iCornerVert = pDisp->VertIndexToInt( cornerVert );
			const Vector &vCornerVert = pDisp->GetVert( iCornerVert );

			// For each displacement sharing this corner..
			Vector vAverage = pDisp->GetNormal( iCornerVert );

			for ( int iNeighbor=0; iNeighbor < nNeighbors; iNeighbor++ )
			{
				int iNBListIndex = iNeighbors[iNeighbor];
				CCoreDispInfo *pNeighbor = ppListBase[iNBListIndex];
				
				// Find out which vert it is on the neighbor.
				int iNBCorner = FindNeighborCornerVert( pNeighbor, vCornerVert );
				if ( iNBCorner == -1 )
				{
					nbCornerVerts[iNeighbor] = -1; // remove this neighbor from the list.
				}
				else
				{
					CVertIndex viNBCornerVert = pNeighbor->GetCornerPointIndex( iNBCorner );
					int iNBVert = pNeighbor->VertIndexToInt( viNBCornerVert );
					nbCornerVerts[iNeighbor] = iNBVert;
					vAverage += pNeighbor->GetNormal( iNBVert );
				}
			}


			// Blend all the neighbor normals with this one.
			VectorNormalize( vAverage );
			pDisp->SetNormal( iCornerVert, vAverage );

#if defined( USE_SCRATCHPAD )
			ScratchPad_DrawArrowSimple( 
				g_pPad, 
				pDisp->GetVert( iCornerVert ), 
				pDisp->GetNormal( iCornerVert ), 
				Vector( 0, 0, 1 ),
				25 );
#endif

			for ( int iNeighbor=0; iNeighbor < nNeighbors; iNeighbor++ )
			{
				int iNBListIndex = iNeighbors[iNeighbor];
				if ( nbCornerVerts[iNeighbor] == -1 )
					continue;

				CCoreDispInfo *pNeighbor = ppListBase[iNBListIndex];
				pNeighbor->SetNormal( nbCornerVerts[iNeighbor], vAverage );
			}
		}
	}
}
コード例 #23
0
void CNetViewThread::UpdateServicesFromNetView()
{
    HANDLE hChildStdoutRd, hChildStdoutWr;
    
	// Set the bInheritHandle flag so pipe handles are inherited.
    SECURITY_ATTRIBUTES saAttr; 
	saAttr.nLength = sizeof(SECURITY_ATTRIBUTES); 
    saAttr.bInheritHandle = TRUE; 
    saAttr.lpSecurityDescriptor = NULL; 

	if( CreatePipe( &hChildStdoutRd, &hChildStdoutWr, &saAttr, 0 ) )
	{
		STARTUPINFO si;
		memset(&si, 0, sizeof si);
		si.cb = sizeof(si);
		si.dwFlags = STARTF_USESTDHANDLES;
		si.hStdOutput = hChildStdoutWr;
		
		PROCESS_INFORMATION pi;

		if( CreateProcess( 
			NULL, 
			"net view", 
			NULL,	// lpProcessAttributes
			NULL,	// lpThreadAttributes
			TRUE,	// bInheritHandls
			DETACHED_PROCESS,	// dwCreationFlags
			NULL,				// lpEnvironment
			NULL,				// lpCurrentDirectory
			&si,				// lpStartupInfo
			&pi					// lpProcessInformation
			) )
		{
			// read from pipe..
			#define BUFFER_SIZE 8192
			char buffer[BUFFER_SIZE];
			BOOL bDone = FALSE;
			CUtlVector<char> totalBuffer;
			
			while(1)
			{
				DWORD dwCount = 0;
				DWORD dwRead = 0;
				
				// read from input handle
				PeekNamedPipe(hChildStdoutRd, NULL, NULL, NULL, &dwCount, NULL);
				if (dwCount)
				{
					dwCount = min (dwCount, BUFFER_SIZE - 1);
					ReadFile(hChildStdoutRd, buffer, dwCount, &dwRead, NULL);
				}
				if(dwRead)
				{
					buffer[dwRead] = 0;
					totalBuffer.AddMultipleToTail( dwRead, buffer );
				}
				// check process termination
				else if( WaitForSingleObject( pi.hProcess, 1000 ) != WAIT_TIMEOUT )
				{
					if ( bDone )
						break;
					
					bDone = TRUE;	// next time we get it
				}
			}

			// Now parse the output.
			totalBuffer.AddToTail( 0 );
			ParseComputerNames( totalBuffer.Base() );
		}

		CloseHandle( hChildStdoutRd );
		CloseHandle( hChildStdoutWr );
	}
}
コード例 #24
0
void BuildPingHeader( CUtlVector<char> &data, char packetID, int iState )
{
	// Figure out the computer's name.
	char computerName[128];
	DWORD computerNameLen = sizeof( computerName );
	GetComputerName( computerName, &computerNameLen );	

	// Ping back at them.
	data.AddToTail( VMPI_PROTOCOL_VERSION );
	data.AddToTail( packetID );
	data.AddToTail( (char)iState );
	
	DWORD liveTime = GetTickCount() - g_AppStartTime;
	data.AddMultipleToTail( sizeof( liveTime ), (char*)&liveTime );

	data.AddMultipleToTail( sizeof( g_SocketPort ), (char*)&g_SocketPort );
	data.AddMultipleToTail( strlen( computerName ) + 1, computerName );

	if ( g_hRunningProcess )
		data.AddMultipleToTail( strlen( g_CurMasterName ) + 1, g_CurMasterName );
	else
		data.AddMultipleToTail( 1, "" );

	// Write in how long the worker app has been running.
	DWORD appRunTime = 0;
	if ( g_hRunningProcess )
		appRunTime = GetTickCount() - g_CreateProcessTime;

	data.AddMultipleToTail( sizeof( appRunTime ), (char*)&appRunTime );

	// Finally, write the password.
	if ( g_pPassword )
		data.AddMultipleToTail( strlen( g_pPassword ) + 1, g_pPassword );
	else
		data.AddToTail( 0 );

	data.AddMultipleToTail( V_strlen( g_VersionString ) + 1, g_VersionString );

	int processorPercentage, memoryUsageMegabytes;
	GetRunningProcessStats( processorPercentage, memoryUsageMegabytes );

	// Write processor percentage.
	data.AddToTail( (char)processorPercentage );

	// Write the EXE name.
	data.AddMultipleToTail( V_strlen( g_RunningProcess_ExeName ) + 1, g_RunningProcess_ExeName );
							
	// Write memory usage.
	short memUsageShort = (short)memoryUsageMegabytes;
	data.AddMultipleToTail( sizeof( memUsageShort ), (const char*)&memUsageShort );

	// Write the map name.
	data.AddMultipleToTail( V_strlen( g_RunningProcess_MapName ) + 1, g_RunningProcess_MapName );
}
コード例 #25
0
ファイル: unifylods.cpp プロジェクト: Bubbasacs/FinalProj
//-----------------------------------------------------------------------------
// Computes LOD vertices for a model piece.
//-----------------------------------------------------------------------------
static void UnifyModelLODs( s_model_t *pSrcModel )
{
	CUtlVector<s_source_t *> lods;
	int nNumLODs = g_ScriptLODs.Count();
	lods.AddMultipleToTail( nNumLODs );
	
	if( Q_stricmp( pSrcModel->name, "blank" ) == 0 )
		return;
	
	// lod source are not gauranteed to be unique
	// an lod's source may be the same source at multiple lods
	// and therefore shared
	GetLODSources( lods, pSrcModel );
	
	// each lod has a unique vertex mapping table
	int nLodID;
	int *pMeshVertIndexMaps[MAX_NUM_LODS];
	for ( nLodID = 0; nLodID < MAX_NUM_LODS; nLodID++ )
	{
		if ( nLodID < nNumLODs && lods[nLodID] )
		{
			pMeshVertIndexMaps[nLodID] = new int[lods[nLodID]->numvertices];
#ifdef _DEBUG
			memset( pMeshVertIndexMaps[nLodID], 0xDD, lods[nLodID]->numvertices * sizeof(int) );
#endif
		}
		else
		{
			pMeshVertIndexMaps[nLodID] = NULL;
		}
	}

	// These hold the aggregate data for the model that grows as lods are processed
	CVertexDictionary vertexDictionary;
	CUtlVector<s_face_t> faces;
	CUtlVector<s_mesh_t> meshes;
	
	meshes.AddMultipleToTail( MAXSTUDIOSKINS );
	Assert( meshes.Count() == MAXSTUDIOSKINS );
	memset( meshes.Base(), 0, meshes.Count() * sizeof( s_mesh_t ) );

	int nMeshID;
	for( nMeshID = 0; nMeshID < pSrcModel->source->nummeshes; nMeshID++ )
	{
		s_mesh_t *pVertexDictMesh = &meshes[pSrcModel->source->meshindex[nMeshID]];
		
		pVertexDictMesh->numvertices = 0;
		pVertexDictMesh->vertexoffset = vertexDictionary.VertexCount();
		pVertexDictMesh->numfaces = 0;
		pVertexDictMesh->faceoffset = faces.Count();
		
		// First build up information for LOD 0
		if ( !lods[0] )
			continue;

		// lookup the material used by this mesh
		int nMaterialID = lods[0]->meshindex[nMeshID];
		s_mesh_t *pLOD0Mesh = FindMeshByMaterial( lods[0], nMaterialID );
		if ( !pLOD0Mesh )
			continue;

		// populate with all vertices from LOD 0
		int nStart = vertexDictionary.VertexCount();
		CopyVerts( 0, lods[0], pLOD0Mesh, vertexDictionary, pVertexDictMesh, pMeshVertIndexMaps[0] );
		vertexDictionary.SetRootVertexRange( nStart, vertexDictionary.VertexCount() );
	
		MarkRootLODBones( vertexDictionary );

		// only fix up the faces for the highest lod since the lowest ones are going
		// to be reprocessed later.
		CopyFaces( lods[0], pLOD0Mesh, faces, pVertexDictMesh );

		// Now, for each LOD, try to build meshes using the vertices in LOD 0.
		// Ideally, vertices used in an LOD would be in LOD 0 for the benefit of shared vertices.
		// If we don't find vertices in LOD 0, this code will add vertices into LOD 0's list
		// of vertices for the next LOD to find
		for ( nLodID = 1; nLodID < nNumLODs; ++nLodID )
		{
			s_source_t *pCurrLOD = lods[nLodID];
			if ( !pCurrLOD )
				continue;

			// Find the mesh that matches the material
			// mesh may not be present or could be culled due to $removemesh commands
			s_mesh_t *pCurrLODMesh = FindOrCullMesh( nLodID, pCurrLOD, nMaterialID );
			if ( !pCurrLODMesh )
				continue;

			CreateLODVertsInDictionary( nLodID, lods[0], pCurrLOD, pCurrLODMesh, pVertexDictMesh, vertexDictionary, pMeshVertIndexMaps[nLodID]);
		}
	}

#ifdef _DEBUG
	Msg( "Total vertex count: %d\n", vertexDictionary.VertexCount() );
#endif

	// save the data we just built into the processed data section
	// The processed data has all of the verts that are needed for all LODs.
	SetProcessedWithDictionary( lods, vertexDictionary, faces, meshes, pMeshVertIndexMaps );
//	PrintSourceVerts( lods[0] );
}