Merge pull request #778 from 0lvin/fixes

cppcheck fixes
This commit is contained in:
Yamagi 2022-01-22 10:51:21 +01:00 committed by GitHub
commit aa561bf50b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 109 additions and 70 deletions

View file

@ -1167,10 +1167,12 @@ Haptic_Feedback(char *name, int effect_volume, int effect_duration,
return;
}
/*
Com_Printf("%s: volume %d: %d ms %d:%d:%d ms speed: %.2f\n",
name, effect_volume, effect_duration - effect_end,
effect_begin, effect_attack, effect_fade,
(float)effect_volume / effect_fade);
*/
// FIFO for effects
last_haptic_efffect_pos = (last_haptic_efffect_pos+1) % last_haptic_efffect_size;

View file

@ -353,9 +353,10 @@ R_ImageList_f(void)
break;
}
R_Printf(PRINT_ALL, " %3i %3i %s: %s %s\n",
R_Printf(PRINT_ALL, " %3i %3i %s: %s (%dx%d) %s\n",
image->upload_width, image->upload_height,
palstrings[image->paletted], image->name, in_use);
palstrings[image->paletted], image->name,
image->width, image->height, in_use);
}
R_Printf(PRINT_ALL,
@ -951,9 +952,24 @@ R_LoadPic(char *name, byte *pic, int width, int realwidth,
// resize 8bit images only when we forced such logic
if (r_scale8bittextures->value)
{
byte *image_converted = malloc(width * height * 4);
scale2x(pic, image_converted, width, height);
image->has_alpha = R_Upload8(image_converted, width * 2, height * 2,
byte *image_converted;
int scale = 2;
// scale 3 times if lerp image
if (!nolerp && (vid.height >= 240 * 3))
scale = 3;
image_converted = malloc(width * height * scale * scale);
if (!image_converted)
return NULL;
if (scale == 3) {
scale3x(pic, image_converted, width, height);
} else {
scale2x(pic, image_converted, width, height);
}
image->has_alpha = R_Upload8(image_converted, width * scale, height * scale,
(image->type != it_pic && image->type != it_sky),
image->type == it_sky);
free(image_converted);

View file

@ -442,9 +442,24 @@ GL3_LoadPic(char *name, byte *pic, int width, int realwidth,
// resize 8bit images only when we forced such logic
if (r_scale8bittextures->value)
{
byte *image_converted = malloc(width * height * 4);
scale2x(pic, image_converted, width, height);
image->has_alpha = GL3_Upload8(image_converted, width * 2, height * 2,
byte *image_converted;
int scale = 2;
// scale 3 times if lerp image
if (!nolerp && (vid.height >= 240 * 3))
scale = 3;
image_converted = malloc(width * height * scale * scale);
if (!image_converted)
return NULL;
if (scale == 3) {
scale3x(pic, image_converted, width, height);
} else {
scale2x(pic, image_converted, width, height);
}
image->has_alpha = GL3_Upload8(image_converted, width * scale, height * scale,
(image->type != it_pic && image->type != it_sky),
image->type == it_sky);
free(image_converted);

View file

@ -411,7 +411,7 @@ extern float xscale, yscale;
extern float xscaleinv, yscaleinv;
extern float xscaleshrink, yscaleshrink;
extern void TransformVector(vec3_t in, vec3_t out);
extern void TransformVector(const vec3_t in, vec3_t out);
//===========================================================================
@ -532,7 +532,7 @@ extern qboolean r_outedgebasespans;
extern mvertex_t *r_pcurrentvertbase;
void R_DrawTriangle(const entity_t *currententity, const finalvert_t *a, const finalvert_t *b, const finalvert_t *c);
void R_AliasClipTriangle(const entity_t *currententity, const finalvert_t *index0, const finalvert_t *index1, finalvert_t *index2);
void R_AliasClipTriangle(const entity_t *currententity, const finalvert_t *index0, const finalvert_t *index1, const finalvert_t *index2);
extern float r_time1;
@ -590,7 +590,7 @@ void R_FreeUnusedImages(void);
qboolean R_ImageHasFreeSpace(void);
void R_InitSkyBox(model_t *loadmodel);
void R_IMFlatShadedQuad( vec3_t a, vec3_t b, vec3_t c, vec3_t d, int color, float alpha );
void R_IMFlatShadedQuad( const vec3_t a, const vec3_t b, const vec3_t c, const vec3_t d, int color, float alpha );
// VID Buffer damage
void VID_DamageBuffer(int u, int v);

View file

@ -222,7 +222,6 @@ typedef struct model_s
void Mod_Init(void);
mleaf_t *Mod_PointInLeaf(vec3_t p, const model_t *model);
const byte *Mod_ClusterPVS(int cluster, const model_t *model);
void Mod_Modellist_f(void);

View file

@ -221,7 +221,7 @@ R_AliasClipTriangle
================
*/
void
R_AliasClipTriangle(const entity_t *currententity, const finalvert_t *index0, const finalvert_t *index1, finalvert_t *index2)
R_AliasClipTriangle(const entity_t *currententity, const finalvert_t *index0, const finalvert_t *index1, const finalvert_t *index2)
{
int i, k, pingpong;
unsigned clipflags;

View file

@ -167,7 +167,7 @@ Clip a bmodel poly down the world bsp tree
static void
R_RecursiveClipBPoly(entity_t *currententity, bedge_t *pedges, mnode_t *pnode, msurface_t *psurf)
{
bedge_t *psideedges[2], *pnextedge, *ptedge;
bedge_t *psideedges[2], *pnextedge;
int i, side, lastside;
cplane_t *splitplane, tplane;
mvertex_t *pvert, *plastvert, *ptvert;
@ -192,6 +192,7 @@ R_RecursiveClipBPoly(entity_t *currententity, bedge_t *pedges, mnode_t *pnode, m
for (; pedges; pedges = pnextedge)
{
float dist, lastdist;
bedge_t *ptedge;
pnextedge = pedges->pnext;
@ -280,6 +281,8 @@ R_RecursiveClipBPoly(entity_t *currententity, bedge_t *pedges, mnode_t *pnode, m
// plane to both sides (but in opposite directions)
if (makeclippededge && pfrontexit != pfrontenter)
{
bedge_t *ptedge;
ptedge = &bedges[numbedges++];
ptedge->pnext = psideedges[0];
psideedges[0] = ptedge;
@ -358,7 +361,6 @@ R_DrawSolidClippedSubmodelPolygons(entity_t *currententity, const model_t *curre
{
cplane_t *pplane;
bedge_t *pbedge;
medge_t *pedge;
vec_t dot;
int j;
@ -390,12 +392,16 @@ R_DrawSolidClippedSubmodelPolygons(entity_t *currententity, const model_t *curre
if (lindex > 0)
{
medge_t *pedge;
pedge = &pedges[lindex];
pbedge[j].v[0] = &r_pcurrentvertbase[pedge->v[0]];
pbedge[j].v[1] = &r_pcurrentvertbase[pedge->v[1]];
}
else
{
medge_t *pedge;
lindex = -lindex;
pedge = &pedges[lindex];
pbedge[j].v[0] = &r_pcurrentvertbase[pedge->v[1]];
@ -410,6 +416,9 @@ R_DrawSolidClippedSubmodelPolygons(entity_t *currententity, const model_t *curre
if ( !( psurf->texinfo->flags & ( SURF_TRANS66 | SURF_TRANS33 ) ))
{
// FIXME: Fan broken in borehole
// teleport: 1231.000000 770.250000 -579.375000
// map: maps/mine2.bsp
// model texture: textures/e2u1/metal6_1.wal
R_RecursiveClipBPoly(currententity, pbedge, topnode, psurf);
}
else
@ -431,7 +440,6 @@ void
R_DrawSubmodelPolygons(entity_t *currententity, const model_t *currentmodel, int clipflags, mnode_t *topnode)
{
int i;
vec_t dot;
msurface_t *psurf;
int numsurfaces;
@ -441,6 +449,8 @@ R_DrawSubmodelPolygons(entity_t *currententity, const model_t *currentmodel, int
for (i=0 ; i<numsurfaces ; i++, psurf++)
{
vec_t dot;
cplane_t *pplane;
// find which side of the node we are on
pplane = psurf->plane;

View file

@ -990,7 +990,7 @@ To allow developers to see the polygon carving of the world
=============
*/
static void
D_DrawflatSurfaces (surf_t *surface)
D_DrawflatSurfaces (const surf_t *surface)
{
surf_t *s;
int color = 0;

View file

@ -325,7 +325,7 @@ R_LoadWal (char *name, imagetype_t type)
static unsigned char *d_16to8table; // 16 to 8 bit conversion table
static void
R_Convert32To8bit(unsigned char* pic_in, unsigned char* pic_out, size_t size)
R_Convert32To8bit(const unsigned char* pic_in, unsigned char* pic_out, size_t size)
{
size_t i;

View file

@ -1280,7 +1280,7 @@ R_SetLightLevel (const entity_t *currententity)
}
static int
VectorCompareRound(vec3_t v1, vec3_t v2)
VectorCompareRound(const vec3_t v1, const vec3_t v2)
{
if ((int)(v1[0] - v2[0]) || (int)(v1[1] - v2[1]) || (int)(v1[2] - v2[2]))
{
@ -1580,13 +1580,12 @@ R_GammaCorrectAndSetPalette( const unsigned char *palette )
static void
RE_SetPalette(const unsigned char *palette)
{
byte palette32[1024];
// clear screen to black to avoid any palette flash
RE_CleanFrame();
if (palette)
{
byte palette32[1024];
int i;
for ( i = 0; i < 256; i++ )

View file

@ -166,7 +166,7 @@ TransformVector
================
*/
void
TransformVector (vec3_t in, vec3_t out)
TransformVector (const vec3_t in, vec3_t out)
{
out[0] = DotProduct(in,vright);
out[1] = DotProduct(in,vup);
@ -216,7 +216,7 @@ Guaranteed to be called before the first refresh
===============
*/
static void
R_ViewChanged (vrect_t *vr)
R_ViewChanged (const vrect_t *vr)
{
int i;
float xOrigin, yOrigin;
@ -306,6 +306,39 @@ R_ViewChanged (vrect_t *vr)
D_ViewChanged ();
}
/*
===============
Mod_PointInLeaf
===============
*/
static mleaf_t *
Mod_PointInLeaf (const vec3_t p, const model_t *model)
{
mnode_t *node;
if (!model || !model->nodes)
{
ri.Sys_Error(ERR_DROP, "%s: bad model", __func__);
return NULL;
}
node = model->nodes;
while (node->contents == -1)
{
float d;
cplane_t *plane;
plane = node->plane;
d = DotProduct (p,plane->normal) - plane->dist;
if (d > 0)
node = node->children[0];
else
node = node->children[1];
}
return (mleaf_t *)node;
}
/*
===============

View file

@ -223,41 +223,6 @@ Mod_ForName (char *name, model_t *parent_model, qboolean crash)
return mod;
}
/*
===============
Mod_PointInLeaf
===============
*/
mleaf_t *
Mod_PointInLeaf (vec3_t p, const model_t *model)
{
mnode_t *node;
if (!model || !model->nodes)
{
ri.Sys_Error(ERR_DROP, "%s: bad model", __func__);
return NULL;
}
node = model->nodes;
while (node->contents == -1)
{
float d;
cplane_t *plane;
plane = node->plane;
d = DotProduct (p,plane->normal) - plane->dist;
if (d > 0)
node = node->children[0];
else
node = node->children[1];
}
return (mleaf_t *)node;
}
/*
==============
Mod_ClusterPVS

View file

@ -1248,7 +1248,7 @@ R_DrawAlphaSurfaces(const entity_t *currententity)
** R_IMFlatShadedQuad
*/
void
R_IMFlatShadedQuad( vec3_t a, vec3_t b, vec3_t c, vec3_t d, int color, float alpha )
R_IMFlatShadedQuad( const vec3_t a, const vec3_t b, const vec3_t c, const vec3_t d, int color, float alpha )
{
vec3_t s0, s1;

View file

@ -164,7 +164,7 @@ D_DrawTurbulentSpan (pixel_t *pdest, const pixel_t *pbase,
int s, int t,
int sstep, int tstep,
int spancount,
int *turb)
const int *turb)
{
do
{

View file

@ -717,7 +717,7 @@ OGG_LoadAsWav(char *filename, wavinfo_t *info, void **buffer)
void * temp_buffer = NULL;
int size = FS_LoadFile(filename, &temp_buffer);
short *final_buffer = NULL;
stb_vorbis * ogg_file = NULL;
stb_vorbis * ogg2wav_file = NULL;
int res = 0;
if (!temp_buffer)
@ -727,27 +727,27 @@ OGG_LoadAsWav(char *filename, wavinfo_t *info, void **buffer)
}
/* load vorbis file from memory */
ogg_file = stb_vorbis_open_memory(temp_buffer, size, &res, NULL);
if (!res && ogg_file->channels > 0)
ogg2wav_file = stb_vorbis_open_memory(temp_buffer, size, &res, NULL);
if (!res && ogg2wav_file->channels > 0)
{
int read_samples = 0;
/* fill in wav structure */
info->rate = ogg_file->sample_rate;
info->rate = ogg2wav_file->sample_rate;
info->width = 2;
info->channels = ogg_file->channels;
info->channels = ogg2wav_file->channels;
info->loopstart = -1;
/* return length * channels */
info->samples = stb_vorbis_stream_length_in_samples(ogg_file) / ogg_file->channels;
info->samples = stb_vorbis_stream_length_in_samples(ogg2wav_file) / ogg2wav_file->channels;
info->dataofs = 0;
/* alloc memory for uncompressed wav */
final_buffer = Z_Malloc(info->samples * sizeof(short) * ogg_file->channels);
final_buffer = Z_Malloc(info->samples * sizeof(short) * ogg2wav_file->channels);
/* load sampleas to buffer */
read_samples = stb_vorbis_get_samples_short_interleaved(
ogg_file, info->channels, final_buffer,
info->samples * ogg_file->channels);
ogg2wav_file, info->channels, final_buffer,
info->samples * ogg2wav_file->channels);
if (read_samples > 0)
{
@ -767,7 +767,7 @@ OGG_LoadAsWav(char *filename, wavinfo_t *info, void **buffer)
final_buffer = NULL;
}
stb_vorbis_close(ogg_file);
stb_vorbis_close(ogg2wav_file);
}
FS_FreeFile(temp_buffer);
}