soft: fix cppcheck warnings, remove unused isflattop

This commit is contained in:
Denis Pauk 2024-03-17 15:08:41 +02:00
parent 344f132044
commit 2b9c4e88fe
12 changed files with 102 additions and 99 deletions

View file

@ -29,22 +29,21 @@ State:
Monsters: Monsters:
* incorrect dead animation for Arachnid, * incorrect dead animation for Arachnid,
* broken fire effect for Guardian, * broken fire effect for Guardian.
* incorrect skin in soft render for Wizard mdl model.
Models support: Models support:
| Format | Original Game | Frame vertex | Comments | | Format | Original Game | Frame vertex | Meshes | Comments |
| ------ | --------------- | ------------ | ------------------------------------------------- | | ------ | --------------- | ------------ | ------ | --------------------------------------- |
| mdl | Quake 1 | 8 bit | unsupported grouped textures | | mdl | Quake 1 | 8 bit | Single | Unsupported grouped textures |
| md2 | Quake 2 | 8 bit | full support | | md2 | Quake 2 | 8 bit | Single | |
| md2 | Anachronox | 8/10/16 bit | does no suport tagged surfaces | | md2 | Anachronox | 8/10/16 bit | Single | No tagged surfaces, unchecked with game |
| mdx | Kingpin | 8 bit | unchecked with game | | mdx | Kingpin | 8 bit | Many | No sfx support, unchecked with game |
| fm | Heretic 2 | 8 bit | show all meshes | | fm | Heretic 2 | 8 bit | Many | |
| dkm | Daikatana DKM1 | 8 bit | unchecked with game | | dkm | Daikatana DKM1 | 8 bit | Many | Unchecked with game |
| dkm | Daikatana DKM2 | 10 bit | unchecked with game | | dkm | Daikatana DKM2 | 10 bit | Many | Unchecked with game |
| md3 | Quake 3 | 16 bit | show all meshes, no tags support, unchecked | | md3 | Quake 3 | 16 bit | Many | No tags support |
| md5 | Doom 3/Quake 4 | float | requires md2 for skins, show all meshes | | md5 | Doom 3/Quake 4 | float | Many | Requires md2 for skins |
All models support only single texture for all meshes and only up to 255 frames. All models support only single texture for all meshes and only up to 255 frames.

View file

@ -415,10 +415,10 @@ Mod_LoadDKMTriangleList(dmdx_t *pheader, const dkmtriangle_t *pintri)
for (i = 0; i < pheader->num_tris; i++) for (i = 0; i < pheader->num_tris; i++)
{ {
int j;
if (pintri[i].mesh_id == m) if (pintri[i].mesh_id == m)
{ {
int j;
for (j = 0; j < 3; j++) for (j = 0; j < 3; j++)
{ {
pouttri->index_xyz[j] = LittleShort(pintri[i].index_xyz[j]); pouttri->index_xyz[j] = LittleShort(pintri[i].index_xyz[j]);

View file

@ -476,7 +476,7 @@ R_AliasPreparePoints(const entity_t *currententity, finalvert_t *verts, const fi
for (i = 0; i < num_mesh_nodes; i++) for (i = 0; i < num_mesh_nodes; i++)
{ {
dtriangle_t *ptri; const dtriangle_t *ptri;
int num_tris; int num_tris;
num_tris = Q_min(s_pmdl->num_tris - mesh_nodes[i].ofs_tris, mesh_nodes[i].num_tris); num_tris = Q_min(s_pmdl->num_tris - mesh_nodes[i].ofs_tris, mesh_nodes[i].num_tris);

View file

@ -486,10 +486,13 @@ R_RecursiveWorldNode (entity_t *currententity, const model_t *currentmodel, mnod
int i; int i;
for (i=0 ; i<4 ; i++) for (i=0 ; i<4 ; i++)
{ {
int *pindex; const int *pindex;
float d; float d;
if (! (clipflags & (1<<i)) )
if (!(clipflags & (1<<i)))
{
continue; // don't need to clip against it continue; // don't need to clip against it
}
// generate accept and reject points // generate accept and reject points
// FIXME: do with fast look-ups or integer tests based on the sign bit // FIXME: do with fast look-ups or integer tests based on the sign bit

View file

@ -72,10 +72,10 @@ smoothly scrolled off.
void void
RE_Draw_CharScaled(int x, int y, int c, float scale) RE_Draw_CharScaled(int x, int y, int c, float scale)
{ {
pixel_t *dest; int drawline, row, col, v, iscale, sscale, width, height;
byte *source, *pic_pixels; const byte *source;
int drawline; byte *pic_pixels;
int row, col, v, iscale, sscale, width, height; pixel_t *dest;
iscale = (int) scale; iscale = (int) scale;
@ -149,9 +149,9 @@ RE_Draw_GetPicSize
============= =============
*/ */
void void
RE_Draw_GetPicSize (int *w, int *h, const char *name) RE_Draw_GetPicSize(int *w, int *h, const char *name)
{ {
image_t *image; const image_t *image;
image = R_FindPic (name, (findimage_t)R_FindImage); image = R_FindPic (name, (findimage_t)R_FindImage);
if (!image) if (!image)
@ -159,6 +159,7 @@ RE_Draw_GetPicSize (int *w, int *h, const char *name)
*w = *h = -1; *w = *h = -1;
return; return;
} }
*w = image->asset_width; *w = image->asset_width;
*h = image->asset_height; *h = image->asset_height;
} }
@ -237,11 +238,14 @@ RE_Draw_StretchPicImplementation (int x, int y, int w, int h, const image_t *pic
dest[u] = source[f>>16]; dest[u] = source[f>>16];
f += fstep; f += fstep;
} }
if (picupscale > 1) if (picupscale > 1)
{ {
int i; const pixel_t *dest_orig;
int pu = Q_min(height-v, picupscale); int pu, i;
pixel_t *dest_orig = dest;
pu = Q_min(height-v, picupscale);
dest_orig = dest;
// copy first line to fill whole sector // copy first line to fill whole sector
for (i=1; i < pu; i++) for (i=1; i < pu; i++)
@ -309,7 +313,7 @@ RE_Draw_StretchPic
void void
RE_Draw_StretchPic (int x, int y, int w, int h, const char *name) RE_Draw_StretchPic (int x, int y, int w, int h, const char *name)
{ {
image_t *pic; const image_t *pic;
pic = R_FindPic (name, (findimage_t)R_FindImage); pic = R_FindPic (name, (findimage_t)R_FindImage);
if (!pic) if (!pic)
@ -317,6 +321,7 @@ RE_Draw_StretchPic (int x, int y, int w, int h, const char *name)
R_Printf(PRINT_ALL, "Can't find pic: %s\n", name); R_Printf(PRINT_ALL, "Can't find pic: %s\n", name);
return; return;
} }
RE_Draw_StretchPicImplementation (x, y, w, h, pic); RE_Draw_StretchPicImplementation (x, y, w, h, pic);
} }
@ -387,7 +392,7 @@ Draw_Pic
void void
RE_Draw_PicScaled(int x, int y, const char *name, float scale) RE_Draw_PicScaled(int x, int y, const char *name, float scale)
{ {
image_t *pic; const image_t *pic;
pic = R_FindPic (name, (findimage_t)R_FindImage); pic = R_FindPic (name, (findimage_t)R_FindImage);
if (!pic) if (!pic)
@ -413,11 +418,10 @@ refresh window.
void void
RE_Draw_TileClear (int x, int y, int w, int h, const char *name) RE_Draw_TileClear (int x, int y, int w, int h, const char *name)
{ {
int i, j; const byte *psrc;
byte *psrc; pixel_t *pdest;
pixel_t *pdest; int i, j, x2;
image_t *pic; image_t *pic;
int x2;
if (x < 0) if (x < 0)
{ {

View file

@ -60,7 +60,7 @@ float scale_for_mip;
static void R_GenerateSpans (void); static void R_GenerateSpans (void);
static void R_GenerateSpansBackward (void); static void R_GenerateSpansBackward (void);
static void R_TrailingEdge (surf_t *surf, edge_t *edge); static void R_TrailingEdge (surf_t *surf, const edge_t *edge);
/* /*
=============================================================================== ===============================================================================
@ -328,7 +328,7 @@ R_TrailingEdge
============== ==============
*/ */
static void static void
R_TrailingEdge (surf_t *surf, edge_t *edge) R_TrailingEdge(surf_t *surf, const edge_t *edge)
{ {
// don't generate a span if this is an inverted span, with the end // don't generate a span if this is an inverted span, with the end
// edge preceding the start edge (that is, we haven't seen the // edge preceding the start edge (that is, we haven't seen the
@ -582,7 +582,7 @@ R_GenerateSpansBackward (void)
R_CleanupSpan (); R_CleanupSpan ();
} }
static void D_DrawSurfaces (entity_t *currententity, surf_t *surface); static void D_DrawSurfaces (entity_t *currententity, const surf_t *surface);
/* /*
============== ==============
@ -1029,7 +1029,7 @@ May be called more than once a frame if the surf list overflows (higher res)
============== ==============
*/ */
static void static void
D_DrawSurfaces (entity_t *currententity, surf_t *surface) D_DrawSurfaces(entity_t *currententity, const surf_t *surface)
{ {
VectorSubtract (r_origin, vec3_origin, modelorg); VectorSubtract (r_origin, vec3_origin, modelorg);
TransformVector (modelorg, transformed_modelorg); TransformVector (modelorg, transformed_modelorg);

View file

@ -88,7 +88,7 @@ R_ImageList_f (void)
//======================================================= //=======================================================
static image_t * static image_t *
R_FindFreeImage(char *name) R_FindFreeImage(const char *name)
{ {
image_t *image; image_t *image;
int i; int i;
@ -256,7 +256,7 @@ R_LoadPic8
================ ================
*/ */
static image_t * static image_t *
R_LoadPic8 (char *name, byte *pic, int width, int realwidth, int height, int realheight, R_LoadPic8(const char *name, const byte *pic, int width, int realwidth, int height, int realheight,
size_t data_size, imagetype_t type) size_t data_size, imagetype_t type)
{ {
image_t *image; image_t *image;
@ -340,7 +340,7 @@ R_LoadPic(char *name, byte *pic, int width, int realwidth, int height, int realh
realheight = height; realheight = height;
} }
if (data_size <= 0 || !width || !height) if (!data_size || !width || !height)
{ {
return NULL; return NULL;
} }

View file

@ -768,10 +768,10 @@ R_PolygonDrawSpans(espan_t *pspan, int iswater, float d_ziorigin, float d_zistep
static void static void
R_PolygonScanLeftEdge (espan_t *s_polygon_spans) R_PolygonScanLeftEdge (espan_t *s_polygon_spans)
{ {
int i, lmaxindex; const emitpoint_t *pvert, *pnext;
emitpoint_t *pvert, *pnext; float du, dv, vtop, u_step;
espan_t *pspan; int i, lmaxindex;
float du, dv, vtop, u_step; espan_t *pspan;
pspan = s_polygon_spans; pspan = s_polygon_spans;
i = s_minindex; i = s_minindex;
@ -837,10 +837,11 @@ R_PolygonScanLeftEdge (espan_t *s_polygon_spans)
static void static void
R_PolygonScanRightEdge(espan_t *s_polygon_spans) R_PolygonScanRightEdge(espan_t *s_polygon_spans)
{ {
int i; float du, dv, vtop, u_step, uvert, unext, vvert;
emitpoint_t *pvert, *pnext; const emitpoint_t *pnext;
espan_t *pspan; emitpoint_t *pvert;
float du, dv, vtop, u_step, uvert, unext, vvert; espan_t *pspan;
int i;
pspan = s_polygon_spans; pspan = s_polygon_spans;
i = s_minindex; i = s_minindex;
@ -1037,11 +1038,11 @@ R_ClipAndDrawPoly ( float alpha, int isturbulent, qboolean textured )
static void static void
R_BuildPolygonFromSurface(const entity_t *currententity, const model_t *currentmodel, msurface_t *fa) R_BuildPolygonFromSurface(const entity_t *currententity, const model_t *currentmodel, msurface_t *fa)
{ {
int i, lnumverts; medge_t *pedges, *r_pedge;
medge_t *pedges, *r_pedge; float tmins[2] = { 0, 0 };
float *vec; int i, lnumverts;
vec5_t *pverts; const float *vec;
float tmins[2] = { 0, 0 }; vec5_t *pverts;
r_polydesc.nump = 0; r_polydesc.nump = 0;

View file

@ -26,7 +26,6 @@
#include <limits.h> #include <limits.h>
typedef struct { typedef struct {
int isflattop;
int numleftedges; int numleftedges;
compactvert_t *pleftedgevert0; compactvert_t *pleftedgevert0;
compactvert_t *pleftedgevert1; compactvert_t *pleftedgevert1;
@ -46,18 +45,18 @@ static int d_xdenom;
static edgetable *pedgetable; static edgetable *pedgetable;
static edgetable edgetables[12] = { static edgetable edgetables[12] = {
{0, 1, &r_p0, &r_p2, NULL, 2, &r_p0, &r_p1, &r_p2}, {1, &r_p0, &r_p2, NULL, 2, &r_p0, &r_p1, &r_p2},
{0, 2, &r_p1, &r_p0, &r_p2, 1, &r_p1, &r_p2, NULL}, {2, &r_p1, &r_p0, &r_p2, 1, &r_p1, &r_p2, NULL},
{1, 1, &r_p0, &r_p2, NULL, 1, &r_p1, &r_p2, NULL}, {1, &r_p0, &r_p2, NULL, 1, &r_p1, &r_p2, NULL},
{0, 1, &r_p1, &r_p0, NULL, 2, &r_p1, &r_p2, &r_p0}, {1, &r_p1, &r_p0, NULL, 2, &r_p1, &r_p2, &r_p0},
{0, 2, &r_p0, &r_p2, &r_p1, 1, &r_p0, &r_p1, NULL}, {2, &r_p0, &r_p2, &r_p1, 1, &r_p0, &r_p1, NULL},
{0, 1, &r_p2, &r_p1, NULL, 1, &r_p2, &r_p0, NULL}, {1, &r_p2, &r_p1, NULL, 1, &r_p2, &r_p0, NULL},
{0, 1, &r_p2, &r_p1, NULL, 2, &r_p2, &r_p0, &r_p1}, {1, &r_p2, &r_p1, NULL, 2, &r_p2, &r_p0, &r_p1},
{0, 2, &r_p2, &r_p1, &r_p0, 1, &r_p2, &r_p0, NULL}, {2, &r_p2, &r_p1, &r_p0, 1, &r_p2, &r_p0, NULL},
{0, 1, &r_p1, &r_p0, NULL, 1, &r_p1, &r_p2, NULL}, {1, &r_p1, &r_p0, NULL, 1, &r_p1, &r_p2, NULL},
{1, 1, &r_p2, &r_p1, NULL, 1, &r_p0, &r_p1, NULL}, {1, &r_p2, &r_p1, NULL, 1, &r_p0, &r_p1, NULL},
{1, 1, &r_p1, &r_p0, NULL, 1, &r_p2, &r_p0, NULL}, {1, &r_p1, &r_p0, NULL, 1, &r_p2, &r_p0, NULL},
{0, 1, &r_p0, &r_p2, NULL, 1, &r_p0, &r_p1, NULL}, {1, &r_p0, &r_p2, NULL, 1, &r_p0, &r_p1, NULL},
}; };
// FIXME: some of these can become statics // FIXME: some of these can become statics
@ -778,12 +777,12 @@ R_RasterizeAliasPolySmooth
static void static void
R_RasterizeAliasPolySmooth(const entity_t *currententity) R_RasterizeAliasPolySmooth(const entity_t *currententity)
{ {
int initialleftheight, initialrightheight; const compactvert_t *pleftbottom, *prightbottom;
compactvert_t *plefttop, *prighttop, *pleftbottom, *prightbottom; int initialleftheight, initialrightheight;
light3_t working_lstepx; const compactvert_t *plefttop, *prighttop;
int originalcount; light3_t working_lstepx;
int u, v; int originalcount, u, v;
pixel_t *d_ptex; pixel_t *d_ptex;
plefttop = pedgetable->pleftedgevert0; plefttop = pedgetable->pleftedgevert0;
prighttop = pedgetable->prightedgevert0; prighttop = pedgetable->prightedgevert0;
@ -995,7 +994,7 @@ R_PolysetSetEdgeTable
================ ================
*/ */
static void static void
R_PolysetSetEdgeTable (void) R_PolysetSetEdgeTable(void)
{ {
int edgetableindex; int edgetableindex;

View file

@ -205,14 +205,11 @@ R_EmitEdge
static void static void
R_EmitEdge (mvertex_t *pv0, mvertex_t *pv1, medge_t *r_pedge, qboolean r_nearzionly) R_EmitEdge (mvertex_t *pv0, mvertex_t *pv1, medge_t *r_pedge, qboolean r_nearzionly)
{ {
edge_t *edge, *pcheck; float u, u_step, scale, lzi0, u0, v0;
int u_check; int u_check, v, v2, ceilv0, side;
float u, u_step; vec3_t local, transformed;
vec3_t local, transformed; edge_t *edge, *pcheck;
float *world; const float *world;
int v, v2, ceilv0;
float scale, lzi0, u0, v0;
int side;
if (r_lastvertvalid) if (r_lastvertvalid)
{ {

View file

@ -40,11 +40,10 @@ the sine warp, to keep the edges from wrapping
void void
D_WarpScreen (void) D_WarpScreen (void)
{ {
int w, h; const int *turb;
int u,v; int w, h, u,v;
pixel_t *dest; pixel_t *dest;
int *turb; byte **row;
byte **row;
static int cached_width, cached_height; static int cached_width, cached_height;
@ -79,7 +78,7 @@ D_WarpScreen (void)
for (v=0 ; v<h ; v++, dest += vid_buffer_width) for (v=0 ; v<h ; v++, dest += vid_buffer_width)
{ {
int *col; const int *col;
col = warp_column + turb[v]; col = warp_column + turb[v];
row = warp_rowptr + v; row = warp_rowptr + v;
@ -184,13 +183,13 @@ TurbulentPow2
============= =============
*/ */
void void
TurbulentPow2 (espan_t *pspan, float d_ziorigin, float d_zistepu, float d_zistepv) TurbulentPow2(espan_t *pspan, float d_ziorigin, float d_zistepu, float d_zistepv)
{ {
float spancountminus1; float sdivzpow2stepu, tdivzpow2stepu, zipow2stepu;
float sdivzpow2stepu, tdivzpow2stepu, zipow2stepu; int spanstep_shift, spanstep_value;
pixel_t *r_turb_pbase; const pixel_t *r_turb_pbase;
int *r_turb_turb; const int *r_turb_turb;
int spanstep_shift, spanstep_value; float spancountminus1;
spanstep_shift = D_DrawSpanGetStep(d_zistepu, d_zistepv); spanstep_shift = D_DrawSpanGetStep(d_zistepu, d_zistepv);
spanstep_value = (1 << spanstep_shift); spanstep_value = (1 << spanstep_shift);
@ -340,11 +339,11 @@ NonTurbulentPow2 - this is for drawing scrolling textures. they're warping water
void void
NonTurbulentPow2 (espan_t *pspan, float d_ziorigin, float d_zistepu, float d_zistepv) NonTurbulentPow2 (espan_t *pspan, float d_ziorigin, float d_zistepu, float d_zistepv)
{ {
float spancountminus1;
float sdivzpow2stepu, tdivzpow2stepu, zipow2stepu; float sdivzpow2stepu, tdivzpow2stepu, zipow2stepu;
pixel_t *r_turb_pbase; int spanstep_shift, spanstep_value;
int *r_turb_turb; const pixel_t *r_turb_pbase;
int spanstep_shift, spanstep_value; const int *r_turb_turb;
float spancountminus1;
spanstep_shift = D_DrawSpanGetStep(d_zistepu, d_zistepv); spanstep_shift = D_DrawSpanGetStep(d_zistepu, d_zistepv);
spanstep_value = (1 << spanstep_shift); spanstep_value = (1 << spanstep_shift);

View file

@ -71,7 +71,8 @@ R_DrawSurfaceBlock_Light (pixel_t *prowdest, pixel_t *psource, size_t size,
// Full same light from both side // Full same light from both side
if (light_masked_right != LIGHTMASK && light_masked_left == light_masked_right) if (light_masked_right != LIGHTMASK && light_masked_left == light_masked_right)
{ {
pixel_t *dest, *dest_max, *src; const pixel_t *dest_max;
pixel_t *dest, *src;
dest = prowdest; dest = prowdest;
dest_max = prowdest + size; dest_max = prowdest + size;