Пример #1
0
void Bench_CheckStart( void )
{
	const char *level;
	if ( !started && !Bench_Active() )
	{
		level = gEngfuncs.pfnGetLevelName();
		if ( level && level[0] && !stricmp( level, "maps/ppdemo.bsp" ) )
		{
			started = 1;
			EngineClientCmd( "ppdemostart\n" );
		}
	}
}
Пример #2
0
void Bench_CheckEntity( int type, struct cl_entity_s *ent, const char *modelname )
{
	if ( Bench_InStage( THIRD_STAGE ) && !stricmp( modelname, "*3" ) )
	{
		model_t *pmod;
		vec3_t v;
		pmod = (model_t *)( ent->model );

		VectorAdd( pmod->mins, pmod->maxs, v );
		VectorScale( v, 0.5, v );

		VectorAdd( v, ent->origin, g_aimorg );
	}

	if ( Bench_InStage( THIRD_STAGE ) && strstr( modelname, "ppdemodot" ) )
	{
		Bench_SetDotAdded( 1 );
		VectorCopy( ent->origin, g_dotorg );

		// Adjust end position
		if ( Bench_Active() && Bench_InStage( THIRD_STAGE ) )
		{
			static float fZAdjust = 0.0;
			static float fLastTime;
			float dt;
			float fRate = Bench_GetPowerPlay() ? 4.0 : 8.0;
			float fBounds = Bench_GetPowerPlay() ? 8.0 : 15.0;

			dt = gHUD.m_flTime - fLastTime;
			if ( dt > 0.0 && dt < 1.0 )
			{
				fZAdjust += gEngfuncs.pfnRandomFloat( -fRate, fRate );
				fZAdjust = min( fBounds, fZAdjust );
				fZAdjust = max( -fBounds, fZAdjust );

				ent->origin[2] += fZAdjust;

				g_fZAdjust = fZAdjust;
			}
			fLastTime = gHUD.m_flTime;
		}
	}
}
Пример #3
0
void Bench_CheckEntity( int type, cl_entity_t *ent, const char *modelname )
{
	if ( Bench_InStage( THIRD_STAGE ) && !stricmp( modelname, "*3" ) )
	{
		model_t *pmod = ent->model;
		const Vector v = ( pmod->mins + pmod->maxs ) * 0.5;

		g_aimorg = v + ent->origin;
	}

	if ( Bench_InStage( THIRD_STAGE ) && strstr( modelname, "ppdemodot" ) )
	{
		Bench_SetDotAdded( 1 );
		g_dotorg = ent->origin;

		// Adjust end position
		if ( Bench_Active() && Bench_InStage( THIRD_STAGE ) )
		{
			static float fZAdjust = 0.0;
			static float fLastTime;
			float dt;
			float fRate = Bench_GetPowerPlay() ? 4.0 : 8.0;
			float fBounds = Bench_GetPowerPlay() ? 8.0 : 15.0;

			dt = gHUD.m_flTime - fLastTime;
			if ( dt > 0.0 && dt < 1.0 )
			{
				fZAdjust += gEngfuncs.pfnRandomFloat( -fRate, fRate );
				fZAdjust = min( fBounds, fZAdjust );
				fZAdjust = max( -fBounds, fZAdjust );

				ent->origin[2] += fZAdjust;

				g_fZAdjust = fZAdjust;
			}
			fLastTime = gHUD.m_flTime;
		}
	}
}
Пример #4
0
void Bench_SetViewAngles( int recalc_wander, Vector& viewangles, float frametime, usercmd_t *cmd )
{
	if ( !Bench_Active() )
		return;

	// Clear stochastic offset between runs
	if ( Bench_InStage( FIRST_STAGE ) )
	{
		v_stochastic = vec3_origin;
	}

	if ( Bench_InStage( SECOND_STAGE ) || Bench_InStage( THIRD_STAGE ) )
	{
		Vector lookdir = g_aimorg - v_origin;
		lookdir = lookdir.Normalize();
		VectorAngles( lookdir, viewangles );
		
		viewangles[0] = -viewangles[0];

		/*
		if ( recalc_wander )
		{
			float fmag = 2.0;
			if ( Bench_GetPowerPlay() )
			{
				fmag = 10.0;
			}

			for ( i = 0; i < 2; i++ )
			{
				v_stochastic[ i ] += frametime * gEngfuncs.pfnRandomFloat( -fmag, fmag );
				v_stochastic[ i ] = max( -15.0, v_stochastic[ i ] );
				v_stochastic[ i ] = min( 15.0, v_stochastic[ i ] );
			}

			v_stochastic[ 2 ] = 0.0;
		}
		*/

		viewangles = viewangles + v_stochastic;

		NormalizeAngles( viewangles );
	}
	else
	{
		viewangles = vec3_origin;

		if ( Bench_InStage( FIRST_STAGE ) )
		{
			viewangles[ 1 ] = -90;
		}
	}

	if ( cmd )
	{
		if ( Bench_InStage( THIRD_STAGE ) )
		{
			cmd->buttons = IN_ATTACK;
		}
		else
		{
			cmd->buttons = 0;
		}
	}
}
Пример #5
0
bool CHudBenchmark::Draw( float flTime )
{
	char sz[ 256 ];
	int x, y;

	if ( m_fDrawTime < flTime || !Bench_Active() )
	{
		m_iFlags &= ~HUD_ACTIVE;
		return true;
	}

	x = 10;
	y = 25; //480 - 150;

	sprintf( sz, "%s: %s", g_title , pp_strings[ Bench_GetPowerPlay() ? 0 : 1]);

	gHUD.DrawHudString( x, y, 320, sz, 251, 237, 7);// , 200, 200); //255, 255, 255 );

	y += 20;
	
//	sprintf( sz, pp_strings[ Bench_GetPowerPlay() ? 0 : 1 ] );

//	gHUD.DrawHudString( x, y, 320, sz, 31, 200, 200 );

//	y += 20;

	
	if ( Bench_InStage( FIRST_STAGE) /*|| Bench_InStage( SECOND_STAGE ) || Bench_InStage( THIRD_STAGE )*/ || Bench_InStage( FOURTH_STAGE ) )
	{
		if ( m_fReceiveTime && m_nSentFinish )
		{
			sprintf( sz, g_stage1[1], Bench_ScoreForValue( FIRST_STAGE, m_StoredLatency ));
		}
		else
		{
			strcpy( sz, g_stage1[0] );
		}
		gHUD.DrawHudString( x, y, 320, sz, 255, 255, 255 );

		y += 20;

	}


	if ( Bench_InStage( SECOND_STAGE )/* || Bench_InStage( THIRD_STAGE )*/ || Bench_InStage( FOURTH_STAGE ) )
	{
		float avg = 0.0;
		
		if ( m_nFPSCount > 0 )
		{
			avg = m_fAverageFT / (float)m_nFPSCount;
			m_fAvgFrameRate = 1.0 / avg;
		}

		if ( m_nSentFinish /* Bench_InStage( THIRD_STAGE ) */|| Bench_InStage( FOURTH_STAGE ) )
		{
			sprintf( sz, g_stage2[1], Bench_ScoreForValue( SECOND_STAGE, m_fAvgFrameRate ) );
		}
		else
		{
			strcpy( sz, g_stage2[0] );
		}
		gHUD.DrawHudString( x, y, 320, sz, 255, 255, 255 );
		y += 20;
	}


	if ( Bench_InStage( THIRD_STAGE ) || Bench_InStage( FOURTH_STAGE ) )
	{
		if ( m_nSentFinish || Bench_InStage( FOURTH_STAGE ) )
		{
			sprintf( sz, g_stage3[1], Bench_ScoreForValue( THIRD_STAGE, m_fAvgScore ) );
		}
		else
		{
			strcpy( sz, g_stage3[0] );
		}

		gHUD.DrawHudString( x, y, 320, sz, 255, 255, 255 );

		y += 20;
	}

	if ( Bench_InStage( FOURTH_STAGE ) )
	{
		sprintf( sz, g_stage4, m_nCompositeScore );
		gHUD.DrawHudString( x, y, 320, sz, 31, 200, 200 );
	}

	m_fDrawTime = gHUD.m_flTime + BENCH_TIME;

	return true;
}
Пример #6
0
void CHudBenchmark::Think( void )
{
	if ( !Bench_Active() )
		return;

	Trace_Think();

	if ( started )
	{
		started = 0;

		// Clear variable
		m_fReceiveTime = 0.0;
		m_nFPSCount = 0;
		m_fAverageFT = 0.0;
		m_nSentFinish = 0;
		m_StoredLatency = 0.0;
		m_StoredPacketLoss = 0.0;
		m_nStoredHopCount = 0;
		m_nTraceDone = 0;
		m_nObjects = 0;
		m_nScoreComputed = 0;
		m_nCompositeScore = 0;
		m_fAvgScore = 0;
		m_fDrawScore = 0.0;
		m_fAvgFrameRate = 0.0;
	}

	if ( gHUD.m_flTime > g_benchSwitchTime )
	{
		Bench_SetStage( Bench_GetStage() + 1 );
		StartNextSection( Bench_GetStage() );
	}

	if ( Bench_InStage( FIRST_STAGE ) )
	{
		// Assume 1000 ms lag is the max and that would take all but 2 seconds of this interval to traverse
		if ( m_fReceiveTime )
		{
			float latency = 2.0 * m_StoredLatency;
			float switch_time;
			float total_time;
			
			latency = max( 0.0f, latency );
			latency = min( 1.0f, latency );

			total_time = Bench_GetSwitchTime();
			total_time -= 2.0;

			switch_time = m_fStageStarted + latency * total_time;
			switch_time += 1.0;

			if ( gHUD.m_flTime >= switch_time )
			{
				if ( !m_nSentFinish )
				{
					g_benchSwitchTime = gHUD.m_flTime + 1.0 + SCORE_TIME_UP;

					ServerCmd( "ppdemo 1 finish\n" );
					m_nSentFinish = 1;
				}
			}
			else
			{
				g_benchSwitchTime = gHUD.m_flTime + 10.0;
			}
		}
	}

	if ( Bench_InStage( SECOND_STAGE ) )
	{
		// frametime
		static float lasttime;
		float elapsed;
		float total;
		float frac;
		float switch_time;	// added by minman

		if ( lasttime )
		{
			float dt;

			dt = gHUD.m_flTime - lasttime;
			if ( dt > 0 )
			{
				CountFrame( dt );
			}
		}
		lasttime = gHUD.m_flTime;

		elapsed = gHUD.m_flTime - m_fStageStarted;
		total = Bench_GetSwitchTime();
		if ( total )
		{
			frac = elapsed / total;

			// Only takes 1/2 time to get up to maximum speed
			frac *= 2.0;
			frac = max( 0.0f, frac );
			frac = min( 1.0f, frac );

			m_nObjects = (int)(NUM_BENCH_OBJ * frac);
		}
		switch_time = m_fStageStarted + total;

		/* BELOW ADDED BY minman */
		if (gHUD.m_flTime >= switch_time)
		{
			if ( !m_nSentFinish)
			{
				g_benchSwitchTime = gHUD.m_flTime + SCORE_TIME_UP;
				m_nSentFinish = 1;
			}
		}
		else
			g_benchSwitchTime = gHUD.m_flTime + 10.0;
	}

	/* BELOW ADDED BY minman */
	if ( Bench_InStage (THIRD_STAGE))
	{
		float switch_time = m_fStageStarted + Bench_GetSwitchTime();

		if (gHUD.m_flTime >= switch_time)
		{
			if ( !m_nSentFinish)
			{
				g_benchSwitchTime = gHUD.m_flTime + SCORE_TIME_UP;
				m_nSentFinish = 1;
			}
		}
		else
			g_benchSwitchTime = gHUD.m_flTime + 10.0;
	}

	if ( Bench_InStage( FOURTH_STAGE ) )
	{
		if ( !m_nScoreComputed )
		{
			m_nScoreComputed = 1;
			gHUD.m_Benchmark.SetCompositeScore();
		}
	}

	if ( Bench_GetStage() > LAST_STAGE )
	{
		m_iFlags &= ~HUD_ACTIVE;
		EngineClientCmd( "quit\n" );
	}
}
Пример #7
0
/*
================
CL_CreateMove

Send the intended movement message to the server
if active == 1 then we are 1) not playing back demos ( where our commands are ignored ) and
2 ) we have finished signing on to server
================
*/
void CL_DLLEXPORT CL_CreateMove ( float frametime, struct usercmd_s *cmd, int active )
{	
//	RecClCL_CreateMove(frametime, cmd, active);

	float spd;
	vec3_t viewangles;
	static vec3_t oldangles;

	if ( active && !Bench_Active() )
	{
		//memset( viewangles, 0, sizeof( vec3_t ) );
		//viewangles[ 0 ] = viewangles[ 1 ] = viewangles[ 2 ] = 0.0;
		gEngfuncs.GetViewAngles( (float *)viewangles );

		CL_AdjustAngles ( frametime, viewangles );

		memset (cmd, 0, sizeof(*cmd));
		
		gEngfuncs.SetViewAngles( (float *)viewangles );

		if ( in_strafe.state & 1 )
		{
			cmd->sidemove += cl_sidespeed->value * CL_KeyState (&in_right);
			cmd->sidemove -= cl_sidespeed->value * CL_KeyState (&in_left);
		}

		cmd->sidemove += cl_sidespeed->value * CL_KeyState (&in_moveright);
		cmd->sidemove -= cl_sidespeed->value * CL_KeyState (&in_moveleft);

		cmd->upmove += cl_upspeed->value * CL_KeyState (&in_up);
		cmd->upmove -= cl_upspeed->value * CL_KeyState (&in_down);

		if ( !(in_klook.state & 1 ) )
		{	
			cmd->forwardmove += cl_forwardspeed->value * CL_KeyState (&in_forward);
			cmd->forwardmove -= cl_backspeed->value * CL_KeyState (&in_back);
		}	

		// adjust for speed key
		if ( in_speed.state & 1 )
		{
			cmd->forwardmove *= cl_movespeedkey->value;
			cmd->sidemove *= cl_movespeedkey->value;
			cmd->upmove *= cl_movespeedkey->value;
		}

		// clip to maxspeed
		spd = gEngfuncs.GetClientMaxspeed();
		if ( spd != 0.0 )
		{
			// scale the 3 speeds so that the total velocity is not > cl.maxspeed
			float fmov = sqrt( (cmd->forwardmove*cmd->forwardmove) + (cmd->sidemove*cmd->sidemove) + (cmd->upmove*cmd->upmove) );

			if ( fmov > spd )
			{
				float fratio = spd / fmov;
				cmd->forwardmove *= fratio;
				cmd->sidemove *= fratio;
				cmd->upmove *= fratio;
			}
		}

		// Allow mice and other controllers to add their inputs
		IN_Move ( frametime, cmd );
	}

	cmd->impulse = in_impulse;
	in_impulse = 0;

	cmd->weaponselect = g_weaponselect;
	g_weaponselect = 0;
	//
	// set button and flag bits
	//
	cmd->buttons = CL_ButtonBits( 1 );

	autofuncs::handle_autojump(cmd);

	// If they're in a modal dialog, ignore the attack button.
	if(GetClientVoiceMgr()->IsInSquelchMode())
		cmd->buttons &= ~IN_ATTACK;

	// Using joystick?
	if ( in_joystick->value )
	{
		if ( cmd->forwardmove > 0 )
		{
			cmd->buttons |= IN_FORWARD;
		}
		else if ( cmd->forwardmove < 0 )
		{
			cmd->buttons |= IN_BACK;
		}
	}

	gEngfuncs.GetViewAngles( (float *)viewangles );
	// Set current view angles.

	if ( g_iAlive )
	{
		VectorCopy( viewangles, cmd->viewangles );
		VectorCopy( viewangles, oldangles );
	}
	else
	{
		VectorCopy( oldangles, cmd->viewangles );
	}

	Bench_SetViewAngles( 1, (float *)&cmd->viewangles, frametime, cmd );
}
Пример #8
0
void Bench_SetViewAngles( int recalc_wander, float *viewangles, float frametime, struct usercmd_s *cmd )
{
	if ( !Bench_Active() )
		return;

	int i;
	vec3_t lookdir;

	// Clear stochastic offset between runs
	if ( Bench_InStage( FIRST_STAGE ) )
	{
		VectorCopy( vec3_origin, v_stochastic );
	}

	if ( Bench_InStage( SECOND_STAGE ) || Bench_InStage( THIRD_STAGE ) )
	{
		VectorSubtract( g_aimorg, v_origin, lookdir );
		VectorNormalize( lookdir );
		VectorAngles( (float *)&lookdir, viewangles );
		
		viewangles[0] = -viewangles[0];

		/*
		if ( recalc_wander )
		{
			float fmag = 2.0;
			if ( Bench_GetPowerPlay() )
			{
				fmag = 10.0;
			}

			for ( i = 0; i < 2; i++ )
			{
				v_stochastic[ i ] += frametime * gEngfuncs.pfnRandomFloat( -fmag, fmag );
				v_stochastic[ i ] = max( -15.0, v_stochastic[ i ] );
				v_stochastic[ i ] = min( 15.0, v_stochastic[ i ] );
			}

			v_stochastic[ 2 ] = 0.0;
		}
		*/

		VectorAdd( viewangles, v_stochastic, viewangles );

		for ( i = 0; i < 3; i++ )
		{
			if ( viewangles[ i ] > 180 )
				viewangles[ i ] -= 360;
			if ( viewangles[ i ] < -180 )
				viewangles[ i ] += 360;
		}
	}
	else
	{
		VectorCopy( vec3_origin, viewangles )

		if ( Bench_InStage( FIRST_STAGE ) )
		{
			viewangles[ 1 ] = -90;
		}
	}

	if ( cmd )
	{
		if ( Bench_InStage( THIRD_STAGE ) )
		{
			cmd->buttons = IN_ATTACK;
		}
		else
		{
			cmd->buttons = 0;
		}
	}
}
Пример #9
0
// Redraw
// step through the local data,  placing the appropriate graphics & text as appropriate
// returns 1 if they've changed, 0 otherwise
int CHud :: Redraw( float flTime, int intermission )
{
	m_fOldTime = m_flTime;	// save time of previous redraw
	m_flTime = flTime;
	m_flTimeDelta = (double)m_flTime - m_fOldTime;
	static float m_flShotTime = 0;

	// Clock was reset, reset delta
	if ( m_flTimeDelta < 0 )
		m_flTimeDelta = 0;

	// Bring up the scoreboard during intermission
	if (gViewPort)
	{
		if ( m_iIntermission && !intermission )
		{
			// Have to do this here so the scoreboard goes away
			m_iIntermission = intermission;
			gViewPort->HideCommandMenu();
			gViewPort->HideScoreBoard();
			gViewPort->UpdateSpectatorPanel();
		}
		else if ( !m_iIntermission && intermission )
		{
			m_iIntermission = intermission;
			gViewPort->HideCommandMenu();
			gViewPort->HideVGUIMenu();
			gViewPort->ShowScoreBoard();
			gViewPort->UpdateSpectatorPanel();

			// Take a screenshot if the client's got the cvar set
			if ( CVAR_GET_FLOAT( "hud_takesshots" ) != 0 )
				m_flShotTime = flTime + 1.0;	// Take a screenshot in a second
		}
	}

	if (m_flShotTime && m_flShotTime < flTime)
	{
		gEngfuncs.pfnClientCmd("snapshot\n");
		m_flShotTime = 0;
	}

	m_iIntermission = intermission;

	// if no redrawing is necessary
	// return 0;

	// draw all registered HUD elements
	if ( m_pCvarDraw->value )
	{
		HUDLIST *pList = m_pHudList;

		while (pList)
		{
			if ( !Bench_Active() )
			{
				if ( !intermission )
				{
					if ( (pList->p->m_iFlags & HUD_ACTIVE) && !(m_iHideHUDDisplay & HIDEHUD_ALL) )
						pList->p->Draw(flTime);
				}
				else
				{  // it's an intermission,  so only draw hud elements that are set to draw during intermissions
					if ( pList->p->m_iFlags & HUD_INTERMISSION )
						pList->p->Draw( flTime );
				}
			}
			else
			{
				if ( ( pList->p == &m_Benchmark ) &&
					 ( pList->p->m_iFlags & HUD_ACTIVE ) &&
					 !( m_iHideHUDDisplay & HIDEHUD_ALL ) )
				{
					pList->p->Draw(flTime);
				}
			}

			pList = pList->pNext;
		}
	}

	// are we in demo mode? do we need to draw the logo in the top corner?
	if (m_iLogo)
	{
		int x, y, i;

		if (m_hsprLogo == 0)
			m_hsprLogo = LoadSprite("sprites/%d_logo.spr");

		SPR_Set(m_hsprLogo, 250, 250, 250 );

		x = SPR_Width(m_hsprLogo, 0);
		x = ScreenWidth - x;
		y = SPR_Height(m_hsprLogo, 0)/2;

		// Draw the logo at 20 fps
		int iFrame = (int)(flTime * 20) % MAX_LOGO_FRAMES;
		i = grgLogoFrame[iFrame] - 1;

		SPR_DrawAdditive(i, x, y, NULL);
	}

	/*
	if ( g_iVisibleMouse )
	{
		void IN_GetMousePos( int *mx, int *my );
		int mx, my;

		IN_GetMousePos( &mx, &my );

		if (m_hsprCursor == 0)
		{
			char sz[256];
			sprintf( sz, "sprites/cursor.spr" );
			m_hsprCursor = SPR_Load( sz );
		}

		SPR_Set(m_hsprCursor, 250, 250, 250 );

		// Draw the logo at 20 fps
		SPR_DrawAdditive( 0, mx, my, NULL );
	}
	*/

	return 1;
}