Skip to content

Commit

Permalink
Add ‘scr_lag_min’ variable.
Browse files Browse the repository at this point in the history
  • Loading branch information
skullernet committed Dec 18, 2012
1 parent 4603dbf commit 203191b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
4 changes: 4 additions & 0 deletions doc/client.txt
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,10 @@ scr_lag_y::
counted in pixels from the screen edge. Negative values align graph to the bottom
edge of the screen intead of the top edge. Default value is -1.

scr_lag_min::
Specifies ping graph offset by defining the minimum value that can be
displayed. Default value is 0.

scr_lag_max::
Specifies ping graph scale by defining the maximum value that can be
displayed. Default value is 200.
Expand Down
17 changes: 12 additions & 5 deletions src/client/screen.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ static cvar_t *scr_draw2d;
static cvar_t *scr_lag_x;
static cvar_t *scr_lag_y;
static cvar_t *scr_lag_draw;
static cvar_t *scr_lag_min;
static cvar_t *scr_lag_max;
static cvar_t *scr_alpha;

Expand Down Expand Up @@ -548,7 +549,14 @@ void SCR_LagSample(void)

static void draw_ping_graph(int x, int y)
{
int i, j, v, c, max = Cvar_ClampInteger(scr_lag_max, 16, 480);
int i, j, v, c, v_min, v_max, v_range;

v_min = Cvar_ClampInteger(scr_lag_min, 0, LAG_HEIGHT * 10);
v_max = Cvar_ClampInteger(scr_lag_max, 0, LAG_HEIGHT * 10);

v_range = v_max - v_min;
if (v_range < 1)
return;

for (i = 0; i < LAG_WIDTH; i++) {
j = lag.head - i - 1;
Expand All @@ -567,10 +575,8 @@ static void draw_ping_graph(int x, int y)
}

v &= ~(LAG_WARN_BIT | LAG_CRIT_BIT);
v = v * LAG_HEIGHT / max;
if (v > LAG_HEIGHT) {
v = LAG_HEIGHT;
}
v = (v - v_min) * LAG_HEIGHT / v_range;
clamp(v, 0, LAG_HEIGHT);

R_DrawFill8(x + LAG_WIDTH - i - 1, y + LAG_HEIGHT - v, 1, v, c);
}
Expand Down Expand Up @@ -1222,6 +1228,7 @@ void SCR_Init(void)
scr_lag_x = Cvar_Get("scr_lag_x", "-1", 0);
scr_lag_y = Cvar_Get("scr_lag_y", "-1", 0);
scr_lag_draw = Cvar_Get("scr_lag_draw", "0", 0);
scr_lag_min = Cvar_Get("scr_lag_min", "0", 0);
scr_lag_max = Cvar_Get("scr_lag_max", "200", 0);
scr_alpha = Cvar_Get("scr_alpha", "1", 0);
#ifdef _DEBUG
Expand Down

0 comments on commit 203191b

Please sign in to comment.