Okay, the big whitespace reformat. There is some silliness (case

statements, variable declarations), but all in all it's not bad.
This commit is contained in:
Jeff Teunissen 2000-12-08 06:51:37 +00:00
parent b62d75a774
commit 54e2a4d9d3
172 changed files with 26949 additions and 26640 deletions

View file

@ -27,7 +27,7 @@
*/
#ifdef HAVE_CONFIG_H
# include <config.h>
# include "config.h"
#endif
#include "host.h"
@ -40,14 +40,17 @@
#include "menu.h"
#include "cl_parse.h"
qboolean allowskybox; // whether or not to allow skyboxes --KB
qboolean allowskybox; // whether or not to allow skyboxes
// --KB
/*
===============
R_CheckVariables
===============
*/
void R_CheckVariables (void)
void
R_CheckVariables (void)
{
}
@ -59,9 +62,10 @@ Show
Debugging use
============
*/
void Show (void)
void
Show (void)
{
vrect_t vr;
vrect_t vr;
vr.x = vr.y = 0;
vr.width = vid.width;
@ -77,19 +81,19 @@ R_TimeRefresh_f
For program optimization
====================
*/
void R_TimeRefresh_f (void)
void
R_TimeRefresh_f (void)
{
int i;
float start, stop, time;
int startangle;
vrect_t vr;
int i;
float start, stop, time;
int startangle;
vrect_t vr;
startangle = r_refdef.viewangles[1];
start = Sys_DoubleTime ();
for (i=0 ; i<128 ; i++)
{
r_refdef.viewangles[1] = i/128.0*360.0;
for (i = 0; i < 128; i++) {
r_refdef.viewangles[1] = i / 128.0 * 360.0;
VID_LockBuffer ();
@ -105,9 +109,9 @@ void R_TimeRefresh_f (void)
VID_Update (&vr);
}
stop = Sys_DoubleTime ();
time = stop-start;
Con_Printf ("%f seconds (%f fps)\n", time, 128/time);
time = stop - start;
Con_Printf ("%f seconds (%f fps)\n", time, 128 / time);
r_refdef.viewangles[1] = startangle;
}
@ -118,13 +122,12 @@ void R_TimeRefresh_f (void)
void
R_LoadSky_f (void)
{
if (Cmd_Argc () != 2)
{
if (Cmd_Argc () != 2) {
Con_Printf ("loadsky <name> : load a skybox\n");
return;
}
R_LoadSkys (Cmd_Argv(1));
R_LoadSkys (Cmd_Argv (1));
}
@ -135,44 +138,43 @@ R_LineGraph
Only called by R_DisplayTime
================
*/
void R_LineGraph (int x, int y, int h)
void
R_LineGraph (int x, int y, int h)
{
int i;
byte *dest;
int s;
int color;
int i;
byte *dest;
int s;
int color;
// FIXME: should be disabled on no-buffer adapters, or should be in the driver
// x += r_refdef.vrect.x;
// y += r_refdef.vrect.y;
dest = vid.buffer + vid.rowbytes*y + x;
// x += r_refdef.vrect.x;
// y += r_refdef.vrect.y;
dest = vid.buffer + vid.rowbytes * y + x;
s = r_graphheight->int_val;
if (h == 10000)
color = 0x6f; // yellow
color = 0x6f; // yellow
else if (h == 9999)
color = 0x4f; // red
color = 0x4f; // red
else if (h == 9998)
color = 0xd0; // blue
color = 0xd0; // blue
else
color = 0xff; // pink
color = 0xff; // pink
if (h>s)
if (h > s)
h = s;
for (i=0 ; i<h ; i++, dest -= vid.rowbytes*2)
{
for (i = 0; i < h; i++, dest -= vid.rowbytes * 2) {
dest[0] = color;
// *(dest-vid.rowbytes) = 0x30;
// *(dest-vid.rowbytes) = 0x30;
}
#if 0
for ( ; i<s ; i++, dest -= vid.rowbytes*2)
{
for (; i < s; i++, dest -= vid.rowbytes * 2) {
dest[0] = 0x30;
*(dest-vid.rowbytes) = 0x30;
*(dest - vid.rowbytes) = 0x30;
}
#endif
}
@ -186,18 +188,19 @@ Performance monitoring tool
*/
#define MAX_TIMINGS 100
extern float mouse_x, mouse_y;
int graphval;
void R_TimeGraph (void)
int graphval;
void
R_TimeGraph (void)
{
static int timex;
int a;
float r_time2;
static byte r_timings[MAX_TIMINGS];
int x;
static int timex;
int a;
float r_time2;
static byte r_timings[MAX_TIMINGS];
int x;
r_time2 = Sys_DoubleTime ();
a = (r_time2-r_time1)/0.01;
a = (r_time2 - r_time1) / 0.01;
//a = fabs(mouse_y * 0.05);
//a = (int)((r_refdef.vieworg[2] + 1024)/1)%(int)r_graphheight->value;
//a = (int)((pmove.velocity[2] + 500)/10);
@ -205,28 +208,27 @@ void R_TimeGraph (void)
//a = ((int)fabs(origin[0])/8)%20;
//a = (cl.idealpitch + 30)/5;
//a = (int)(cl.simangles[YAW] * 64/360) & 63;
a = graphval;
a = graphval;
r_timings[timex] = a;
a = timex;
if (r_refdef.vrect.width <= MAX_TIMINGS)
x = r_refdef.vrect.width-1;
x = r_refdef.vrect.width - 1;
else
x = r_refdef.vrect.width -
(r_refdef.vrect.width - MAX_TIMINGS)/2;
do
{
R_LineGraph (x, r_refdef.vrect.height-2, r_timings[a]);
if (x==0)
break; // screen too small to hold entire thing
x = r_refdef.vrect.width - (r_refdef.vrect.width - MAX_TIMINGS) / 2;
do {
R_LineGraph (x, r_refdef.vrect.height - 2, r_timings[a]);
if (x == 0)
break; // screen too small to hold entire
// thing
x--;
a--;
if (a == -1)
a = MAX_TIMINGS-1;
a = MAX_TIMINGS - 1;
} while (a != timex);
timex = (timex+1)%MAX_TIMINGS;
timex = (timex + 1) % MAX_TIMINGS;
}
/*
@ -234,32 +236,32 @@ a = graphval;
R_NetGraph
==============
*/
void R_NetGraph (void)
void
R_NetGraph (void)
{
int a, x, y, y2, w, i;
int lost;
char st[80];
int a, x, y, y2, w, i;
int lost;
char st[80];
if (vid.width - 16 <= NET_TIMINGS)
w = vid.width - 16;
else
w = NET_TIMINGS;
x = w - ((vid.width - 320)>>1);
y = vid.height - sb_lines - 24 - r_graphheight->int_val*2 - 2;
x = w - ((vid.width - 320) >> 1);
y = vid.height - sb_lines - 24 - r_graphheight->int_val * 2 - 2;
M_DrawTextBox (x, y, (w+7)/8, (r_graphheight->int_val*2+7)/8 + 1);
M_DrawTextBox (x, y, (w + 7) / 8, (r_graphheight->int_val * 2 + 7) / 8 + 1);
y2 = y + 8;
y = vid.height - sb_lines - 8 - 2;
x = 8;
lost = CL_CalcNet();
for (a=NET_TIMINGS-w ; a<w ; a++)
{
i = (cls.netchan.outgoing_sequence-a) & NET_TIMINGSMASK;
R_LineGraph (x+w-1-a, y, packet_latency[i]);
lost = CL_CalcNet ();
for (a = NET_TIMINGS - w; a < w; a++) {
i = (cls.netchan.outgoing_sequence - a) & NET_TIMINGSMASK;
R_LineGraph (x + w - 1 - a, y, packet_latency[i]);
}
snprintf(st, sizeof(st), "%3i%% packet loss", lost);
snprintf (st, sizeof (st), "%3i%% packet loss", lost);
Draw_String8 (8, y2, st);
}
@ -268,23 +270,23 @@ void R_NetGraph (void)
R_ZGraph
==============
*/
void R_ZGraph (void)
void
R_ZGraph (void)
{
int a, x, w, i;
static int height[256];
int a, x, w, i;
static int height[256];
if (r_refdef.vrect.width <= 256)
w = r_refdef.vrect.width;
else
w = 256;
height[r_framecount&255] = ((int)r_origin[2]) & 31;
height[r_framecount & 255] = ((int) r_origin[2]) & 31;
x = 0;
for (a=0 ; a<w ; a++)
{
i = (r_framecount-a) & 255;
R_LineGraph (x+w-1-a, r_refdef.vrect.height-2, height[i]);
for (a = 0; a < w; a++) {
i = (r_framecount - a) & 255;
R_LineGraph (x + w - 1 - a, r_refdef.vrect.height - 2, height[i]);
}
}
@ -293,15 +295,16 @@ void R_ZGraph (void)
R_PrintTimes
=============
*/
void R_PrintTimes (void)
void
R_PrintTimes (void)
{
float r_time2;
float ms;
float r_time2;
float ms;
r_time2 = Sys_DoubleTime ();
ms = 1000* (r_time2 - r_time1);
ms = 1000 * (r_time2 - r_time1);
Con_Printf ("%5.1f ms %3i/%3i/%3i poly %3i surf\n",
ms, c_faceclip, r_polycount, r_drawnpolycount, c_surf);
c_surf = 0;
@ -313,9 +316,12 @@ void R_PrintTimes (void)
R_PrintDSpeeds
=============
*/
void R_PrintDSpeeds (void)
void
R_PrintDSpeeds (void)
{
float ms, dp_time, r_time2, rw_time, db_time, se_time, de_time, dv_time;
float ms, dp_time, r_time2, rw_time, db_time, se_time, de_time,
dv_time;
r_time2 = Sys_DoubleTime ();
@ -328,8 +334,8 @@ void R_PrintDSpeeds (void)
ms = (r_time2 - r_time1) * 1000;
Con_Printf ("%3i %4.1fp %3iw %4.1fb %3is %4.1fe %4.1fv\n",
(int)ms, dp_time, (int)rw_time, db_time, (int)se_time, de_time,
dv_time);
(int) ms, dp_time, (int) rw_time, db_time, (int) se_time,
de_time, dv_time);
}
@ -338,31 +344,32 @@ void R_PrintDSpeeds (void)
R_PrintAliasStats
=============
*/
void R_PrintAliasStats (void)
void
R_PrintAliasStats (void)
{
Con_Printf ("%3i polygon model drawn\n", r_amodels_drawn);
}
void WarpPalette (void)
void
WarpPalette (void)
{
int i,j;
byte newpalette[768];
int basecolor[3];
int i, j;
byte newpalette[768];
int basecolor[3];
basecolor[0] = 130;
basecolor[1] = 80;
basecolor[2] = 50;
// pull the colors halfway to bright brown
for (i=0 ; i<256 ; i++)
{
for (j=0 ; j<3 ; j++)
{
newpalette[i*3+j] = (host_basepal[i*3+j] + basecolor[j])/2;
for (i = 0; i < 256; i++) {
for (j = 0; j < 3; j++) {
newpalette[i * 3 + j] =
(host_basepal[i * 3 + j] + basecolor[j]) / 2;
}
}
VID_ShiftPalette (newpalette);
}
@ -372,20 +379,20 @@ void WarpPalette (void)
R_TransformFrustum
===================
*/
void R_TransformFrustum (void)
void
R_TransformFrustum (void)
{
int i;
vec3_t v, v2;
for (i=0 ; i<4 ; i++)
{
int i;
vec3_t v, v2;
for (i = 0; i < 4; i++) {
v[0] = screenedge[i].normal[2];
v[1] = -screenedge[i].normal[0];
v[2] = screenedge[i].normal[1];
v2[0] = v[1]*vright[0] + v[2]*vup[0] + v[0]*vpn[0];
v2[1] = v[1]*vright[1] + v[2]*vup[1] + v[0]*vpn[1];
v2[2] = v[1]*vright[2] + v[2]*vup[2] + v[0]*vpn[2];
v2[0] = v[1] * vright[0] + v[2] * vup[0] + v[0] * vpn[0];
v2[1] = v[1] * vright[1] + v[2] * vup[1] + v[0] * vpn[1];
v2[2] = v[1] * vright[2] + v[2] * vup[2] + v[0] * vpn[2];
VectorCopy (v2, view_clipplanes[i].normal);
@ -401,11 +408,12 @@ void R_TransformFrustum (void)
TransformVector
================
*/
void TransformVector (vec3_t in, vec3_t out)
void
TransformVector (vec3_t in, vec3_t out)
{
out[0] = DotProduct(in,vright);
out[1] = DotProduct(in,vup);
out[2] = DotProduct(in,vpn);
out[0] = DotProduct (in, vright);
out[1] = DotProduct (in, vup);
out[2] = DotProduct (in, vpn);
}
#endif
@ -416,10 +424,11 @@ void TransformVector (vec3_t in, vec3_t out)
R_TransformPlane
================
*/
void R_TransformPlane (mplane_t *p, float *normal, float *dist)
void
R_TransformPlane (mplane_t *p, float *normal, float *dist)
{
float d;
float d;
d = DotProduct (r_origin, p->normal);
*dist = p->dist - d;
// TODO: when we have rotating entities, this will need to use the view matrix
@ -432,29 +441,25 @@ void R_TransformPlane (mplane_t *p, float *normal, float *dist)
R_SetUpFrustumIndexes
===============
*/
void R_SetUpFrustumIndexes (void)
void
R_SetUpFrustumIndexes (void)
{
int i, j, *pindex;
int i, j, *pindex;
pindex = r_frustum_indexes;
for (i=0 ; i<4 ; i++)
{
for (j=0 ; j<3 ; j++)
{
if (view_clipplanes[i].normal[j] < 0)
{
for (i = 0; i < 4; i++) {
for (j = 0; j < 3; j++) {
if (view_clipplanes[i].normal[j] < 0) {
pindex[j] = j;
pindex[j+3] = j+3;
}
else
{
pindex[j] = j+3;
pindex[j+3] = j;
pindex[j + 3] = j + 3;
} else {
pindex[j] = j + 3;
pindex[j + 3] = j;
}
}
// FIXME: do just once at start
// FIXME: do just once at start
pfrustum_indexes[i] = pindex;
pindex += 6;
}
@ -466,23 +471,24 @@ void R_SetUpFrustumIndexes (void)
R_SetupFrame
===============
*/
void R_SetupFrame (void)
void
R_SetupFrame (void)
{
int edgecount;
vrect_t vrect;
float w, h;
int edgecount;
vrect_t vrect;
float w, h;
// don't allow cheats in multiplayer
Cvar_SetValue(r_draworder, 0);
Cvar_SetValue(r_ambient, 0);
Cvar_SetValue(r_drawflat, 0);
Cvar_SetValue (r_draworder, 0);
Cvar_SetValue (r_ambient, 0);
Cvar_SetValue (r_drawflat, 0);
if (r_numsurfs->int_val) {
if ((surface_p - surfaces) > r_maxsurfsseen)
r_maxsurfsseen = surface_p - surfaces;
Con_Printf ("Used %d of %d surfs; %d max\n", surface_p - surfaces,
surf_max - surfaces, r_maxsurfsseen);
surf_max - surfaces, r_maxsurfsseen);
}
if (r_numedges->int_val) {
@ -492,15 +498,15 @@ void R_SetupFrame (void)
r_maxedgesseen = edgecount;
Con_Printf ("Used %d of %d edges; %d max\n", edgecount,
r_numallocatededges, r_maxedgesseen);
r_numallocatededges, r_maxedgesseen);
}
r_refdef.ambientlight = max(r_ambient->value, 0);
r_refdef.ambientlight = max (r_ambient->value, 0);
Cvar_SetValue (r_draworder, 0);
Cvar_SetValue(r_draworder, 0);
R_CheckVariables ();
R_AnimateLight ();
r_framecount++;
@ -530,50 +536,42 @@ void R_SetupFrame (void)
r_dowarpold = r_dowarp;
r_dowarp = r_waterwarp->int_val && (r_viewleaf->contents <= CONTENTS_WATER);
if ((r_dowarp != r_dowarpold) || r_viewchanged)
{
if (r_dowarp)
{
if ((r_dowarp != r_dowarpold) || r_viewchanged) {
if (r_dowarp) {
if ((vid.width <= vid.maxwarpwidth) &&
(vid.height <= vid.maxwarpheight))
{
(vid.height <= vid.maxwarpheight)) {
vrect.x = 0;
vrect.y = 0;
vrect.width = vid.width;
vrect.height = vid.height;
R_ViewChanged (&vrect, sb_lines, vid.aspect);
}
else
{
} else {
w = vid.width;
h = vid.height;
if (w > vid.maxwarpwidth)
{
h *= (float)vid.maxwarpwidth / w;
if (w > vid.maxwarpwidth) {
h *= (float) vid.maxwarpwidth / w;
w = vid.maxwarpwidth;
}
if (h > vid.maxwarpheight)
{
if (h > vid.maxwarpheight) {
h = vid.maxwarpheight;
w *= (float)vid.maxwarpheight / h;
w *= (float) vid.maxwarpheight / h;
}
vrect.x = 0;
vrect.y = 0;
vrect.width = (int)w;
vrect.height = (int)h;
vrect.width = (int) w;
vrect.height = (int) h;
R_ViewChanged (&vrect,
(int)((float)sb_lines * (h/(float)vid.height)),
vid.aspect * (h / w) *
((float)vid.width / (float)vid.height));
(int) ((float) sb_lines *
(h / (float) vid.height)),
vid.aspect * (h / w) * ((float) vid.width /
(float) vid.height));
}
}
else
{
} else {
vrect.x = 0;
vrect.y = 0;
vrect.width = vid.width;
@ -584,7 +582,6 @@ void R_SetupFrame (void)
r_viewchanged = false;
}
// start off with just the four screen edge clip planes
R_TransformFrustum ();
@ -612,4 +609,3 @@ void R_SetupFrame (void)
D_SetupFrame ();
}