PVS Studio fixes for GL3 renderer

This commit is contained in:
Daniel Gibson 2020-02-09 05:30:05 +01:00 committed by Yamagi
parent 00127cc912
commit b3f61f20d4
7 changed files with 29 additions and 53 deletions

View file

@ -312,21 +312,16 @@ 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)
/* 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;
}
}

View file

@ -189,6 +189,8 @@ RecursiveLightPoint(mnode_t *node, vec3_t start, vec3_t end)
for (i = 0; i < node->numsurfaces; i++, surf++)
{
vec3_t scale;
if (surf->flags & (SURF_DRAWTURB | SURF_DRAWSKY))
{
continue; /* no lightmaps */
@ -224,27 +226,22 @@ 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 < MAX_LIGHTMAPS_PER_SURFACE && surf->styles[maps] != 255;
maps++)
{
vec3_t scale;
lightmap += 3 * (dt * ((surf->extents[0] >> 4) + 1) + ds);
for (maps = 0; maps < MAX_LIGHTMAPS_PER_SURFACE && surf->styles[maps] != 255;
maps++)
for (int j = 0; j < 3; j++)
{
for (int j = 0; j < 3; j++)
{
scale[j] = r_modulate->value *
gl3_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 *
gl3_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

@ -198,8 +198,6 @@ GL3_LM_BuildPolygonFromSurface(msurface_t *fa)
VectorCopy(normal, vert->normal);
vert->lightFlags = 0;
}
poly->numverts = lnumverts;
}
void

View file

@ -324,7 +324,6 @@ enum
{
rserr_ok,
rserr_invalid_fullscreen,
rserr_invalid_mode,
rserr_unknown
@ -393,18 +392,7 @@ GL3_SetMode(void)
}
else
{
if (err == rserr_invalid_fullscreen)
{
ri.Cvar_SetValue("vid_fullscreen", 0);
vid_fullscreen->modified = false;
R_Printf(PRINT_ALL, "ref_gl3::GL3_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_gl3::GL3_SetMode() - invalid mode\n");
@ -922,7 +910,7 @@ GL3_DrawParticles(void)
{
int i;
int numParticles = gl3_newrefdef.num_particles;
unsigned char color[4];
YQ2_ALIGNAS_TYPE(unsigned) byte color[4];
const particle_t *p;
// assume the size looks good with window height 480px and scale according to real resolution
float pointSize = gl3_particle_size->value * (float)gl3_newrefdef.height/480.0f;

View file

@ -30,7 +30,7 @@
enum { MAX_MOD_KNOWN = 512 };
static gl3model_t *loadmodel;
static byte mod_novis[MAX_MAP_LEAFS / 8];
YQ2_ALIGNAS_TYPE(int) static byte mod_novis[MAX_MAP_LEAFS / 8];
gl3model_t mod_known[MAX_MOD_KNOWN];
static int mod_numknown;
int registration_sequence;
@ -849,7 +849,7 @@ Mod_LoadBrushModel(gl3model_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

@ -806,10 +806,8 @@ initShader2D(gl3ShaderInfo_t* shaderInfo, const char* vertSrc, const char* fragS
return true;
err_cleanup:
if(shaders2D[0] != 0) glDeleteShader(shaders2D[0]);
if(shaders2D[1] != 0) glDeleteShader(shaders2D[1]);
if(prog != 0) glDeleteProgram(prog);
glDeleteProgram(prog);
return false;
}
@ -948,8 +946,8 @@ initShader3D(gl3ShaderInfo_t* shaderInfo, const char* vertSrc, const char* fragS
err_cleanup:
if(shaders3D[0] != 0) glDeleteShader(shaders3D[0]);
if(shaders3D[1] != 0) glDeleteShader(shaders3D[1]);
glDeleteShader(shaders3D[0]);
glDeleteShader(shaders3D[1]);
if(prog != 0) glDeleteProgram(prog);

View file

@ -852,7 +852,7 @@ void
GL3_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;