summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/cgame/cg_draw.c58
-rw-r--r--src/cgame/cg_local.h5
-rw-r--r--src/cgame/cg_main.c2
3 files changed, 65 insertions, 0 deletions
diff --git a/src/cgame/cg_draw.c b/src/cgame/cg_draw.c
index e5e1894..33a275a 100644
--- a/src/cgame/cg_draw.c
+++ b/src/cgame/cg_draw.c
@@ -3019,6 +3019,63 @@ static void CG_DrawCenterString( void )
//==============================================================================
+/*
+==============
+CG_DrawSpeed
+
+Ideally this should be a part of the HUD but that would require updating
+all the custom ones
+==============
+*/
+static void CG_DrawSpeed( void )
+{
+ vec4_t white = { 1.0f, 1.0f, 1.0f, 0.6f };
+ vec3_t xyvelocity;
+ int x, y;
+ float speed, dot;
+
+ switch( cg_drawSpeed.integer & 3 )
+ {
+ case 0:
+ return;
+
+ case 1:
+ x = 8;
+ y = 360;
+ break;
+
+ case 2:
+ x = 360;
+ y = 240;
+ break;
+
+ case 3:
+ x = 570;
+ y = 200;
+ break;
+ }
+
+ if( cg_drawSpeed.integer & 4 )
+ {
+ speed = VectorLength( cg.predictedPlayerState.velocity );
+ }
+ else
+ {
+ dot = DotProduct( cg.predictedPlayerState.velocity, cg.predictedPlayerState.grapplePoint );
+ VectorMA( cg.predictedPlayerState.velocity, -dot, cg.predictedPlayerState.grapplePoint, xyvelocity );
+ speed = VectorLength( xyvelocity );
+ }
+
+ if( speed > cg.topSpeed || cg.time > cg.topSpeedTime + 3000 )
+ {
+ cg.topSpeed = speed;
+ cg.topSpeedTime = cg.time;
+ }
+
+ CG_Text_Paint( x, y, 0.3f, white, va( "%.0f %.0f", cg.topSpeed, speed),
+ 0, 0, ITEM_TEXTSTYLE_NORMAL );
+}
+
//FIXME: both vote notes are hardcoded, change to ownerdrawn?
/*
@@ -3288,6 +3345,7 @@ static void CG_Draw2D( void )
else if( cg_drawStatus.integer )
Menu_Paint( defaultMenu, qtrue );
+ CG_DrawSpeed( );
CG_DrawVote( );
CG_DrawTeamVote( );
CG_DrawFollow( );
diff --git a/src/cgame/cg_local.h b/src/cgame/cg_local.h
index 83c3162..e68e94b 100644
--- a/src/cgame/cg_local.h
+++ b/src/cgame/cg_local.h
@@ -1140,6 +1140,10 @@ typedef struct
playerState_t savedPmoveStates[ NUM_SAVED_STATES ];
int stateHead, stateTail;
int ping;
+
+ // speedometer
+ float topSpeed;
+ int topSpeedTime;
} cg_t;
@@ -1429,6 +1433,7 @@ extern vmCvar_t cg_drawTeamOverlay;
extern vmCvar_t cg_teamOverlayUserinfo;
extern vmCvar_t cg_crosshairX;
extern vmCvar_t cg_crosshairY;
+extern vmCvar_t cg_drawSpeed;
extern vmCvar_t cg_drawStatus;
extern vmCvar_t cg_draw2D;
extern vmCvar_t cg_animSpeed;
diff --git a/src/cgame/cg_main.c b/src/cgame/cg_main.c
index c2e55b8..89a4c5c 100644
--- a/src/cgame/cg_main.c
+++ b/src/cgame/cg_main.c
@@ -138,6 +138,7 @@ vmCvar_t cg_drawCrosshairNames;
vmCvar_t cg_drawRewards;
vmCvar_t cg_crosshairX;
vmCvar_t cg_crosshairY;
+vmCvar_t cg_drawSpeed;
vmCvar_t cg_draw2D;
vmCvar_t cg_drawStatus;
vmCvar_t cg_animSpeed;
@@ -283,6 +284,7 @@ static cvarTable_t cvarTable[ ] =
{ &cg_drawRewards, "cg_drawRewards", "1", CVAR_ARCHIVE },
{ &cg_crosshairX, "cg_crosshairX", "0", CVAR_ARCHIVE },
{ &cg_crosshairY, "cg_crosshairY", "0", CVAR_ARCHIVE },
+ { &cg_drawSpeed, "cg_drawSpeed", "0", CVAR_ARCHIVE },
{ &cg_brassTime, "cg_brassTime", "2500", CVAR_ARCHIVE },
{ &cg_simpleItems, "cg_simpleItems", "0", CVAR_ARCHIVE },
{ &cg_addMarks, "cg_marks", "1", CVAR_ARCHIVE },