diff --git a/src/client/menu/menu.c b/src/client/menu/menu.c index bf7a5ea6..992c5eb9 100644 --- a/src/client/menu/menu.c +++ b/src/client/menu/menu.c @@ -1559,7 +1559,7 @@ static const char *idcredits[] = { "Marty Stratton", "Henk Hartong", "", - "+Patches authors:" + "+Patches authors:", "PGM", "PMM", "eliasm", diff --git a/src/client/refresh/soft/header/local.h b/src/client/refresh/soft/header/local.h index 34c81de1..dc81c521 100644 --- a/src/client/refresh/soft/header/local.h +++ b/src/client/refresh/soft/header/local.h @@ -65,7 +65,7 @@ typedef struct image_s int width, height; qboolean transparent; // true if any 255 pixels in image int registration_sequence; // 0 = free - byte *pixels[NUM_MIPS]; // mip levels + byte *pixels[NUM_MIPS]; // mip levels } image_t; diff --git a/src/client/refresh/soft/header/model.h b/src/client/refresh/soft/header/model.h index e0fdd3b8..e04f3031 100644 --- a/src/client/refresh/soft/header/model.h +++ b/src/client/refresh/soft/header/model.h @@ -118,7 +118,7 @@ typedef struct msurface_s #define CONTENTS_NODE -1 typedef struct mnode_s { -// common with leaf + // common with leaf int contents; // CONTENTS_NODE, to differentiate from leafs int visframe; // node needs to be traversed if current diff --git a/src/client/refresh/soft/sw_bsp.c b/src/client/refresh/soft/sw_bsp.c index c5330d6d..d45cdf33 100644 --- a/src/client/refresh/soft/sw_bsp.c +++ b/src/client/refresh/soft/sw_bsp.c @@ -38,14 +38,10 @@ typedef enum {touchessolid, drawnode, nodrawnode} solidstate_t; #define MAX_BMODEL_VERTS 500 // 6K #define MAX_BMODEL_EDGES 1000 // 12K -static mvertex_t *pbverts; -static bedge_t *pbedges; static int numbverts, numbedges; static mvertex_t bverts[MAX_BMODEL_VERTS]; static bedge_t bedges[MAX_BMODEL_EDGES]; -static mvertex_t *pfrontenter, *pfrontexit; - //=========================================================================== /* @@ -157,12 +153,11 @@ R_RecursiveClipBPoly(entity_t *currententity, bedge_t *pedges, mnode_t *pnode, m { bedge_t *psideedges[2], *pnextedge, *ptedge; int i, side, lastside; - float frac; mplane_t *splitplane, tplane; mvertex_t *pvert, *plastvert, *ptvert; mnode_t *pn; - int area; qboolean makeclippededge; + mvertex_t *pfrontenter = bverts, *pfrontexit = bverts; psideedges[0] = psideedges[1] = NULL; @@ -206,13 +201,15 @@ R_RecursiveClipBPoly(entity_t *currententity, bedge_t *pedges, mnode_t *pnode, m if (side != lastside) { + float frac; + // clipped if (numbverts >= MAX_BMODEL_VERTS) return; // generate the clipped vertex frac = lastdist / (lastdist - dist); - ptvert = &pbverts[numbverts++]; + ptvert = &bverts[numbverts++]; ptvert->position[0] = plastvert->position[0] + frac * (pvert->position[0] - plastvert->position[0]); @@ -232,13 +229,13 @@ R_RecursiveClipBPoly(entity_t *currententity, bedge_t *pedges, mnode_t *pnode, m return; } - ptedge = &pbedges[numbedges]; + ptedge = &bedges[numbedges]; ptedge->pnext = psideedges[lastside]; psideedges[lastside] = ptedge; ptedge->v[0] = plastvert; ptedge->v[1] = ptvert; - ptedge = &pbedges[numbedges + 1]; + ptedge = &bedges[numbedges + 1]; ptedge->pnext = psideedges[side]; psideedges[side] = ptedge; ptedge->v[0] = ptvert; @@ -267,7 +264,7 @@ R_RecursiveClipBPoly(entity_t *currententity, bedge_t *pedges, mnode_t *pnode, m // if anything was clipped, reconstitute and add the edges along the clip // plane to both sides (but in opposite directions) - if (makeclippededge) + if (makeclippededge && pfrontexit != pfrontenter) { if (numbedges >= (MAX_BMODEL_EDGES - 2)) { @@ -275,13 +272,13 @@ R_RecursiveClipBPoly(entity_t *currententity, bedge_t *pedges, mnode_t *pnode, m return; } - ptedge = &pbedges[numbedges]; + ptedge = &bedges[numbedges]; ptedge->pnext = psideedges[0]; psideedges[0] = ptedge; ptedge->v[0] = pfrontexit; ptedge->v[1] = pfrontenter; - ptedge = &pbedges[numbedges + 1]; + ptedge = &bedges[numbedges + 1]; ptedge->pnext = psideedges[1]; psideedges[1] = ptedge; ptedge->v[0] = pfrontenter; @@ -308,6 +305,8 @@ R_RecursiveClipBPoly(entity_t *currententity, bedge_t *pedges, mnode_t *pnode, m { if (r_newrefdef.areabits) { + int area; + area = ((mleaf_t *)pn)->area; if (! (r_newrefdef.areabits[area>>3] & (1<<(area&7)) ) ) continue; // not visible @@ -337,12 +336,10 @@ Bmodel crosses multiple leafs void R_DrawSolidClippedSubmodelPolygons(entity_t *currententity, const model_t *currentmodel, mnode_t *topnode) { - int i, j, lindex; - vec_t dot; + int i; msurface_t *psurf; - int numsurfaces; - bedge_t *pbedge; - medge_t *pedge, *pedges; + int numsurfaces; + medge_t *pedges; // FIXME: use bounding-box-based frustum clipping info? psurf = ¤tmodel->surfaces[currentmodel->firstmodelsurface]; @@ -352,6 +349,10 @@ R_DrawSolidClippedSubmodelPolygons(entity_t *currententity, const model_t *curre for (i=0 ; iplane; @@ -369,14 +370,14 @@ R_DrawSolidClippedSubmodelPolygons(entity_t *currententity, const model_t *curre // clockwise winding // FIXME: if edges and vertices get caches, these assignments must move // outside the loop, and overflow checking must be done here - pbverts = bverts; - pbedges = bedges; numbverts = numbedges = 0; pbedge = &bedges[numbedges]; numbedges += psurf->numedges; for (j=0 ; jnumedges ; j++) { + int lindex; + lindex = currentmodel->surfedges[psurf->firstedge+j]; if (lindex > 0) diff --git a/src/client/refresh/soft/sw_draw.c b/src/client/refresh/soft/sw_draw.c index d612f246..b849673d 100644 --- a/src/client/refresh/soft/sw_draw.c +++ b/src/client/refresh/soft/sw_draw.c @@ -35,19 +35,15 @@ RE_Draw_FindPic image_t * RE_Draw_FindPic (char *name) { - image_t *image; - if (name[0] != '/' && name[0] != '\\') { char fullname[MAX_QPATH]; Com_sprintf (fullname, sizeof(fullname), "pics/%s.pcx", name); - image = R_FindImage (fullname, it_pic); + return R_FindImage (fullname, it_pic); } else - image = R_FindImage (name+1, it_pic); - - return image; + return R_FindImage (name+1, it_pic); } diff --git a/src/client/refresh/soft/sw_image.c b/src/client/refresh/soft/sw_image.c index d4dcd01a..2d2544bd 100644 --- a/src/client/refresh/soft/sw_image.c +++ b/src/client/refresh/soft/sw_image.c @@ -174,6 +174,9 @@ R_LoadPic (char *name, byte *pic, int width, int height, imagetype_t type) image_t *image; size_t i, size, full_size; + if (!pic) + return NULL; + image = R_FindFreeImage(); if (strlen(name) >= sizeof(image->name)) ri.Sys_Error(ERR_DROP, "%s: '%s' is too long", __func__, name); diff --git a/src/client/refresh/soft/sw_light.c b/src/client/refresh/soft/sw_light.c index 63117855..58918bfc 100644 --- a/src/client/refresh/soft/sw_light.c +++ b/src/client/refresh/soft/sw_light.c @@ -48,9 +48,9 @@ R_MarkLights (dlight_t *light, int bit, mnode_t *node, int r_dlightframecount) splitplane = node->plane; dist = DotProduct (light->origin, splitplane->normal) - splitplane->dist; - i=light->intensity; - if(i<0) - i=-i; + i = light->intensity; + if( i< 0) + i = -i; if (dist > i) // (dist > light->intensity) { diff --git a/src/client/refresh/soft/sw_main.c b/src/client/refresh/soft/sw_main.c index 62b3a63f..f8114528 100644 --- a/src/client/refresh/soft/sw_main.c +++ b/src/client/refresh/soft/sw_main.c @@ -20,6 +20,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // sw_main.c #include +#include #include #include @@ -782,8 +783,8 @@ RotatedBBox (const vec3_t mins, const vec3_t maxs, vec3_t angles, vec3_t tmins, for (i=0 ; i<3 ; i++) { - tmins[i] = 99999; - tmaxs[i] = -99999; + tmins[i] = INT_MAX; // Set maximum values for world range + tmaxs[i] = INT_MIN; // Set minimal values for world range } AngleVectors (angles, forward, right, up); @@ -1469,6 +1470,9 @@ static int RE_PrepareForWindow(void) return flags; } +// Declared in vid/header/ref.h +refexport_t re; + /* =============== GetRefAPI @@ -1477,8 +1481,6 @@ GetRefAPI Q2_DLL_EXPORTED refexport_t GetRefAPI(refimport_t imp) { - refexport_t re; - memset(&re, 0, sizeof(refexport_t)); ri = imp; diff --git a/src/client/refresh/soft/sw_misc.c b/src/client/refresh/soft/sw_misc.c index 994e29d1..12213eb2 100644 --- a/src/client/refresh/soft/sw_misc.c +++ b/src/client/refresh/soft/sw_misc.c @@ -203,7 +203,7 @@ R_SetUpFrustumIndexes (void) } } - // FIXME: do just once at start + // FIXME: do just once at start pfrustum_indexes[i] = pindex; pindex += 6; } diff --git a/src/client/refresh/soft/sw_model.c b/src/client/refresh/soft/sw_model.c index 900c133a..38a444e6 100644 --- a/src/client/refresh/soft/sw_model.c +++ b/src/client/refresh/soft/sw_model.c @@ -22,6 +22,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // models are the only shared resource between a client and server running // on the same machine. +#include #include "header/local.h" model_t *loadmodel; @@ -366,7 +367,7 @@ Mod_LoadVertexes (lump_t *l) count = l->filelen / sizeof(*in); out = Hunk_Alloc((count+8)*sizeof(*out)); // extra for skybox /* - * This patch fixes the problem where the games dumped core + * Fix for the problem where the games dumped core * when changing levels. */ memset( out, 0, (count + 6) * sizeof( *out ) ); @@ -509,7 +510,7 @@ Mod_LoadTexinfo (lump_t *l) if (next > 0) out->next = loadmodel->texinfo + next; /* - * This patch fixes the problem where the game + * Fix for the problem where the game * domed core when loading a new level. */ else { @@ -550,8 +551,8 @@ CalcSurfaceExtents (msurface_t *s) mtexinfo_t *tex; int bmins[2], bmaxs[2]; - mins[0] = mins[1] = 999999; - maxs[0] = maxs[1] = -99999; + mins[0] = mins[1] = INT_MAX; // Set maximum values for world range + maxs[0] = maxs[1] = INT_MIN; // Set minimal values for world range tex = s->texinfo; diff --git a/src/client/refresh/soft/sw_poly.c b/src/client/refresh/soft/sw_poly.c index 40d54292..3f89c067 100644 --- a/src/client/refresh/soft/sw_poly.c +++ b/src/client/refresh/soft/sw_poly.c @@ -18,6 +18,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include +#include #include "header/local.h" #define AFFINE_SPANLET_SIZE 16 @@ -48,7 +49,7 @@ static emitpoint_t outverts[MAXWORKINGVERTS+3]; static int s_minindex, s_maxindex; -static void R_DrawPoly(int iswater); +static void R_DrawPoly(int iswater, espan_t *spans); /* ** R_DrawSpanletOpaque @@ -1019,7 +1020,7 @@ R_ClipAndDrawPoly ( float alpha, int isturbulent, qboolean textured ) r_polydesc.nump = nump; r_polydesc.pverts = outverts; - R_DrawPoly(isturbulent); + R_DrawPoly(isturbulent, vid_polygon_spans); } /* @@ -1151,18 +1152,16 @@ R_PolygonCalculateGradients (void) */ // iswater was qboolean. changed to support passing more flags static void -R_DrawPoly(int iswater) +R_DrawPoly(int iswater, espan_t *spans) { int i, nump; float ymin, ymax; emitpoint_t *pverts; - espan_t *spans; - spans = vid_polygon_spans; // find the top and bottom vertices, and make sure there's at least one scan to // draw - ymin = 999999.9; - ymax = -999999.9; + ymin = INT_MAX; // Set maximum values for world range + ymax = INT_MIN; // Set minimal values for world range pverts = r_polydesc.pverts; for (i=0 ; i= 0) { - // both points are unclipped + // both points are unclipped continue; }