Skip to content
Permalink
Browse files

Add cg_drawSpeedometer cvar to enable speedometer for showing

player speed in Quake units per second. Displays in upper right corner
under the match clock.
Source code from the q3mme project. https://github.com/entdark/q3mme
  • Loading branch information...
cdev-tux committed Oct 31, 2017
1 parent 19ba242 commit 9680f6913b7b574697ca0ed844d810fd069cb040
Showing with 35 additions and 1 deletion.
  1. +28 −0 code/cgame/cg_draw.c
  2. +4 −0 code/cgame/cg_local.h
  3. +3 −1 code/cgame/cg_main.c
@@ -794,6 +794,31 @@ static float CG_DrawTimer( float y ) {
return y + BIGCHAR_HEIGHT + 4;
}

/*
==================
CG_DrawSpeedometer
==================
*/

static float CG_DrawSpeedometer( float y ) {
char *s;
float speed;
vec3_t velocity;
int w;

if (!cg_drawSpeedometer.integer || !cg.snap) {
return y;
}

VectorCopy(cg.predictedPlayerState.velocity, velocity);
speed = sqrt(velocity[0] * velocity[0] + velocity[1] * velocity[1]);
s = va( "%iups", ((int)speed));
w = CG_DrawStrlen( s ) * BIGCHAR_WIDTH;
CG_DrawBigString( 635 - w, y + 2, s, 1.0F);

return y + BIGCHAR_HEIGHT + 4;

}

/*
=================
@@ -993,6 +1018,9 @@ static void CG_DrawUpperRight(stereoFrame_t stereoFrame)
if ( cg_drawTimer.integer ) {
y = CG_DrawTimer( y );
}
if ( cg_drawSpeedometer.integer ) {
y = CG_DrawSpeedometer( y );
}
if ( cg_drawAttacker.integer ) {
CG_DrawAttacker( y );
}
@@ -486,6 +486,9 @@ typedef struct {

qboolean renderingThirdPerson; // during deaths, chasecams, etc

qboolean playerPredicted;
centity_t *playerCent;

// prediction state
qboolean hyperspace; // true if prediction has hit a trigger_teleport
playerState_t predictedPlayerState;
@@ -1179,6 +1182,7 @@ extern vmCvar_t cg_oldPlasma;
extern vmCvar_t cg_trueLightning;
extern vmCvar_t cg_nochatbeeps;
extern vmCvar_t cg_novotebeeps;
extern vmCvar_t cg_drawSpeedometer;
#ifdef MISSIONPACK
extern vmCvar_t cg_redTeamName;
extern vmCvar_t cg_blueTeamName;
@@ -187,6 +187,7 @@ vmCvar_t cg_oldPlasma;
vmCvar_t cg_trueLightning;
vmCvar_t cg_nochatbeeps;
vmCvar_t cg_novotebeeps;
vmCvar_t cg_drawSpeedometer;

#ifdef MISSIONPACK
vmCvar_t cg_redTeamName;
@@ -324,7 +325,8 @@ static cvarTable_t cvarTable[] = {
{ &cg_oldPlasma, "cg_oldPlasma", "1", CVAR_ARCHIVE},
{ &cg_trueLightning, "cg_trueLightning", "0.0", CVAR_ARCHIVE},
{ &cg_nochatbeeps, "cg_nochatbeeps", "0", CVAR_ARCHIVE},
{ &cg_novotebeeps, "cg_novotebeeps", "0", CVAR_ARCHIVE}
{ &cg_novotebeeps, "cg_novotebeeps", "0", CVAR_ARCHIVE},
{ &cg_drawSpeedometer, "cg_drawSpeedometer", "0", CVAR_ARCHIVE}
// { &cg_pmove_fixed, "cg_pmove_fixed", "0", CVAR_USERINFO | CVAR_ARCHIVE }
};

0 comments on commit 9680f69

Please sign in to comment.
You can’t perform that action at this time.