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


C++ CGameManager::GetFilterSet方法代码示例

本文整理汇总了C++中CGameManager::GetFilterSet方法的典型用法代码示例。如果您正苦于以下问题:C++ CGameManager::GetFilterSet方法的具体用法?C++ CGameManager::GetFilterSet怎么用?C++ CGameManager::GetFilterSet使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CGameManager的用法示例。


在下文中一共展示了CGameManager::GetFilterSet方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Initialize_Rescan2

//Create scanning threads
void Initialize_Rescan2(GAME_INFO *pGI, bool (*filterServerItem)(SERVER_INFO *lp,GAME_INFO *pGI, vFILTER_SETS *vFilterSets))
{
	g_log.AddLogInfo(GS_LOG_DEBUG,"Entering Initialize_Rescan2 function.");
	//SCAN_FilterServerItem = filterServerItem;

	vFILTER_SETS vFS;
	vFS = pGI->vFilterSets;
	vFS.insert(vFS.end(),gm.GetFilterSet(GLOBAL_FILTER).begin(),gm.GetFilterSet(GLOBAL_FILTER).end());
	sort(vFS.begin(),vFS.end(),Sort_Filter_By_GroupName);

	vSRV_INF::iterator  iLst;
	pGI->vRefScanSI.clear();

	pGI->dwViewFlags  |= SCAN_SERVERLIST;

	for ( iLst = pGI->vSI.begin( ); iLst != pGI->vSI.end( ); iLst++ )
	{	
		SERVER_INFO *pSI = *iLst;
		REF_SERVER_INFO refSI;
		refSI.pServerInfo = pSI;
		if(filterServerItem!=NULL)
		{
			if(filterServerItem(pSI,pGI,&vFS))
			{
				pGI->vRefScanSI.push_back(refSI);		
			}
		}
		else
		{
			pGI->vRefScanSI.push_back(refSI);  		
		}
	}
	if(pGI->dwViewFlags & SCAN_SERVERLIST)
		pGI->dwViewFlags ^= SCAN_SERVERLIST;

	g_log.AddLogInfo(GS_LOG_INFO,"Preparing to scan %d servers of a total %d.",pGI->vRefScanSI.size(),pGI->vSI.size());

	if(pGI->dwViewFlags & FORCE_SCAN_FILTERED)
		pGI->dwViewFlags = 0;

	if(g_hwndProgressBar!=NULL)
	{
		//Initililze Progressbar
		SendMessage(g_hwndProgressBar, PBM_SETSTEP, (WPARAM) 1, 0); 
		SendMessage(g_hwndProgressBar, PBM_SETRANGE, (WPARAM) 0,MAKELPARAM(0,pGI->vRefScanSI.size())); 
		SendMessage(g_hwndProgressBar, PBM_SETPOS, (WPARAM) 0, 0); 
	}

	HANDLE hThreadIndex[MAX_THREADS];
	DWORD dwThreadId[MAX_THREADS];
	
	for(DWORD i=0; i<AppCFG.dwThreads;i++)
		hThreadIndex[i]=NULL;

	SCANNER_dwThreadCounter=0;
	pGI->dwScanIdx = 0;
	
	//Create and setup Continue Event, this is important! Otherwise ETSV can crash.
	SCAN_hContinueEvent = CreateEvent(NULL,TRUE,TRUE,"ScanContinueEvent"); 
    if (SCAN_hContinueEvent == NULL) 
        g_log.AddLogInfo(GS_LOG_DEBUG,"CreateEvent failed (%d)\n", GetLastError());

	if (! ResetEvent(SCAN_hContinueEvent) ) 
        g_log.AddLogInfo(GS_LOG_DEBUG,"ResetEvent failed (%d)\n", GetLastError());

	DWORD dwMaxThreads = (AppCFG.dwThreads>pGI->vRefScanSI.size())?pGI->vRefScanSI.size():AppCFG.dwThreads;

	//---------------------------------
	//Multi thread scanning code
	//---------------------------------
	//Startup the threads!!!
	for (DWORD i=0; i<dwMaxThreads;i++)
	{
		hThreadIndex[SCANNER_dwThreadCounter] = CreateThread( NULL, 0, &Get_ServerStatusThread2, (LPVOID) pGI ,0, &dwThreadId[SCANNER_dwThreadCounter]);  
	
		if (hThreadIndex[SCANNER_dwThreadCounter] == NULL) 
		{
			dbg_print("Error creating thread!\n");			
		}
		else 
		{	
			//g_log.AddLogInfo(GS_LOG_INFO,"Thread created! %d",i);					
			EnterCriticalSection( &SCANNER_CSthreadcounter ); 
			SCANNER_dwThreadCounter++;  
			LeaveCriticalSection( &SCANNER_CSthreadcounter ); 
			//SetThreadName(dwThreadId[SCANNER_dwThreadCounter], "Get_ServerStatusThread2");
		} 
	}
		
	//All threads created in graceful way and counter increased properly
	if (! SetEvent(SCAN_hContinueEvent) ) 
		dbg_print("SetEvent failed\n");
	//After this this the thread counter can decrease properly with a noncorrupted handle
	DWORD dwStartTick = GetTickCount();
	DWORD iWaitIndex = 0;
	DWORD i=0;
	//Wait for all threads to finish...
	//g_log.AddLogInfo(GS_LOG_DEBUG,"AppCFG.dwThreads %d",AppCFG.dwThreads);

//.........这里部分代码省略.........
开发者ID:bdamage,项目名称:gamescanner,代码行数:101,代码来源:scanner.cpp


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