PVS Studio fixes for GL1 renderer

This commit is contained in:
Daniel Gibson 2020-02-08 21:12:06 +01:00 committed by Yamagi
parent 9f22f3d298
commit 00127cc912
8 changed files with 32 additions and 59 deletions

View file

@ -35,7 +35,7 @@ Mod_DecompressVis
byte *
Mod_DecompressVis(byte *in, int row)
{
static byte decompressed[MAX_MAP_LEAFS / 8];
YQ2_ALIGNAS_TYPE(int) static byte decompressed[MAX_MAP_LEAFS / 8];
int c;
byte *out;

View file

@ -354,21 +354,17 @@ R_FloodFillSkin(byte *skin, int skinwidth, int skinheight)
byte fillcolor = *skin; /* assume this is the pixel to fill */
floodfill_t fifo[FLOODFILL_FIFO_SIZE];
int inpt = 0, outpt = 0;
int filledcolor = -1;
int filledcolor = 0;
int i;
if (filledcolor == -1)
// NOTE: there was a if(filledcolor == -1) which didn't make sense b/c filledcolor used to be initialized to -1
/* attempt to find opaque black */
for (i = 0; i < 256; ++i)
{
filledcolor = 0;
/* attempt to find opaque black */
for (i = 0; i < 256; ++i)
if (LittleLong(d_8to24table[i]) == (255 << 0)) /* alpha 1.0 */
{
if (LittleLong(d_8to24table[i]) == (255 << 0)) /* alpha 1.0 */
{
filledcolor = i;
break;
}
filledcolor = i;
break;
}
}
@ -658,6 +654,7 @@ R_Upload32Soft(unsigned *data, int width, int height, qboolean mipmap)
if (scaled_width * scaled_height > sizeof(scaled) / 4)
{
// this can't really happen (because they're clamped to 256 above), but whatever
ri.Sys_Error(ERR_DROP, "R_Upload32: too big");
}

View file

@ -219,6 +219,7 @@ R_RecursiveLightPoint(mnode_t *node, vec3_t start, vec3_t end)
byte *lightmap;
int maps;
int r;
vec3_t scale;
if (node->contents != -1)
{
@ -297,29 +298,24 @@ R_RecursiveLightPoint(mnode_t *node, vec3_t start, vec3_t end)
lightmap = surf->samples;
VectorCopy(vec3_origin, pointcolor);
if (lightmap)
lightmap += 3 * (dt * ((surf->extents[0] >> 4) + 1) + ds);
for (maps = 0; maps < MAXLIGHTMAPS && surf->styles[maps] != 255;
maps++)
{
vec3_t scale;
int j;
lightmap += 3 * (dt * ((surf->extents[0] >> 4) + 1) + ds);
for (maps = 0; maps < MAXLIGHTMAPS && surf->styles[maps] != 255;
maps++)
for (j = 0; j < 3; j++)
{
int j;
for (j = 0; j < 3; j++)
{
scale[j] = r_modulate->value *
r_newrefdef.lightstyles[surf->styles[maps]].rgb[j];
}
pointcolor[0] += lightmap[0] * scale[0] * (1.0 / 255);
pointcolor[1] += lightmap[1] * scale[1] * (1.0 / 255);
pointcolor[2] += lightmap[2] * scale[2] * (1.0 / 255);
lightmap += 3 * ((surf->extents[0] >> 4) + 1) *
((surf->extents[1] >> 4) + 1);
scale[j] = r_modulate->value *
r_newrefdef.lightstyles[surf->styles[maps]].rgb[j];
}
pointcolor[0] += lightmap[0] * scale[0] * (1.0 / 255);
pointcolor[1] += lightmap[1] * scale[1] * (1.0 / 255);
pointcolor[2] += lightmap[2] * scale[2] * (1.0 / 255);
lightmap += 3 * ((surf->extents[0] >> 4) + 1) *
((surf->extents[1] >> 4) + 1);
}
return 1;

View file

@ -202,8 +202,6 @@ LM_BuildPolygonFromSurface(msurface_t *fa)
poly->verts[i][5] = s;
poly->verts[i][6] = t;
}
poly->numverts = lnumverts;
}
void
@ -246,7 +244,7 @@ LM_BeginBuildingLightmaps(model_t *m)
{
static lightstyle_t lightstyles[MAX_LIGHTSTYLES];
int i;
unsigned dummy[128 * 128];
unsigned dummy[128 * 128] = {0};
memset(gl_lms.allocated, 0, sizeof(gl_lms.allocated));

View file

@ -425,7 +425,7 @@ R_DrawParticles2(int num_particles, const particle_t particles[],
int i;
vec3_t up, right;
float scale;
byte color[4];
YQ2_ALIGNAS_TYPE(unsigned) byte color[4];
GLfloat vtx[3*num_particles*3];
GLfloat tex[2*num_particles*3];
@ -459,7 +459,7 @@ R_DrawParticles2(int num_particles, const particle_t particles[],
scale = 1 + scale * 0.004;
}
*(int *) color = colortable [ p->color ];
*(unsigned *) color = colortable [ p->color ];
for (j=0; j<3; j++) // Copy the color for each point
{
@ -522,7 +522,7 @@ R_DrawParticles(void)
if (gl_config.pointparameters && !(stereo_split_tb || stereo_split_lr))
{
int i;
unsigned char color[4];
YQ2_ALIGNAS_TYPE(unsigned) byte color[4];
const particle_t *p;
GLfloat vtx[3*r_newrefdef.num_particles];
@ -1343,18 +1343,7 @@ R_SetMode(void)
}
else
{
if (err == rserr_invalid_fullscreen)
{
ri.Cvar_SetValue("vid_fullscreen", 0);
vid_fullscreen->modified = false;
R_Printf(PRINT_ALL, "ref_gl::R_SetMode() - fullscreen unavailable in this mode\n");
if ((err = SetMode_impl(&vid.width, &vid.height, r_mode->value, 0)) == rserr_ok)
{
return true;
}
}
else if (err == rserr_invalid_mode)
if (err == rserr_invalid_mode)
{
R_Printf(PRINT_ALL, "ref_gl::R_SetMode() - invalid mode\n");
if (gl_msaa_samples->value != 0.0f)

View file

@ -30,7 +30,7 @@
model_t *loadmodel;
int modfilelen;
byte mod_novis[MAX_MAP_LEAFS / 8];
YQ2_ALIGNAS_TYPE(int) byte mod_novis[MAX_MAP_LEAFS / 8];
model_t mod_known[MAX_MOD_KNOWN];
int mod_numknown;
int registration_sequence;
@ -964,7 +964,7 @@ Mod_LoadBrushModel(model_t *mod, void *buffer, int modfilelen)
hunkSize += calcLumpHunkSize(&header->lumps[LUMP_VERTEXES], sizeof(dvertex_t), sizeof(mvertex_t));
hunkSize += calcLumpHunkSize(&header->lumps[LUMP_EDGES], sizeof(dedge_t), sizeof(medge_t));
hunkSize += sizeof(medge_t) + 31; // for count+1 in Mod_LoadEdges()
float surfEdgeCount = header->lumps[LUMP_SURFEDGES].filelen/sizeof(int);
int surfEdgeCount = (header->lumps[LUMP_SURFEDGES].filelen+sizeof(int)-1)/sizeof(int);
if(surfEdgeCount < MAX_MAP_SURFEDGES) // else it errors out later anyway
hunkSize += calcLumpHunkSize(&header->lumps[LUMP_SURFEDGES], sizeof(int), sizeof(int));
hunkSize += calcLumpHunkSize(&header->lumps[LUMP_LIGHTING], 1, 1);

View file

@ -190,12 +190,6 @@ R_DrawGLPolyChain(glpoly_t *p, float soffset, float toffset)
v = p->verts[0];
if (v == NULL)
{
fprintf(stderr, "BUGFIX: R_DrawGLPolyChain: v==NULL\n");
return;
}
glEnableClientState( GL_VERTEX_ARRAY );
glEnableClientState( GL_TEXTURE_COORD_ARRAY );
@ -976,7 +970,7 @@ void
R_MarkLeaves(void)
{
byte *vis;
byte fatvis[MAX_MAP_LEAFS / 8];
YQ2_ALIGNAS_TYPE(int) byte fatvis[MAX_MAP_LEAFS / 8];
mnode_t *node;
int i, c;
mleaf_t *leaf;

View file

@ -119,7 +119,6 @@ typedef enum
{
rserr_ok,
rserr_invalid_fullscreen,
rserr_invalid_mode,
rserr_unknown