fixed -Wshadow warnings.

This commit is contained in:
Ozkan Sezer 2021-06-23 04:37:10 +03:00
parent 9fc38410dd
commit 9ca7d499e5
6 changed files with 64 additions and 68 deletions

View file

@ -903,7 +903,7 @@ void Sky_DrawFace (int axis)
vec3_t verts[4]; vec3_t verts[4];
int i, j, start; int i, j, start;
float di,qi,dj,qj; float di,qi,dj,qj;
vec3_t vup, vright, temp, temp2; vec3_t up, right, temp, temp2;
Sky_SetBoxVert(-1.0, -1.0, axis, verts[0]); Sky_SetBoxVert(-1.0, -1.0, axis, verts[0]);
Sky_SetBoxVert(-1.0, 1.0, axis, verts[1]); Sky_SetBoxVert(-1.0, 1.0, axis, verts[1]);
@ -913,8 +913,8 @@ void Sky_DrawFace (int axis)
start = Hunk_LowMark (); start = Hunk_LowMark ();
p = (glpoly_t *) Hunk_Alloc(sizeof(glpoly_t)); p = (glpoly_t *) Hunk_Alloc(sizeof(glpoly_t));
VectorSubtract(verts[2],verts[3],vup); VectorSubtract(verts[2],verts[3],up);
VectorSubtract(verts[2],verts[1],vright); VectorSubtract(verts[2],verts[1],right);
di = q_max((int)r_sky_quality.value, 1); di = q_max((int)r_sky_quality.value, 1);
qi = 1.0 / di; qi = 1.0 / di;
@ -930,15 +930,15 @@ void Sky_DrawFace (int axis)
continue; continue;
//if (i&1 ^ j&1) continue; //checkerboard test //if (i&1 ^ j&1) continue; //checkerboard test
VectorScale (vright, qi*i, temp); VectorScale (right, qi*i, temp);
VectorScale (vup, qj*j, temp2); VectorScale (up, qj*j, temp2);
VectorAdd(temp,temp2,temp); VectorAdd(temp,temp2,temp);
VectorAdd(verts[0],temp,p->verts[0]); VectorAdd(verts[0],temp,p->verts[0]);
VectorScale (vup, qj, temp); VectorScale (up, qj, temp);
VectorAdd (p->verts[0],temp,p->verts[1]); VectorAdd (p->verts[0],temp,p->verts[1]);
VectorScale (vright, qi, temp); VectorScale (right, qi, temp);
VectorAdd (p->verts[1],temp,p->verts[2]); VectorAdd (p->verts[1],temp,p->verts[2]);
VectorAdd (p->verts[0],temp,p->verts[3]); VectorAdd (p->verts[0],temp,p->verts[3]);

View file

@ -1282,34 +1282,32 @@ void TexMgr_ReloadImage (gltexture_t *glt, int shirt, int pants)
// //
mark = Hunk_LowMark (); mark = Hunk_LowMark ();
if (glt->source_file[0] && glt->source_offset) if (glt->source_file[0] && glt->source_offset) {
{
//lump inside file //lump inside file
long size;
FILE *f; FILE *f;
COM_FOpenFile(glt->source_file, &f, NULL); COM_FOpenFile(glt->source_file, &f, NULL);
if (!f) if (!f) goto invalid;
goto invalid;
fseek (f, glt->source_offset, SEEK_CUR); fseek (f, glt->source_offset, SEEK_CUR);
size = (long) (glt->source_width * glt->source_height); size = glt->source_width * glt->source_height;
/* should be SRC_INDEXED, but no harm being paranoid: */ /* should be SRC_INDEXED, but no harm being paranoid: */
if (glt->source_format == SRC_RGBA) if (glt->source_format == SRC_RGBA) {
size *= 4; size *= 4;
else if (glt->source_format == SRC_LIGHTMAP) }
else if (glt->source_format == SRC_LIGHTMAP) {
size *= lightmap_bytes; size *= lightmap_bytes;
}
data = (byte *) Hunk_Alloc (size); data = (byte *) Hunk_Alloc (size);
fread (data, 1, size, f); fread (data, 1, size, f);
fclose (f); fclose (f);
} }
else if (glt->source_file[0] && !glt->source_offset) else if (glt->source_file[0] && !glt->source_offset) {
data = Image_LoadImage (glt->source_file, (int *)&glt->source_width, (int *)&glt->source_height); //simple file data = Image_LoadImage (glt->source_file, (int *)&glt->source_width, (int *)&glt->source_height); //simple file
else if (!glt->source_file[0] && glt->source_offset) }
else if (!glt->source_file[0] && glt->source_offset) {
data = (byte *) glt->source_offset; //image in memory data = (byte *) glt->source_offset; //image in memory
}
if (!data) if (!data) {
{ invalid: Con_Printf ("TexMgr_ReloadImage: invalid source for %s\n", glt->name);
invalid:
Con_Printf ("TexMgr_ReloadImage: invalid source for %s\n", glt->name);
Hunk_FreeToLowMark(mark); Hunk_FreeToLowMark(mark);
return; return;
} }

View file

@ -661,10 +661,9 @@ static qboolean VID_SetMode (int width, int height, int refreshrate, int bpp, qb
/* Make window fullscreen if needed, and show the window */ /* Make window fullscreen if needed, and show the window */
if (fullscreen) { if (fullscreen) {
Uint32 flags = vid_desktopfullscreen.value ? const Uint32 flag = vid_desktopfullscreen.value ?
SDL_WINDOW_FULLSCREEN_DESKTOP : SDL_WINDOW_FULLSCREEN_DESKTOP : SDL_WINDOW_FULLSCREEN;
SDL_WINDOW_FULLSCREEN; if (SDL_SetWindowFullscreen (draw_context, flag) != 0)
if (SDL_SetWindowFullscreen (draw_context, flags) != 0)
Sys_Error ("Couldn't set fullscreen state mode"); Sys_Error ("Couldn't set fullscreen state mode");
} }

View file

@ -310,7 +310,7 @@ struct lightmap_s
// main memory so texsubimage can update properly // main memory so texsubimage can update properly
byte *data;//[4*LMBLOCK_WIDTH*LMBLOCK_HEIGHT]; byte *data;//[4*LMBLOCK_WIDTH*LMBLOCK_HEIGHT];
}; };
extern struct lightmap_s *lightmap; extern struct lightmap_s *lightmaps;
extern int lightmap_count; //allocated lightmaps extern int lightmap_count; //allocated lightmaps
extern int gl_warpimagesize; //johnfitz -- for water warp extern int gl_warpimagesize; //johnfitz -- for water warp

View file

@ -31,7 +31,7 @@ int gl_lightmap_format;
int lightmap_bytes; int lightmap_bytes;
#define MAX_SANITY_LIGHTMAPS (1u<<20) #define MAX_SANITY_LIGHTMAPS (1u<<20)
struct lightmap_s *lightmap; struct lightmap_s *lightmaps;
int lightmap_count; int lightmap_count;
int last_lightmap_allocated; int last_lightmap_allocated;
int allocated[LMBLOCK_WIDTH]; int allocated[LMBLOCK_WIDTH];
@ -663,8 +663,8 @@ void R_RenderDynamicLightmaps (msurface_t *fa)
return; return;
// add to lightmap chain // add to lightmap chain
fa->polys->chain = lightmap[fa->lightmaptexturenum].polys; fa->polys->chain = lightmaps[fa->lightmaptexturenum].polys;
lightmap[fa->lightmaptexturenum].polys = fa->polys; lightmaps[fa->lightmaptexturenum].polys = fa->polys;
// check for lightmap modification // check for lightmap modification
for (maps=0; maps < MAXLIGHTMAPS && fa->styles[maps] != 255; maps++) for (maps=0; maps < MAXLIGHTMAPS && fa->styles[maps] != 255; maps++)
@ -677,7 +677,7 @@ void R_RenderDynamicLightmaps (msurface_t *fa)
dynamic: dynamic:
if (r_dynamic.value) if (r_dynamic.value)
{ {
struct lightmap_s *lm = &lightmap[fa->lightmaptexturenum]; struct lightmap_s *lm = &lightmaps[fa->lightmaptexturenum];
lm->modified = true; lm->modified = true;
theRect = &lm->rectchange; theRect = &lm->rectchange;
if (fa->light_t < theRect->t) { if (fa->light_t < theRect->t) {
@ -724,11 +724,11 @@ int AllocBlock (int w, int h, int *x, int *y)
if (texnum == lightmap_count) if (texnum == lightmap_count)
{ {
lightmap_count++; lightmap_count++;
lightmap = (struct lightmap_s *) realloc(lightmap, sizeof(*lightmap)*lightmap_count); lightmaps = (struct lightmap_s *) realloc(lightmaps, sizeof(*lightmaps)*lightmap_count);
memset(&lightmap[texnum], 0, sizeof(lightmap[texnum])); memset(&lightmaps[texnum], 0, sizeof(lightmaps[texnum]));
/* FIXME: we leave 'gaps' in malloc()ed data, CRC_Block() later accesses /* FIXME: we leave 'gaps' in malloc()ed data, CRC_Block() later accesses
* that uninitialized data and valgrind complains for it. use calloc() ? */ * that uninitialized data and valgrind complains for it. use calloc() ? */
lightmap[texnum].data = (byte *) malloc(4*LMBLOCK_WIDTH*LMBLOCK_HEIGHT); lightmaps[texnum].data = (byte *) malloc(4*LMBLOCK_WIDTH*LMBLOCK_HEIGHT);
//as we're only tracking one texture, we don't need multiple copies of allocated any more. //as we're only tracking one texture, we don't need multiple copies of allocated any more.
memset(allocated, 0, sizeof(allocated)); memset(allocated, 0, sizeof(allocated));
} }
@ -786,7 +786,7 @@ void GL_CreateSurfaceLightmap (msurface_t *surf)
tmax = (surf->extents[1]>>4)+1; tmax = (surf->extents[1]>>4)+1;
surf->lightmaptexturenum = AllocBlock (smax, tmax, &surf->light_s, &surf->light_t); surf->lightmaptexturenum = AllocBlock (smax, tmax, &surf->light_s, &surf->light_t);
base = lightmap[surf->lightmaptexturenum].data; base = lightmaps[surf->lightmaptexturenum].data;
base += (surf->light_t * LMBLOCK_WIDTH + surf->light_s) * lightmap_bytes; base += (surf->light_t * LMBLOCK_WIDTH + surf->light_s) * lightmap_bytes;
R_BuildLightMap (surf, base, LMBLOCK_WIDTH*lightmap_bytes); R_BuildLightMap (surf, base, LMBLOCK_WIDTH*lightmap_bytes);
} }
@ -883,9 +883,9 @@ void GL_BuildLightmaps (void)
//Spike -- wipe out all the lightmap data (johnfitz -- the gltexture objects were already freed by Mod_ClearAll) //Spike -- wipe out all the lightmap data (johnfitz -- the gltexture objects were already freed by Mod_ClearAll)
for (i=0; i < lightmap_count; i++) for (i=0; i < lightmap_count; i++)
free(lightmap[i].data); free(lightmaps[i].data);
free(lightmap); free(lightmaps);
lightmap = NULL; lightmaps = NULL;
last_lightmap_allocated = 0; last_lightmap_allocated = 0;
lightmap_count = 0; lightmap_count = 0;
@ -928,7 +928,7 @@ void GL_BuildLightmaps (void)
// //
for (i=0; i<lightmap_count; i++) for (i=0; i<lightmap_count; i++)
{ {
lm = &lightmap[i]; lm = &lightmaps[i];
lm->modified = false; lm->modified = false;
lm->rectchange.l = LMBLOCK_WIDTH; lm->rectchange.l = LMBLOCK_WIDTH;
lm->rectchange.t = LMBLOCK_HEIGHT; lm->rectchange.t = LMBLOCK_HEIGHT;
@ -1252,7 +1252,7 @@ assumes lightmap texture is already bound
*/ */
static void R_UploadLightmap(int lmap) static void R_UploadLightmap(int lmap)
{ {
struct lightmap_s *lm = &lightmap[lmap]; struct lightmap_s *lm = &lightmaps[lmap];
if (!lm->modified) if (!lm->modified)
return; return;
@ -1275,10 +1275,10 @@ void R_UploadLightmaps (void)
for (lmap = 0; lmap < lightmap_count; lmap++) for (lmap = 0; lmap < lightmap_count; lmap++)
{ {
if (!lightmap[lmap].modified) if (!lightmaps[lmap].modified)
continue; continue;
GL_Bind (lightmap[lmap].texture); GL_Bind (lightmaps[lmap].texture);
R_UploadLightmap(lmap); R_UploadLightmap(lmap);
} }
} }
@ -1308,7 +1308,7 @@ void R_RebuildAllLightmaps (void)
{ {
if (fa->flags & SURF_DRAWTILED) if (fa->flags & SURF_DRAWTILED)
continue; continue;
base = lightmap[fa->lightmaptexturenum].data; base = lightmaps[fa->lightmaptexturenum].data;
base += fa->light_t * LMBLOCK_WIDTH * lightmap_bytes + fa->light_s * lightmap_bytes; base += fa->light_t * LMBLOCK_WIDTH * lightmap_bytes + fa->light_s * lightmap_bytes;
R_BuildLightMap (fa, base, LMBLOCK_WIDTH*lightmap_bytes); R_BuildLightMap (fa, base, LMBLOCK_WIDTH*lightmap_bytes);
} }
@ -1317,8 +1317,8 @@ void R_RebuildAllLightmaps (void)
//for each lightmap, upload it //for each lightmap, upload it
for (i=0; i<lightmap_count; i++) for (i=0; i<lightmap_count; i++)
{ {
GL_Bind (lightmap[i].texture); GL_Bind (lightmaps[i].texture);
glTexSubImage2D (GL_TEXTURE_2D, 0, 0, 0, LMBLOCK_WIDTH, LMBLOCK_HEIGHT, gl_lightmap_format, glTexSubImage2D (GL_TEXTURE_2D, 0, 0, 0, LMBLOCK_WIDTH, LMBLOCK_HEIGHT, gl_lightmap_format,
GL_UNSIGNED_BYTE, lightmap[i].data); GL_UNSIGNED_BYTE, lightmaps[i].data);
} }
} }

View file

@ -55,7 +55,7 @@ void R_ClearTextureChains (qmodel_t *mod, texchain_t chain)
// clear lightmap chains // clear lightmap chains
for (i=0 ; i<lightmap_count ; i++) for (i=0 ; i<lightmap_count ; i++)
lightmap[i].polys = NULL; lightmaps[i].polys = NULL;
} }
/* /*
@ -85,7 +85,7 @@ void R_MarkSurfaces (void)
// clear lightmap chains // clear lightmap chains
for (i=0 ; i<lightmap_count ; i++) for (i=0 ; i<lightmap_count ; i++)
lightmap[i].polys = NULL; lightmaps[i].polys = NULL;
// check this leaf for water portals // check this leaf for water portals
// TODO: loop through all water surfs and use distance to leaf cullbox // TODO: loop through all water surfs and use distance to leaf cullbox
@ -139,7 +139,6 @@ void R_MarkSurfaces (void)
cl.worldmodel->textures[i]->texturechains[chain_world] = NULL; cl.worldmodel->textures[i]->texturechains[chain_world] = NULL;
// rebuild chains // rebuild chains
#if 1 #if 1
//iterate through surfaces one node at a time to rebuild chains //iterate through surfaces one node at a time to rebuild chains
//need to do it this way if we want to work with tyrann's skip removal tool //need to do it this way if we want to work with tyrann's skip removal tool
@ -249,7 +248,7 @@ void R_BuildLightmapChains (qmodel_t *model, texchain_t chain)
// clear lightmap chains (already done in r_marksurfaces, but clearing them here to be safe becuase of r_stereo) // clear lightmap chains (already done in r_marksurfaces, but clearing them here to be safe becuase of r_stereo)
for (i=0 ; i<lightmap_count ; i++) for (i=0 ; i<lightmap_count ; i++)
lightmap[i].polys = NULL; lightmaps[i].polys = NULL;
// now rebuild them // now rebuild them
for (i=0 ; i<model->numtextures ; i++) for (i=0 ; i<model->numtextures ; i++)
@ -539,7 +538,7 @@ void R_DrawTextureChains_Multitexture (qmodel_t *model, entity_t *ent, texchain_
GL_EnableMultitexture(); // selects TEXTURE1 GL_EnableMultitexture(); // selects TEXTURE1
bound = true; bound = true;
} }
GL_Bind (lightmap[s->lightmaptexturenum].texture); GL_Bind (lightmaps[s->lightmaptexturenum].texture);
glBegin(GL_POLYGON); glBegin(GL_POLYGON);
v = s->polys->verts[0]; v = s->polys->verts[0];
for (j=0 ; j<s->polys->numverts ; j++, v+= VERTEXSIZE) for (j=0 ; j<s->polys->numverts ; j++, v+= VERTEXSIZE)
@ -777,11 +776,11 @@ void R_DrawLightmapChains (void)
for (i=0 ; i<lightmap_count ; i++) for (i=0 ; i<lightmap_count ; i++)
{ {
if (!lightmap[i].polys) if (!lightmaps[i].polys)
continue; continue;
GL_Bind (lightmap[i].texture); GL_Bind (lightmaps[i].texture);
for (p = lightmap[i].polys; p; p=p->chain) for (p = lightmaps[i].polys; p; p=p->chain)
{ {
glBegin (GL_POLYGON); glBegin (GL_POLYGON);
v = p->verts[0]; v = p->verts[0];
@ -990,7 +989,7 @@ void R_DrawTextureChains_GLSL (qmodel_t *model, entity_t *ent, texchain_t chain)
R_FlushBatch (); R_FlushBatch ();
GL_SelectTexture (GL_TEXTURE1); GL_SelectTexture (GL_TEXTURE1);
GL_Bind (lightmap[s->lightmaptexturenum].texture); GL_Bind (lightmaps[s->lightmaptexturenum].texture);
lastlightmap = s->lightmaptexturenum; lastlightmap = s->lightmaptexturenum;
R_BatchSurface (s); R_BatchSurface (s);