From 025210812d786fa832c8ebc6efba7d4a058a051d Mon Sep 17 00:00:00 2001 From: Scott Brooks Date: Sat, 11 Jul 2009 03:06:29 +0000 Subject: [PATCH] cg_RQ3_drawSpeed cvar to print player movement speed in units per second --- reaction/code/cgame/cg_draw.c | 30 ++++++++++++++++++++++++++++++ reaction/code/cgame/cg_local.h | 1 + reaction/code/cgame/cg_main.c | 4 ++++ 3 files changed, 35 insertions(+) diff --git a/reaction/code/cgame/cg_draw.c b/reaction/code/cgame/cg_draw.c index a389ecd9..13f5b9c6 100644 --- a/reaction/code/cgame/cg_draw.c +++ b/reaction/code/cgame/cg_draw.c @@ -755,6 +755,33 @@ static float CG_DrawAttacker(float y) return y + BIGCHAR_HEIGHT + 2; } +static float CG_DrawSpeed(float y) +{ + char *s; + int w; + int x = 0; + float Color[4]; + vec3_t vel; + + VectorCopy( cg.snap->ps.velocity, vel ); + vel[2] = 0.0f; + + y += 4; + s = va("%3.0f UPS", VectorLength(vel) ); + w = CG_DrawStrlen(s) * SMALLCHAR_WIDTH; + x = w; + + MAKERGBA(Color, 0.0f, 0.0f, 0.0f, 0.4f); + CG_FillRect(631 - x - 3, y - 1, w + 6, SMALLCHAR_HEIGHT + 6, Color); + + MAKERGBA(Color, 0.0f, 0.0f, 0.0f, 1.0f); + CG_DrawCleanRect(631 - x - 3, y - 1, w + 6, SMALLCHAR_HEIGHT + 6, 1, Color); + + CG_DrawSmallString(631 - x, y + 2, s, 1.0F); + + return y + SMALLCHAR_HEIGHT + 4; +} + /* ================== CG_DrawSnapshot @@ -1203,6 +1230,9 @@ static void CG_DrawUpperRight(void) if (cg_drawAttacker.integer) y = CG_DrawAttacker(y); + + if (cg_RQ3_drawSpeed.integer) + y = CG_DrawSpeed(y); } /* diff --git a/reaction/code/cgame/cg_local.h b/reaction/code/cgame/cg_local.h index d09e1ac2..a850b663 100644 --- a/reaction/code/cgame/cg_local.h +++ b/reaction/code/cgame/cg_local.h @@ -1881,6 +1881,7 @@ extern vmCvar_t cg_RQ3_ammo_m3; extern vmCvar_t cg_RQ3_ammo_ssg3000; extern vmCvar_t cg_RQ3_ammo_mp5; extern vmCvar_t cg_RQ3_ammo_m4; +extern vmCvar_t cg_RQ3_drawSpeed; extern vmCvar_t cg_RQ3_zcam_stfu; diff --git a/reaction/code/cgame/cg_main.c b/reaction/code/cgame/cg_main.c index 08389be8..65a8113d 100644 --- a/reaction/code/cgame/cg_main.c +++ b/reaction/code/cgame/cg_main.c @@ -557,6 +557,8 @@ vmCvar_t cg_RQ3_ammo_ssg3000; vmCvar_t cg_RQ3_ammo_mp5; vmCvar_t cg_RQ3_ammo_m4; +vmCvar_t cg_RQ3_drawSpeed; + vmCvar_t cg_RQ3_zcam_stfu; //Elder: muzzle flash toggle @@ -836,6 +838,8 @@ static cvarTable_t cvarTable[] = { // bk001129 {&cg_RQ3_ammo_mp5, "cg_RQ3_ammo_mp5", "mp5/default", CVAR_ARCHIVE}, {&cg_RQ3_ammo_m4, "cg_RQ3_ammo_m4", "m4/default", CVAR_ARCHIVE}, + {&cg_RQ3_drawSpeed, "cg_RQ3_drawSpeed", "0", CVAR_ARCHIVE}, + {&cg_RQ3_zcam_stfu, "cg_RQ3_zcam_stfu", "0", CVAR_USERINFO | CVAR_ARCHIVE}, // the following variables are created in other parts of the system,