From 666685fba669b566832231c57d2e48994189a4f2 Mon Sep 17 00:00:00 2001 From: Jonathan Gray Date: Sun, 21 Apr 2013 20:29:47 +1000 Subject: [PATCH] adjust to different scoping of variables declared in for loops --- code/cgame/cg_camera.cpp | 3 ++- code/client/snd_dma.cpp | 6 ++++-- code/game/AI_Utils.cpp | 3 ++- code/game/NPC_spawn.cpp | 3 ++- code/game/NPC_utils.cpp | 3 ++- code/game/g_client.cpp | 3 ++- code/game/g_combat.cpp | 3 ++- code/game/g_roff.cpp | 6 ++++-- code/game/g_savegame.cpp | 8 +++++--- code/game/wp_saber.cpp | 8 +++++--- code/game/wp_saberLoad.cpp | 3 ++- code/ghoul2/G2_misc.cpp | 18 ++++++++++++------ code/icarus/Sequence.cpp | 5 +++-- code/icarus/Sequencer.cpp | 3 ++- code/icarus/TaskManager.cpp | 3 ++- code/renderer/tr_draw.cpp | 3 ++- code/renderer/tr_font.cpp | 9 ++++++--- code/server/sv_savegame.cpp | 3 ++- 18 files changed, 61 insertions(+), 32 deletions(-) diff --git a/code/cgame/cg_camera.cpp b/code/cgame/cg_camera.cpp index dc2081e..d162809 100644 --- a/code/cgame/cg_camera.cpp +++ b/code/cgame/cg_camera.cpp @@ -1391,7 +1391,8 @@ void CGCam_UpdateShake( vec3_t origin, vec3_t angles ) intensity = client_camera.shake_intensity * intensity_scale; - for ( int i = 0; i < 3; i++ ) + int i; + for ( i = 0; i < 3; i++ ) { moveDir[i] = ( crandom() * intensity ); } diff --git a/code/client/snd_dma.cpp b/code/client/snd_dma.cpp index 860562f..f5d8089 100644 --- a/code/client/snd_dma.cpp +++ b/code/client/snd_dma.cpp @@ -4534,7 +4534,8 @@ void S_StartBackgroundTrack( const char *intro, const char *loop, qboolean bCall { extern const char *Music_GetLevelSetName(void); Q_strncpyz(sInfoOnly_CurrentDynamicMusicSet, Music_GetLevelSetName(), sizeof(sInfoOnly_CurrentDynamicMusicSet)); - for (int i = eBGRNDTRACK_DATABEGIN; i != eBGRNDTRACK_DATAEND; i++) + int i; + for (i = eBGRNDTRACK_DATABEGIN; i != eBGRNDTRACK_DATAEND; i++) { qboolean bOk = qfalse; LPCSTR psMusicName = Music_GetFileNameForState( (MusicState_e) i); @@ -5163,7 +5164,8 @@ int SND_FreeOldestSound(sfx_t *pButNotThisOne /* = NULL */) { // new bit, we can't throw away any sfx_t struct in use by a channel, else the paint code will crash... // - for (int iChannel=0; iChannelnumGroup; i++ ) + int i; + for ( i = 0; i < group->numGroup; i++ ) { if ( group->member[i].number == member->s.number ) {//already in here diff --git a/code/game/NPC_spawn.cpp b/code/game/NPC_spawn.cpp index 3a516af..eb02084 100644 --- a/code/game/NPC_spawn.cpp +++ b/code/game/NPC_spawn.cpp @@ -1403,7 +1403,8 @@ bool NPC_SafeSpawn( gentity_t *ent, float safeRadius ) } //Setup the bbox to search in - for ( int i = 0; i < 3; i++ ) + int i; + for ( i = 0; i < 3; i++ ) { safeMins[i] = ent->currentOrigin[i] - safeRadius; safeMaxs[i] = ent->currentOrigin[i] + safeRadius; diff --git a/code/game/NPC_utils.cpp b/code/game/NPC_utils.cpp index 18dc3ee..c3e8870 100644 --- a/code/game/NPC_utils.cpp +++ b/code/game/NPC_utils.cpp @@ -1099,7 +1099,8 @@ int NPC_FindNearestEnemy( gentity_t *ent ) int numEnts, numChecks = 0; //Setup the bbox to search in - for ( int i = 0; i < 3; i++ ) + int i; + for ( i = 0; i < 3; i++ ) { mins[i] = ent->currentOrigin[i] - NPCInfo->stats.visrange; maxs[i] = ent->currentOrigin[i] + NPCInfo->stats.visrange; diff --git a/code/game/g_client.cpp b/code/game/g_client.cpp index 04da273..2e816da 100644 --- a/code/game/g_client.cpp +++ b/code/game/g_client.cpp @@ -639,7 +639,8 @@ void Player_CacheFromPrevLevel(void) &ibits //client->ps.stats[STAT_ITEMS] ); - for ( int i = 1 ; i < 16 ; i++ ) + int i; + for ( i = 1 ; i < 16 ; i++ ) { if ( bits & ( 1 << i ) ) { diff --git a/code/game/g_combat.cpp b/code/game/g_combat.cpp index 0969c9f..c7e6d21 100644 --- a/code/game/g_combat.cpp +++ b/code/game/g_combat.cpp @@ -480,7 +480,8 @@ void G_AlertTeam( gentity_t *victim, gentity_t *attacker, float radius, float so return; //Setup the bbox to search in - for ( int i = 0; i < 3; i++ ) + int i; + for ( i = 0; i < 3; i++ ) { mins[i] = victim->currentOrigin[i] - radius; maxs[i] = victim->currentOrigin[i] + radius; diff --git a/code/game/g_roff.cpp b/code/game/g_roff.cpp index 74fa908..43c785e 100644 --- a/code/game/g_roff.cpp +++ b/code/game/g_roff.cpp @@ -298,7 +298,8 @@ static qboolean G_InitRoff( char *file, unsigned char *data ) move_rotate_t *roff_data = ( move_rotate_t *)&header[1]; // Copy all of the goods into our ROFF cache - for ( int i = 0; i < count; i++, roff_data++, mem++ ) + int i; + for ( i = 0; i < count; i++, roff_data++, mem++ ) { // Copy just the delta position and orientation which can be applied to anything at a later point VectorCopy( roff_data->origin_delta, mem->origin_delta ); @@ -335,7 +336,8 @@ static qboolean G_InitRoff( char *file, unsigned char *data ) roffs[num_roffs].type = 2; //rww - any reason this wasn't being set already? // Copy all of the goods into our ROFF cache - for ( int i = 0; i < count; i++ ) + int i; + for ( i = 0; i < count; i++ ) { VectorCopy( roff_data[i].origin_delta, mem[i].origin_delta ); VectorCopy( roff_data[i].rotate_delta, mem[i].rotate_delta ); diff --git a/code/game/g_savegame.cpp b/code/game/g_savegame.cpp index 87bd829..561c37d 100644 --- a/code/game/g_savegame.cpp +++ b/code/game/g_savegame.cpp @@ -793,7 +793,8 @@ static void WriteGEntities(qboolean qbAutosave) { int iCount = 0; - for (int i=0; i<(qbAutosave?1:globals.num_entities); i++) + int i; + for (i=0; i<(qbAutosave?1:globals.num_entities); i++) { gentity_t* ent = &g_entities[i]; @@ -886,7 +887,8 @@ static void ReadGEntities(qboolean qbAutosave) gi.ReadFromSaveGame('NMED', (void *)&iCount, sizeof(iCount)); int iPreviousEntRead = -1; - for (int i=0; icurrentOrigin[i] - radius; maxs[i] = ent->currentOrigin[i] + radius; @@ -14568,4 +14570,4 @@ void WP_InitForcePowers( gentity_t *ent ) ent->client->ps.forcePowerLevel[FP_GRIP] = FORCE_LEVEL_2; } } -} \ No newline at end of file +} diff --git a/code/game/wp_saberLoad.cpp b/code/game/wp_saberLoad.cpp index 62850a4..fecfd3e 100644 --- a/code/game/wp_saberLoad.cpp +++ b/code/game/wp_saberLoad.cpp @@ -18,7 +18,8 @@ char SaberParms[MAX_SABER_DATA_SIZE]; void Saber_SithSwordPrecache( void ) {//*SIGH* special sounds used by the sith sword - for ( int i = 1; i < 5; i++ ) + int i; + for ( i = 1; i < 5; i++ ) { G_SoundIndex( va( "sound/weapons/sword/stab%d.wav", i ) ); } diff --git a/code/ghoul2/G2_misc.cpp b/code/ghoul2/G2_misc.cpp index 2d562ae..adc0002 100644 --- a/code/ghoul2/G2_misc.cpp +++ b/code/ghoul2/G2_misc.cpp @@ -1119,7 +1119,8 @@ static bool G2_TracePolys(const mdxmSurface_t *surface, const mdxmSurfHierarchy_ // did we hit it? if (G2_SegmentTriangleTest(TS.rayStart, TS.rayEnd, point1, point2, point3, qtrue, qtrue, hitPoint, normal, &face)) { // find space in the collision records for this record - for (int i=0; iBufferRead( &iNumChildren, sizeof( iNumChildren ) ); //Reload all children - for ( int i = 0; i < iNumChildren; i++ ) + int i; + for ( i = 0; i < iNumChildren; i++ ) { //Get the child sequence ID icarus->BufferRead( &id, sizeof( id ) ); @@ -671,4 +672,4 @@ int CSequence::Load( CIcarus* icarus ) } return true; -} \ No newline at end of file +} diff --git a/code/icarus/Sequencer.cpp b/code/icarus/Sequencer.cpp index fc0620d..0d796c7 100644 --- a/code/icarus/Sequencer.cpp +++ b/code/icarus/Sequencer.cpp @@ -2553,7 +2553,8 @@ int CSequencer::Load( CIcarus* icarus, IGameInterface* game ) pIcarus->BufferRead( &numSequences, sizeof( numSequences ) ); //Read in all the sequences - for ( int i = 0; i < numSequences; i++ ) + int i; + for ( i = 0; i < numSequences; i++ ) { pIcarus->BufferRead( &seqID, sizeof( seqID ) ); diff --git a/code/icarus/TaskManager.cpp b/code/icarus/TaskManager.cpp index 84d0b28..3290c48 100644 --- a/code/icarus/TaskManager.cpp +++ b/code/icarus/TaskManager.cpp @@ -1849,7 +1849,8 @@ void CTaskManager::Load( CIcarus* icarus ) pIcarus->BufferRead( &numTasks, sizeof( numTasks ) ); //Reload all the tasks - for ( int i = 0; i < numTasks; i++ ) + int i; + for ( i = 0; i < numTasks; i++ ) { task = new CTask; diff --git a/code/renderer/tr_draw.cpp b/code/renderer/tr_draw.cpp index bddba76..53aff13 100644 --- a/code/renderer/tr_draw.cpp +++ b/code/renderer/tr_draw.cpp @@ -893,7 +893,8 @@ qboolean RE_InitDissolve(qboolean bForceCircularExtroWipe) // // do it... // - for (int y = 0; y < glConfig.vidHeight; y++) + int y; + for (y = 0; y < glConfig.vidHeight; y++) { pbDst -= iClearBytes; memset(pbDst,0,iClearBytes); diff --git a/code/renderer/tr_font.cpp b/code/renderer/tr_font.cpp index ebe8f04..3383d1b 100644 --- a/code/renderer/tr_font.cpp +++ b/code/renderer/tr_font.cpp @@ -592,7 +592,8 @@ static int Thai_ValidTISCode( const byte *psString, int &iThaiBytes ) // thai codes can be up to 3 bytes long, so see how high we can get... // - for (int i=0; i<3; i++) + int i; + for (i=0; i<3; i++) { CodeToTry.sChars[i] = psString[i]; @@ -1671,9 +1672,11 @@ void R_ReloadFonts_f(void) // vector vstrFonts; - for (int iFontToFind = 1; iFontToFind < g_iCurrentFontIndex; iFontToFind++) + int iFontToFind; + for (iFontToFind = 1; iFontToFind < g_iCurrentFontIndex; iFontToFind++) { - for (FontIndexMap_t::iterator it = g_mapFontIndexes.begin(); it != g_mapFontIndexes.end(); ++it) + FontIndexMap_t::iterator it; + for (it = g_mapFontIndexes.begin(); it != g_mapFontIndexes.end(); ++it) { if (iFontToFind == (*it).second) { diff --git a/code/server/sv_savegame.cpp b/code/server/sv_savegame.cpp index 5c87d5b..40827e6 100644 --- a/code/server/sv_savegame.cpp +++ b/code/server/sv_savegame.cpp @@ -888,7 +888,8 @@ void SG_ReadServerConfigStrings( void ) { // trash the whole table... // - for (int i=0; i