mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-23 04:42:32 +00:00
Do a bit of bound() usage auditing.
While these seem to be mostly harmless, having function calls in the bounded value can be nasty.
This commit is contained in:
parent
a822a683cd
commit
6fe32103ea
3 changed files with 58 additions and 44 deletions
|
@ -106,6 +106,12 @@ gl_Fog_Update (float density, float red, float green, float blue, float time)
|
|||
static void
|
||||
Fog_FogCommand_f (void)
|
||||
{
|
||||
float density = fog_density;
|
||||
float red = fog_red;
|
||||
float green = fog_green;
|
||||
float blue = fog_blue;
|
||||
float time = 0.0;
|
||||
|
||||
switch (Cmd_Argc ()) {
|
||||
default:
|
||||
case 1:
|
||||
|
@ -118,37 +124,38 @@ Fog_FogCommand_f (void)
|
|||
Sys_Printf (" \"red\" is \"%f\"\n", fog_red);
|
||||
Sys_Printf (" \"green\" is \"%f\"\n", fog_green);
|
||||
Sys_Printf (" \"blue\" is \"%f\"\n", fog_blue);
|
||||
break;
|
||||
return;
|
||||
case 2:
|
||||
gl_Fog_Update (max (0.0, atof (Cmd_Argv (1))),
|
||||
fog_red, fog_green, fog_blue, 0.0);
|
||||
density = atof (Cmd_Argv(1));
|
||||
break;
|
||||
case 3: //TEST
|
||||
gl_Fog_Update (max (0.0, atof (Cmd_Argv (1))),
|
||||
fog_red, fog_green, fog_blue, atof (Cmd_Argv (2)));
|
||||
density = atof (Cmd_Argv(1));
|
||||
time = atof (Cmd_Argv(2));
|
||||
break;
|
||||
case 4:
|
||||
gl_Fog_Update (fog_density,
|
||||
bound (0.0, atof (Cmd_Argv (1)), 1.0),
|
||||
bound (0.0, atof (Cmd_Argv (2)), 1.0),
|
||||
bound (0.0, atof (Cmd_Argv (3)), 1.0),
|
||||
0.0);
|
||||
red = atof (Cmd_Argv(1));
|
||||
green = atof (Cmd_Argv(2));
|
||||
blue = atof (Cmd_Argv(3));
|
||||
break;
|
||||
case 5:
|
||||
gl_Fog_Update (max (0.0, atof (Cmd_Argv (1))),
|
||||
bound (0.0, atof (Cmd_Argv (2)), 1.0),
|
||||
bound (0.0, atof (Cmd_Argv (3)), 1.0),
|
||||
bound (0.0, atof (Cmd_Argv (4)), 1.0),
|
||||
0.0);
|
||||
density = atof (Cmd_Argv(1));
|
||||
red = atof (Cmd_Argv(2));
|
||||
green = atof (Cmd_Argv(3));
|
||||
blue = atof (Cmd_Argv(4));
|
||||
break;
|
||||
case 6: //TEST
|
||||
gl_Fog_Update (max (0.0, atof (Cmd_Argv (1))),
|
||||
bound (0.0, atof (Cmd_Argv (2)), 1.0),
|
||||
bound (0.0, atof (Cmd_Argv (3)), 1.0),
|
||||
bound (0.0, atof (Cmd_Argv (4)), 1.0),
|
||||
atof (Cmd_Argv (5)));
|
||||
density = atof (Cmd_Argv(1));
|
||||
red = atof (Cmd_Argv(2));
|
||||
green = atof (Cmd_Argv(3));
|
||||
blue = atof (Cmd_Argv(4));
|
||||
time = atof (Cmd_Argv(5));
|
||||
break;
|
||||
}
|
||||
density = max (0.0, density);
|
||||
red = bound (0.0, red, 1.0);
|
||||
green = bound (0.0, green, 1.0);
|
||||
blue = bound (0.0, blue, 1.0);
|
||||
gl_Fog_Update (density, red, green, blue, time);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -106,6 +106,12 @@ glsl_Fog_Update (float density, float red, float green, float blue, float time)
|
|||
static void
|
||||
Fog_FogCommand_f (void)
|
||||
{
|
||||
float density = fog_density;
|
||||
float red = fog_red;
|
||||
float green = fog_green;
|
||||
float blue = fog_blue;
|
||||
float time = 0.0;
|
||||
|
||||
switch (Cmd_Argc ()) {
|
||||
default:
|
||||
case 1:
|
||||
|
@ -118,38 +124,38 @@ Fog_FogCommand_f (void)
|
|||
Sys_Printf (" \"red\" is \"%f\"\n", fog_red);
|
||||
Sys_Printf (" \"green\" is \"%f\"\n", fog_green);
|
||||
Sys_Printf (" \"blue\" is \"%f\"\n", fog_blue);
|
||||
break;
|
||||
return;
|
||||
case 2:
|
||||
glsl_Fog_Update (max (0.0, atof (Cmd_Argv (1))),
|
||||
fog_red, fog_green, fog_blue, 0.0);
|
||||
density = atof (Cmd_Argv(1));
|
||||
break;
|
||||
case 3: //TEST
|
||||
glsl_Fog_Update (max (0.0, atof (Cmd_Argv (1))),
|
||||
fog_red, fog_green, fog_blue,
|
||||
atof (Cmd_Argv (2)));
|
||||
density = atof (Cmd_Argv(1));
|
||||
time = atof (Cmd_Argv(2));
|
||||
break;
|
||||
case 4:
|
||||
glsl_Fog_Update (fog_density,
|
||||
bound (0.0, atof (Cmd_Argv (1)), 1.0),
|
||||
bound (0.0, atof (Cmd_Argv (2)), 1.0),
|
||||
bound (0.0, atof (Cmd_Argv (3)), 1.0),
|
||||
0.0);
|
||||
red = atof (Cmd_Argv(1));
|
||||
green = atof (Cmd_Argv(2));
|
||||
blue = atof (Cmd_Argv(3));
|
||||
break;
|
||||
case 5:
|
||||
glsl_Fog_Update (max (0.0, atof (Cmd_Argv (1))),
|
||||
bound (0.0, atof (Cmd_Argv (2)), 1.0),
|
||||
bound (0.0, atof (Cmd_Argv (3)), 1.0),
|
||||
bound (0.0, atof (Cmd_Argv (4)), 1.0),
|
||||
0.0);
|
||||
density = atof (Cmd_Argv(1));
|
||||
red = atof (Cmd_Argv(2));
|
||||
green = atof (Cmd_Argv(3));
|
||||
blue = atof (Cmd_Argv(4));
|
||||
break;
|
||||
case 6: //TEST
|
||||
glsl_Fog_Update (max (0.0, atof (Cmd_Argv (1))),
|
||||
bound (0.0, atof (Cmd_Argv (2)), 1.0),
|
||||
bound (0.0, atof (Cmd_Argv (3)), 1.0),
|
||||
bound (0.0, atof (Cmd_Argv (4)), 1.0),
|
||||
atof (Cmd_Argv (5)));
|
||||
density = atof (Cmd_Argv(1));
|
||||
red = atof (Cmd_Argv(2));
|
||||
green = atof (Cmd_Argv(3));
|
||||
blue = atof (Cmd_Argv(4));
|
||||
time = atof (Cmd_Argv(5));
|
||||
break;
|
||||
}
|
||||
density = max (0.0, density);
|
||||
red = bound (0.0, red, 1.0);
|
||||
green = bound (0.0, green, 1.0);
|
||||
blue = bound (0.0, blue, 1.0);
|
||||
glsl_Fog_Update (density, red, green, blue, time);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -168,9 +168,10 @@ CL_PredictMove (void)
|
|||
// now interpolate some fraction of the final frame
|
||||
if (to->senttime == from->senttime)
|
||||
f = 0;
|
||||
else
|
||||
f = bound (0, (cl.time - from->senttime) /
|
||||
(to->senttime - from->senttime), 1);
|
||||
else {
|
||||
f = (cl.time - from->senttime) / (to->senttime - from->senttime);
|
||||
f = bound (0, f, 1);
|
||||
}
|
||||
|
||||
for (i = 0; i < 3; i++)
|
||||
if (fabs (from->playerstate[cl.playernum].pls.origin[i] -
|
||||
|
|
Loading…
Reference in a new issue