Пример #1
0
 LARGE_INTEGER Adapter::checkInterfaceSupport(REFGUID InterfaceName)
 {
   LARGE_INTEGER pUMDVersion = LARGE_INTEGER();
   HRESULT hr = getRawInterface()->CheckInterfaceSupport(InterfaceName, &pUMDVersion);
   if(FAILED(hr)) throw COMException(hr, "IDXGIAdapter::CheckInterfaceSupport");
   return pUMDVersion;
 }
Пример #2
0
bool GameMode::PlayRoundLan(bool& roundsLeft, bool& zoomInPressed, bool& zoomOutPressed)
{
	bool running = true;
	bool quitByMenu = false;
	int numAlivePlayers = 0;
	LARGE_INTEGER oldTick = LARGE_INTEGER();
	QueryPerformanceCounter(&oldTick);
	LARGE_INTEGER now =  LARGE_INTEGER();

	ThreadParam* tp = NULL;
	bool resume = true;
	bool menuPressed = false;
	#if FixedTimeStep
		while(running && this->mGe->isRunning())
		{
				float diff = mGe->Update(); //A problem when the user opens up ingame menu is that the diff after resume is incredibly high so it breaks game logic, game gotta continue in the background if network :P	

				if(this->mGe->GetKeyListener()->IsPressed(VK_ESCAPE) && tp == NULL)
				{
					this->HideHud();
					menuPressed = true;
					tp = new ThreadParam(this->mIGM, resume);
					CreateThread(0, 0, &InGameMenuThread, (void*)tp, 0, 0);
				}
				if(tp != NULL)
				{
					if(tp->finished)
					{
						roundsLeft = running = tp->resume;
						quitByMenu = !running;
						delete tp;
						tp = NULL;
						menuPressed = false;
					}
				}
					
				for(int i = 0; i < this->mNumberOfPlayers; i++)
				{
					if(this->mBalls[i]->GetTeamColor() != this->mNet->GetBall(i)->GetTeam()) //causes lag otherwise re-setting the color every frame if its alrdy set.
						this->mBalls[i]->SetTeamColor(this->mNet->GetBall(i)->GetTeam());
				}

				if(this->mNet->IsServer())
					this->mPe->SimulateServer();
				else //is client
					this->mPe->SimulateClient();
				
				

					
				if(this->mNet->GetNumPlayers() > this->mNumberOfPlayers)
				{
					this->AddBall();
					numAlivePlayers++;
				}
					
				for(int i = 0; i < this->mNumberOfPlayers; i++)
				{
					if(this->mBalls[i]->IsAlive())
						numAlivePlayers += 1;
				}
				if(this->mNet->IsServer())
				if(numAlivePlayers < 1)
				{
					running = false;
				}
				
				if(this->checkWinConditions(diff))
					running = false;
				if(!menuPressed)
					this->ShowHud();
				
			

				float newdt = diff/1000.0f;
				
				this->mTimeElapsed += newdt;
				if(this->mTimeElapsed > 600.0f)
					running = false;
				if(this->mQuitByMenu)
				{
					quitByMenu = true;
					running = false;
				}
		}
	#else
		while(running && this->mGe->isRunning())
		{
				float diff = mGe->Update(); //A problem when the user opens up ingame menu is that the diff after resume is incredibly high so it breaks game logic, game gotta continue in the background if network :P	

				if(this->mGe->GetKeyListener()->IsPressed(VK_ESCAPE) && tp == NULL)
				{
					this->HideHud();
					menuPressed = true;
					tp = new ThreadParam(this->mIGM, resume);
					CreateThread(0, 0, &InGameMenuThread, (void*)tp, 0, 0);
				}
				if(tp != NULL)
				{
					if(tp->finished)
					{
						roundsLeft = running = tp->resume;
						quitByMenu = !running;
						delete tp;
						tp = NULL;
						menuPressed = false;
					}
				}
		
				QueryPerformanceCounter(&now);
				LARGE_INTEGER proc_freq;
				::QueryPerformanceFrequency(&proc_freq);
				double frequency = proc_freq.QuadPart;

				diff = 1000*((now.QuadPart - oldTick.QuadPart) / frequency); //2			WITH A VARIABLE DELTATIME THE BALL PHYSICS RESULT DIFFER IF MORE THAN TWO CLIENTS WITH DIFFERENT DELTA TIMES PROCESS EXACTLY THE SAME INPUT, SETTING A CONSTANT DELTATIME HOWEVER LEADS TO THE SAME PHYSICS RESULT (THOUGH WITH A HUGE DELAY DUE TO THE CLIENT IN THE BACKGROUND IS A ASSIGNED LESS CPU TIME (-> low FPS)). IS THERE SOMETHING IN BALL PHYSICS THAT SHOULD BE DEPENDANT ON DELTATIME THAT ISNT?//
				QueryPerformanceCounter(&oldTick);
				if(diff > 100)
					diff = 5;

				for(int i = 0; i < this->mNumberOfPlayers; i++)
				{
					if(this->mBalls[i]->GetTeam() != this->mNet->GetBall(i)->GetTeam()) //causes lag otherwise re-setting the color every frame if its alrdy set.
						this->mBalls[i]->SetTeam(this->mNet->GetBall(i)->GetTeam());
				}
				if(this->mNet->IsServer())
					this->IsServer(diff, zoomOutPressed, zoomInPressed, running, quitByMenu);
				else //is client
					this->IsClient(diff, zoomOutPressed, zoomInPressed, running, quitByMenu);
				

				for(int i = 0; i < this->mNumberOfPlayers; i++)
				{
					if(this->mBalls[i]->IsAlive())
						numAlivePlayers += 1;
				}
				mPlatform->Update(diff);

		
				if(!this->mNet->UpdatePowerBall(this->mBalls, this->mNumberOfPlayers, this->mPe, diff))
					running = false;

				if(this->mNet->GetNumPlayers() > this->mNumberOfPlayers)
				{
					this->AddBall();
					numAlivePlayers++;
				}

				if(this->mNet->IsServer())
				if(numAlivePlayers < 1)
				{
					running = false;
				}
				
				if(this->checkWinConditions(diff))
					running = false;
				if(!menuPressed) 
					this->ShowHud();
				
					

				float newdt = diff/1000.0f;
				
				this->mTimeElapsed += newdt;
				if(this->mTimeElapsed > 600.0f)
					running = false;
				if(this->mQuitByMenu)
				{
					quitByMenu = true;
					running = false;
				}
		}
	#endif
		
	#if FixedTimeStep
		this->mPe->ResetTimers();
			
	#else
			
	#endif
		
	return quitByMenu;
}