fixed multiple instances of variable shadowing

This commit is contained in:
myT 2022-12-26 22:08:46 +01:00
parent 8ccea00571
commit b36fce3234
4 changed files with 32 additions and 29 deletions

View file

@ -949,16 +949,16 @@ static void AddAllCommands( const commandBuffer_t* cmdBuf )
}
static void SeekToIndex( int index )
static void SeekToIndex( int seekIndex )
{
if (index < 0) {
if (seekIndex < 0) {
Warning("Attempted to seek out of range");
index = 0;
} else if (index >= demo.numIndices) {
index = demo.numIndices - 1;
seekIndex = 0;
} else if (seekIndex >= demo.numIndices) {
seekIndex = demo.numIndices - 1;
}
const demoIndex_t* demoIndex = &demo.indices[index];
const demoIndex_t* demoIndex = &demo.indices[seekIndex];
MB_Seek(&demo.buffer, demoIndex->byteOffset);
ReadNextSnapshot(); // 1st in next, ??? in current
ReadNextSnapshot(); // 2nd in next, 1st in current
@ -992,9 +992,9 @@ static void SeekToIndex( int index )
PrintCmdListBegin("synch CS commands");
qsort(cs, numCS, sizeof(configString_t), &CompareConfigStringTimes);
for (int i = 0; i < numCS; ++i) {
const int index = cs[i].index;
const char* const csNew = syncSnap->configStrings + syncSnap->configStringOffsets[index];
AddCommand(va("cs %d \"%s\"", index, csNew));
const int csIndex = cs[i].index;
const char* const csValue = syncSnap->configStrings + syncSnap->configStringOffsets[csIndex];
AddCommand(va("cs %d \"%s\"", csIndex, csValue));
}
PrintCmdListEnd();

View file

@ -256,7 +256,10 @@ void RE_EndFrame( int* pcFE, int* pc2D, int* pc3D, qbool render )
}
if ( render ) {
R_CMD_END( swapBuffersCommand_t, RC_SWAP_BUFFERS );
{
// forcing the sub-scope to prevent variable shadowing
R_CMD_END( swapBuffersCommand_t, RC_SWAP_BUFFERS );
}
if ( delayScreenshot ) {
R_CMD_END( screenshotCommand_t, RC_SCREENSHOT );
*cmd = r_delayedScreenshot;

View file

@ -401,9 +401,9 @@ static void IMG_Gamma_F32toU8( imageU8_t* output, const imageF32_t* input )
}
static int IMG_WrapPixel( int p, int size, textureWrap_t wrapMode )
static int IMG_WrapPixel( int p, int size, textureWrap_t textureWrap )
{
if (wrapMode == TW_CLAMP_TO_EDGE) {
if (textureWrap == TW_CLAMP_TO_EDGE) {
return clamp(p, 0, size - 1);
}

View file

@ -1573,14 +1573,14 @@ static void SortNewShader()
const int numDrawSurfs = tr.refdef.numDrawSurfs;
drawSurf_t* drawSurfs = tr.refdef.drawSurfs;
for( int i = 0; i < numDrawSurfs; ++i, ++drawSurfs ) {
for( i = 0; i < numDrawSurfs; ++i, ++drawSurfs ) {
R_DecomposeSort( drawSurfs->sort, &entityNum, &wrongShader, &fogNum );
drawSurfs->sort = R_ComposeSort( entityNum, tr.shaders[drawSurfs->shaderNum], fogNum );
}
const int numLitSurfs = tr.refdef.numLitSurfs;
litSurf_t* litSurfs = tr.refdef.litSurfs;
for ( int i = 0; i < numLitSurfs; ++i, ++litSurfs ) {
for ( i = 0; i < numLitSurfs; ++i, ++litSurfs ) {
R_DecomposeSort( litSurfs->sort, &entityNum, &wrongShader, &fogNum );
litSurfs->sort = R_ComposeSort( entityNum, tr.shaders[litSurfs->shaderNum], fogNum );
}
@ -2846,25 +2846,25 @@ void R_ShaderInfo_f()
}
const char* const name = Cmd_Argv(1);
const shader_t* shader = NULL;
const shader_t* sh = NULL;
for ( int i = 0; i < tr.numShaders; i++ ) {
if ( !Q_stricmp( tr.shaders[i]->name, name ) ) {
shader = tr.shaders[i];
sh = tr.shaders[i];
break;
}
}
if ( shader == NULL ) {
if ( sh == NULL ) {
ri.Printf( PRINT_ALL, "shader not found\n" );
return;
}
if ( shader->text == NULL ) {
if ( sh->text == NULL ) {
const char* type;
if ( shader->vlApplied ) {
if ( sh->vlApplied ) {
type = "vertex-lit surface";
} else {
switch ( shader->lightmapIndex ) {
switch ( sh->lightmapIndex ) {
case LIGHTMAP_BROKEN: type = "broken lit surface"; break;
case LIGHTMAP_2D: type = "UI element"; break;
case LIGHTMAP_NONE: type = "opaque surface"; break;
@ -2875,7 +2875,7 @@ void R_ShaderInfo_f()
return;
}
const char* const shaderPath = R_GetShaderPath( shader );
const char* const shaderPath = R_GetShaderPath( sh );
if ( shaderPath != NULL ) {
ri.Printf( PRINT_ALL, "%s\n", shaderPath );
}
@ -2884,7 +2884,7 @@ void R_ShaderInfo_f()
return;
}
const char* s = shader->text;
const char* s = sh->text;
int tabs = 0;
for ( ;; ) {
const char c0 = s[0];
@ -2933,15 +2933,15 @@ void R_ShaderMixedUse_f()
}
const int s = (tr.imageShaders[is] >> 16) & 0xFFFF;
const shader_t* const shader = tr.shaders[s];
const qbool nmmS = shader->imgflags & IMG_NOMIPMAP;
const qbool npmS = shader->imgflags & IMG_NOPICMIP;
const shader_t* const sh = tr.shaders[s];
const qbool nmmS = sh->imgflags & IMG_NOMIPMAP;
const qbool npmS = sh->imgflags & IMG_NOPICMIP;
ri.Printf( PRINT_ALL, "%s %s %s\n",
nmmS ? "NMM" : " ",
npmS ? "NPM" : " ",
shader->name);
sh->name);
const char* const shaderPath = R_GetShaderPath( shader );
const char* const shaderPath = R_GetShaderPath( sh );
if ( shaderPath != NULL ) {
ri.Printf( PRINT_ALL, " -> %s\n", shaderPath );
}
@ -3094,9 +3094,9 @@ void R_InitShaders()
}
const char* R_GetShaderPath( const shader_t* shader )
const char* R_GetShaderPath( const shader_t* sh )
{
const int fileIndex = shader->fileIndex;
const int fileIndex = sh->fileIndex;
if ( fileIndex < 0 || fileIndex >= s_numShaderFiles ) {
return NULL;
}