Rename cl_drawfps to cl_showfps, to be consistent with other cvar.

And ensure that a nice message is printed to the console if anyone
enters the old cvar.
This commit is contained in:
Yamagi Burmeister 2018-01-06 16:26:28 +01:00
parent 7ae9b38da1
commit 226e5922b9
4 changed files with 20 additions and 9 deletions

View file

@ -44,7 +44,7 @@ cvar_t *cl_noskins;
cvar_t *cl_footsteps;
cvar_t *cl_timeout;
cvar_t *cl_predict;
cvar_t *cl_drawfps;
cvar_t *cl_showfps;
cvar_t *cl_gun;
cvar_t *cl_add_particles;
cvar_t *cl_add_lights;
@ -483,7 +483,7 @@ CL_InitLocal(void)
cl_footsteps = Cvar_Get("cl_footsteps", "1", 0);
cl_noskins = Cvar_Get("cl_noskins", "0", 0);
cl_predict = Cvar_Get("cl_predict", "1", 0);
cl_drawfps = Cvar_Get("cl_drawfps", "0", CVAR_ARCHIVE);
cl_showfps = Cvar_Get("cl_showfps", "0", CVAR_ARCHIVE);
cl_upspeed = Cvar_Get("cl_upspeed", "200", 0);
cl_forwardspeed = Cvar_Get("cl_forwardspeed", "200", 0);

View file

@ -64,7 +64,7 @@ dirty_t scr_dirty, scr_old_dirty[2];
char crosshair_pic[MAX_QPATH];
int crosshair_width, crosshair_height;
extern cvar_t *cl_drawfps;
extern cvar_t *cl_showfps;
extern cvar_t *crosshair_scale;
void SCR_TimeRefresh_f(void);
@ -1430,7 +1430,7 @@ SCR_Framecounter(void) {
float scale = SCR_GetConsoleScale();
if (cl_drawfps->value == 1) {
if (cl_showfps->value == 1) {
// Calculate average of frames.
int avg = 0;
int num = 0;
@ -1446,7 +1446,7 @@ SCR_Framecounter(void) {
char str[10];
snprintf(str, sizeof(str), "%3.2ffps", (1000.0 * 1000.0) / (avg / num));
DrawStringScaled(viddef.width - scale*(strlen(str)*8 + 2), 0, str, scale);
} else if (cl_drawfps->value >= 2) {
} else if (cl_showfps->value >= 2) {
// Calculate average of frames.
int avg = 0;
int num = 0;
@ -1478,7 +1478,7 @@ SCR_Framecounter(void) {
(1000.0 * 1000.0) / min, (1000.0 * 1000.0) / max, (1000.0 * 1000.0) / (avg / num));
DrawStringScaled(viddef.width - scale*(strlen(str)*8 + 2), 0, str, scale);
if (cl_drawfps->value > 2)
if (cl_showfps->value > 2)
{
snprintf(str, sizeof(str), "Max: %5.2fms, Min: %5.2fms, Avg: %5.2fms",
0.001f*min, 0.001f*max, 0.001f*(avg / num));

View file

@ -37,6 +37,7 @@ typedef struct
/* An ugly hack to rewrite CVARs loaded from config.cfg */
replacement_t replacements[] = {
{"cl_drawfps", "cl_showfps"}
};
@ -65,9 +66,21 @@ static cvar_t *
Cvar_FindVar(const char *var_name)
{
cvar_t *var;
int i;
for (var = cvar_vars; var; var = var->next)
{
/* An ugly hack to rewrite changed CVARs */
for (i = 0; i < sizeof(replacements) / sizeof(replacement_t); i++)
{
if (!strcmp(var_name, replacements[i].old))
{
Com_Printf("cvar %s ist deprecated, use %s instead\n", replacements[i].old, replacements[i].new);
var_name = replacements[i].new;
}
}
if (!strcmp(var_name, var->name))
{
return var;
@ -438,8 +451,6 @@ Cvar_Set_f(void)
{
if (!strcmp(firstarg, replacements[i].old))
{
Com_Printf("cvar %s ist deprecated, use %s instead\n", replacements[i].old, replacements[i].new);
firstarg = replacements[i].new;
}
}

View file

@ -27,7 +27,7 @@ General:
If *cl_async* is set to `0` *gl_maxfps* is the same as *cl_maxfps*, use
*cl_maxfps* to set the framerate.
* **cl_drawfps**: Shows the framecounter. The shown value is rather
* **cl_showfps**: Shows the framecounter. The shown value is rather
inaccurate and gets less precise with higher framerates, as it only
measures full milliseconds.