some more s/GetSize/size/ and other minor STLisms

This commit is contained in:
Glenn Maynard
2002-10-31 02:54:49 +00:00
parent 2b16872bd5
commit 945a39a247
11 changed files with 65 additions and 65 deletions
+7 -7
View File
@@ -30,7 +30,7 @@ BGAnimation::~BGAnimation()
void BGAnimation::Unload()
{
for( int i=0; i<m_Layers.GetSize(); i++ )
for( unsigned i=0; i<m_Layers.size(); i++ )
delete m_Layers[i];
m_Layers.clear();
}
@@ -64,7 +64,7 @@ void BGAnimation::LoadFromAniDir( CString sAniDir, CString sSongBGPath )
SortCStringArray( asImagePaths );
for( int i=0; i<asImagePaths.GetSize(); i++ )
for( unsigned i=0; i<asImagePaths.size(); i++ )
{
const CString sPath = asImagePaths[i];
CString sDir, sFName, sExt;
@@ -109,19 +109,19 @@ void BGAnimation::LoadFromVisualization( CString sVisPath, CString sSongBGPath )
void BGAnimation::Update( float fDeltaTime )
{
for( int i=0; i<m_Layers.GetSize(); i++ )
for( unsigned i=0; i<m_Layers.size(); i++ )
m_Layers[i]->Update( fDeltaTime );
}
void BGAnimation::DrawPrimitives()
{
for( int i=0; i<m_Layers.GetSize(); i++ )
for( unsigned i=0; i<m_Layers.size(); i++ )
m_Layers[i]->Draw();
}
void BGAnimation::GainingFocus()
{
for( int i=0; i<m_Layers.GetSize(); i++ )
for( unsigned i=0; i<m_Layers.size(); i++ )
m_Layers[i]->GainingFocus();
SetDiffuse( RageColor(1,1,1,1) );
@@ -129,12 +129,12 @@ void BGAnimation::GainingFocus()
void BGAnimation::LosingFocus()
{
for( int i=0; i<m_Layers.GetSize(); i++ )
for( unsigned i=0; i<m_Layers.size(); i++ )
m_Layers[i]->LosingFocus();
}
void BGAnimation::SetDiffuse( const RageColor &c )
{
for( int i=0; i<m_Layers.GetSize(); i++ )
for( unsigned i=0; i<m_Layers.size(); i++ )
m_Layers[i]->SetDiffuse(c);
}
+7 -7
View File
@@ -37,22 +37,22 @@ void MusicList::AddGroup()
void MusicList::AddSongsToGroup(const CArray<Song*,Song*> &Songs)
{
// Generate what text will show in the contents for each group
int group = m_ContentsText.GetSize()-1;
unsigned group = m_ContentsText.size()-1;
m_ContentsText[group].m_iNumSongsInGroup = Songs.GetSize();
m_ContentsText[group].m_iNumSongsInGroup = Songs.size();
for( int c=0; c<TITLES_COLUMNS; c++ ) // foreach col
{
CString sText;
for( int r=0; r<TITLES_ROWS; r++ ) // foreach row
{
int iIndex = c*TITLES_ROWS + r;
if( iIndex >= Songs.GetSize() )
unsigned iIndex = c*TITLES_ROWS + r;
if( iIndex >= Songs.size() )
continue;
if( c == TITLES_COLUMNS-1 && r == TITLES_ROWS-1 && Songs.GetSize() != TITLES_COLUMNS*TITLES_ROWS )
if( c == TITLES_COLUMNS-1 && r == TITLES_ROWS-1 && Songs.size() != unsigned(TITLES_COLUMNS*TITLES_ROWS) )
{
sText += ssprintf( "%d more.....", Songs.GetSize() - TITLES_COLUMNS * TITLES_ROWS + 1 );
sText += ssprintf( "%d more.....", Songs.size() - TITLES_COLUMNS * TITLES_ROWS + 1 );
continue;
}
@@ -65,7 +65,7 @@ void MusicList::AddSongsToGroup(const CArray<Song*,Song*> &Songs)
}
sText += sTitle + "\n";
}
m_ContentsText[m_ContentsText.GetSize()-1].ContentsText[c] = sText;
m_ContentsText[m_ContentsText.size()-1].ContentsText[c] = sText;
}
}
+9 -9
View File
@@ -74,7 +74,7 @@ void NoteData::LoadFromSMNoteDataString( CString sSMNoteData )
CStringArray asMeasures;
split( sSMNoteData, ",", asMeasures, true ); // ignore empty is important
for( int m=0; m<asMeasures.GetSize(); m++ ) // foreach measure
for( unsigned m=0; m<asMeasures.size(); m++ ) // foreach measure
{
CString &sMeasureString = asMeasures[m];
sMeasureString.TrimLeft();
@@ -83,19 +83,19 @@ void NoteData::LoadFromSMNoteDataString( CString sSMNoteData )
CStringArray asMeasureLines;
split( sMeasureString, "\n", asMeasureLines, true ); // ignore empty is important
//ASSERT( asMeasureLines.GetSize() == 4 ||
// asMeasureLines.GetSize() == 8 ||
// asMeasureLines.GetSize() == 12 ||
// asMeasureLines.GetSize() == 16 );
//ASSERT( asMeasureLines.size() == 4 ||
// asMeasureLines.size() == 8 ||
// asMeasureLines.size() == 12 ||
// asMeasureLines.size() == 16 );
for( int l=0; l<asMeasureLines.GetSize(); l++ )
for( unsigned l=0; l<asMeasureLines.size(); l++ )
{
CString &sMeasureLine = asMeasureLines[l];
sMeasureLine.TrimLeft();
sMeasureLine.TrimRight();
const float fPercentIntoMeasure = l/(float)asMeasureLines.GetSize();
const float fPercentIntoMeasure = l/(float)asMeasureLines.size();
const float fBeat = (m + fPercentIntoMeasure) * BEATS_PER_MEASURE;
const int iIndex = BeatToNoteRow( fBeat );
@@ -571,7 +571,7 @@ void NoteData::Turn( PlayerOptions::TurnType tt )
for( t=0; t<m_iNumTracks; t++ )
{
int iRandTrackIndex = rand()%aiTracksLeftToMap.GetSize();
int iRandTrackIndex = rand()%aiTracksLeftToMap.size();
int iRandTrack = aiTracksLeftToMap[iRandTrackIndex];
aiTracksLeftToMap.RemoveAt( iRandTrackIndex );
iTakeFromTrack[t] = iRandTrack;
@@ -632,7 +632,7 @@ void NoteData::Turn( PlayerOptions::TurnType tt )
{
if( GetTapNote(t, r) != TAP_HOLD && GetTapNote(t, r) != TAP_EMPTY ) // there is a tap note here (and not a HoldNote)
{
int iRandIndex = rand() % aiTracksThatCouldHaveTapNotes.GetSize();
int iRandIndex = rand() % aiTracksThatCouldHaveTapNotes.size();
int iTo = aiTracksThatCouldHaveTapNotes[ iRandIndex ];
aiTracksThatCouldHaveTapNotes.RemoveAt( iRandIndex );
+5 -5
View File
@@ -72,7 +72,7 @@ void NoteDisplay::Load( int iColNum, PlayerNumber pn )
m_colorTapTweens.Add( color );
} while( bSuccess );
if( m_colorTapTweens.GetSize() == 0 )
if( m_colorTapTweens.empty() )
m_colorTapTweens.Add( RageColor(1,1,1,1) );
fclose( fp );
@@ -176,17 +176,17 @@ void NoteDisplay::GetTapEdgeColors( const float fNoteBeat, RageColor &colorLeadi
return;
}
float fLeadingColorIndex = fPercentThroughColorsLeading * m_colorTapTweens.GetSize();
float fTrailingColorIndex = fPercentThroughColorsTrailing* m_colorTapTweens.GetSize();
float fLeadingColorIndex = fPercentThroughColorsLeading * m_colorTapTweens.size();
float fTrailingColorIndex = fPercentThroughColorsTrailing* m_colorTapTweens.size();
float fLeadingColorWeightOf2 = fLeadingColorIndex - int(fLeadingColorIndex);
int iLeadingColor1 = int(fLeadingColorIndex);
int iLeadingColor2 = (iLeadingColor1 + 1) % m_colorTapTweens.GetSize();
int iLeadingColor2 = (iLeadingColor1 + 1) % m_colorTapTweens.size();
colorLeadingOut = m_colorTapTweens[iLeadingColor1] * (1-fLeadingColorWeightOf2) + m_colorTapTweens[iLeadingColor2] * fLeadingColorWeightOf2;
float fTrailingColorWeightOf2 = fTrailingColorIndex - int(fTrailingColorIndex);
int iTrailingColor1 = int(fTrailingColorIndex);
int iTrailingColor2 = (iTrailingColor1 + 1) % m_colorTapTweens.GetSize();
int iTrailingColor2 = (iTrailingColor1 + 1) % m_colorTapTweens.size();
colorTrailingOut = m_colorTapTweens[iTrailingColor1] * (1-fTrailingColorWeightOf2) + m_colorTapTweens[iTrailingColor2] * fTrailingColorWeightOf2;
}
+1 -1
View File
@@ -7,7 +7,7 @@ bool NotesLoader::Loadable( CString sPath )
{
CStringArray list;
GetApplicableFiles( sPath, list );
return list.GetSize() != 0;
return !list.empty();
}
void NotesLoader::GetMainAndSubTitlesFromFullTitle( const CString sFullTitle, CString &sMainTitleOut, CString &sSubTitleOut )
+9 -9
View File
@@ -161,10 +161,10 @@ bool BMSLoader::LoadFromBMSFile( const CString &sPath, Notes &out )
arrayNotes.Add( bThisIsANote );
}
const int iNumNotesInThisMeasure = arrayNotes.GetSize();
const unsigned iNumNotesInThisMeasure = arrayNotes.size();
//LOG->Trace( "%s:%s: iMeasureNo = %d, iNoteNum = %d, iNumNotesInThisMeasure = %d",
// valuename.GetString(), sNoteData.GetString(), iMeasureNo, iNoteNum, iNumNotesInThisMeasure );
for( int j=0; j<iNumNotesInThisMeasure; j++ )
for( unsigned j=0; j<iNumNotesInThisMeasure; j++ )
{
if( arrayNotes[j] )
{
@@ -258,11 +258,11 @@ bool BMSLoader::LoadFromDir( CString sDir, Song &out )
CStringArray arrayBMSFileNames;
GetApplicableFiles( sDir, arrayBMSFileNames );
if( arrayBMSFileNames.GetSize() == 0 )
if( arrayBMSFileNames.empty() )
throw RageException( "Couldn't find any BMS files in '%s'", sDir.GetString() );
// load the Notes from the rest of the BMS files
for( int i=0; i<arrayBMSFileNames.GetSize(); i++ )
for( unsigned i=0; i<arrayBMSFileNames.size(); i++ )
{
Notes* pNewNotes = new Notes;
@@ -364,10 +364,10 @@ bool BMSLoader::LoadFromDir( CString sDir, Song &out )
arrayNotes.Add( iNote );
}
const int iNumNotesInThisMeasure = arrayNotes.GetSize();
const unsigned iNumNotesInThisMeasure = arrayNotes.size();
//LOG->Trace( "%s:%s: iMeasureNo = %d, iBMSTrackNo = %d, iNumNotesInThisMeasure = %d",
// valuename.GetString(), sNoteData.GetString(), iMeasureNo, iBMSTrackNo, iNumNotesInThisMeasure );
for( int j=0; j<iNumNotesInThisMeasure; j++ )
for( unsigned j=0; j<iNumNotesInThisMeasure; j++ )
{
if( arrayNotes[j] == 0 )
continue;
@@ -511,7 +511,7 @@ bool BMSLoader::LoadFromDir( CString sDir, Song &out )
{
// find the BPM at the time of this freeze
float fBPM = -1;
for( int i=0; i<out.m_BPMSegments.GetSize()-1; i++ )
for( unsigned i=0; i<out.m_BPMSegments.size()-1; i++ )
{
if( out.m_BPMSegments[i].m_fStartBeat <= fFreezeStartBeat &&
out.m_BPMSegments[i+1].m_fStartBeat > fFreezeStartBeat )
@@ -522,7 +522,7 @@ bool BMSLoader::LoadFromDir( CString sDir, Song &out )
}
// the BPM segment of this beat is the last BPM segment
if( fBPM == -1 )
fBPM = out.m_BPMSegments[out.m_BPMSegments.GetSize()-1].m_fBPM;
fBPM = out.m_BPMSegments[out.m_BPMSegments.size()-1].m_fBPM;
fFreezeSecs = (float)atof(value_data)/(fBPM*0.81f); // I have no idea what units these are in, so I experimented until finding this factor.
break;
@@ -548,7 +548,7 @@ bool BMSLoader::LoadFromDir( CString sDir, Song &out )
}
}
for( i=0; i<out.m_BPMSegments.GetSize(); i++ )
for( i=0; i<out.m_BPMSegments.size(); i++ )
LOG->Trace( "There is a BPM change at beat %f, BPM %f, index %d",
out.m_BPMSegments[i].m_fStartBeat, out.m_BPMSegments[i].m_fBPM, i );
+7 -7
View File
@@ -228,35 +228,35 @@ bool NotesWriterDWI::Write( CString sPath, const Song &out )
fprintf( fp, "#SAMPLESTART:%.3f;\n", out.m_fMusicSampleStartSeconds );
fprintf( fp, "#SAMPLELENGTH:%.3f;\n", out.m_fMusicSampleLengthSeconds );
if( out.m_StopSegments.GetSize() )
if( !out.m_StopSegments.empty() )
{
fprintf( fp, "#FREEZE:" );
for( int i=0; i<out.m_StopSegments.GetSize(); i++ )
for( unsigned i=0; i<out.m_StopSegments.size(); i++ )
{
const StopSegment &fs = out.m_StopSegments[i];
fprintf( fp, "%.3f=%.3f", BeatToNoteRow( fs.m_fStartBeat ) * 4.0f / ROWS_PER_BEAT,
roundf(fs.m_fStopSeconds*1000) );
if( i != out.m_StopSegments.GetSize()-1 )
if( i != out.m_StopSegments.size()-1 )
fprintf( fp, "," );
}
fprintf( fp, ";\n" );
}
if( out.m_BPMSegments.GetSize() > 1)
if( out.m_BPMSegments.size() > 1)
{
fprintf( fp, "#CHANGEBPM:" );
for( int i=1; i<out.m_BPMSegments.GetSize(); i++ )
for( unsigned i=1; i<out.m_BPMSegments.size(); i++ )
{
const BPMSegment &bs = out.m_BPMSegments[i];
fprintf( fp, "%.3f=%.3f", BeatToNoteRow( bs.m_fStartBeat ) * 4.0f / ROWS_PER_BEAT, bs.m_fBPM );
if( i != out.m_BPMSegments.GetSize()-1 )
if( i != out.m_BPMSegments.size()-1 )
fprintf( fp, "," );
}
fprintf( fp, ";\n" );
}
for( int i=0; i<out.m_apNotes.GetSize(); i++ )
for( unsigned i=0; i<out.m_apNotes.size(); i++ )
{
if( -1 != out.m_apNotes[i]->m_sDescription.Find("autogen") )
continue; // don't save autogen notes
+5 -5
View File
@@ -225,21 +225,21 @@ void ScreenSelectMode::RefreshModeChoices()
int iNumSidesJoined = GAMESTATE->GetNumSidesJoined();
GAMEMAN->GetModesChoicesForGame( GAMESTATE->m_CurGame, m_aPossibleModeChoices );
ASSERT( m_aPossibleModeChoices.GetSize() > 0 );
ASSERT( !m_aPossibleModeChoices.empty() );
int i;
// remove ModeChoices that won't work with the current number of players
for( i=m_aPossibleModeChoices.GetSize()-1; i>=0; i-- )
for( i=m_aPossibleModeChoices.size()-1; i>=0; i-- )
if( m_aPossibleModeChoices[i].numSidesJoinedToPlay != iNumSidesJoined )
m_aPossibleModeChoices.RemoveAt( i );
CString sGameName = GAMESTATE->GetCurrentGameDef()->m_szName;
CStringArray asGraphicPaths;
for( i=0; i<m_aPossibleModeChoices.GetSize(); i++ )
for( unsigned j=0; j<m_aPossibleModeChoices.size(); j++ )
{
const ModeChoice& choice = m_aPossibleModeChoices[i];
const ModeChoice& choice = m_aPossibleModeChoices[j];
asGraphicPaths.Add( THEME->GetPathTo("Graphics", ssprintf("select mode choice %s %s", sGameName.GetString(), choice.name) ) );
}
@@ -250,7 +250,7 @@ void ScreenSelectMode::RefreshModeChoices()
{
CString sGameName = GAMESTATE->GetCurrentGameDef()->m_szName;
for( int i=0; i<m_aPossibleModeChoices.GetSize(); i++ )
for( unsigned i=0; i<m_aPossibleModeChoices.size(); i++ )
{
CString sChoiceName = m_aPossibleModeChoices[i].name;
m_BGAnimations[i].LoadFromAniDir( THEME->GetPathTo("BGAnimations",ssprintf("select mode %s %s", sGameName.GetString(), sChoiceName.GetString())) );
+11 -11
View File
@@ -45,7 +45,7 @@ ScrollingList::~ScrollingList()
void ScrollingList::Unload()
{
for( int i=0; i<m_apSprites.GetSize(); i++ )
for( unsigned i=0; i<m_apSprites.size(); i++ )
delete m_apSprites[i];
m_apSprites.clear();
}
@@ -57,7 +57,7 @@ in the scrolling list
void ScrollingList::Load( const CStringArray& asGraphicPaths )
{
Unload();
for( int i=0; i<asGraphicPaths.GetSize(); i++ )
for( unsigned i=0; i<asGraphicPaths.size(); i++ )
{
Sprite* pNewSprite = new Sprite;
pNewSprite->Load( asGraphicPaths[i] );
@@ -73,9 +73,9 @@ Make the entire list shuffle left
**************************************/
void ScrollingList::Left()
{
ASSERT( m_apSprites.GetSize() > 0 ); // nothing loaded!
ASSERT( !m_apSprites.empty() ); // nothing loaded!
m_iSelection = (m_iSelection + m_apSprites.GetSize() - 1) % m_apSprites.GetSize(); // decrement with wrapping
m_iSelection = (m_iSelection + m_apSprites.size() - 1) % m_apSprites.size(); // decrement with wrapping
m_fSelectionLag -= 1;
}
@@ -86,9 +86,9 @@ Make the entire list shuffle right
**************************************/
void ScrollingList::Right()
{
ASSERT( m_apSprites.GetSize() > 0 ); // nothing loaded!
ASSERT( !m_apSprites.empty() ); // nothing loaded!
m_iSelection = (m_iSelection + 1) % m_apSprites.GetSize(); // increment with wrapping
m_iSelection = (m_iSelection + 1) % m_apSprites.size(); // increment with wrapping
m_fSelectionLag += 1;
}
@@ -133,7 +133,7 @@ void ScrollingList::Update( float fDeltaTime )
{
ActorFrame::Update( fDeltaTime );
if( m_apSprites.GetSize() == 0 )
if( m_apSprites.empty() )
return;
// update m_fLaggingSelection
@@ -149,7 +149,7 @@ void ScrollingList::Update( float fDeltaTime )
m_fSelectionLag = 0; // snap
}
for( int i=0; i<m_apSprites.GetSize(); i++ )
for( unsigned i=0; i<m_apSprites.size(); i++ )
m_apSprites[i]->Update( fDeltaTime );
}
@@ -160,7 +160,7 @@ Draws the elements onto the screen
*********************************/
void ScrollingList::DrawPrimitives()
{
ASSERT( m_apSprites.GetSize() > 0 );
ASSERT( !m_apSprites.empty() );
for( int i=(m_iNumVisible)/2; i>= 0; i-- ) // draw outside to inside
{
@@ -168,8 +168,8 @@ void ScrollingList::DrawPrimitives()
int iIndexToDraw2 = m_iSelection + i;
// wrap IndexToDraw*
iIndexToDraw1 = (iIndexToDraw1 + m_apSprites.GetSize()*300) % m_apSprites.GetSize(); // make sure this is positive
iIndexToDraw2 = iIndexToDraw2 % m_apSprites.GetSize();
iIndexToDraw1 = (iIndexToDraw1 + m_apSprites.size()*300) % m_apSprites.size(); // make sure this is positive
iIndexToDraw2 = iIndexToDraw2 % m_apSprites.size();
ASSERT( iIndexToDraw1 >= 0 );
+1 -1
View File
@@ -30,7 +30,7 @@ void SongCacheIndex::ReadCacheIndex()
LOG->Trace( "Cache format is out of date. Deleting all cache files." );
CStringArray asCacheFileNames;
GetDirListing( "Cache/*.*", asCacheFileNames );
for( int i=0; i<asCacheFileNames.GetSize(); i++ )
for( unsigned i=0; i<asCacheFileNames.size(); i++ )
DeleteFile( "Cache/" + asCacheFileNames[i] );
CacheIndex.Reset();
}
+3 -3
View File
@@ -36,7 +36,7 @@ TipDisplay::TipDisplay()
void TipDisplay::SetTips( CStringArray &arrayTips )
{
m_arrayTips = arrayTips;
if( m_arrayTips.GetSize() > 0 )
if( !m_arrayTips.empty() )
m_textTip.SetText( m_arrayTips[0] );
}
@@ -45,13 +45,13 @@ void TipDisplay::Update( float fDeltaTime )
{
ActorFrame::Update( fDeltaTime );
if( m_arrayTips.GetSize() > 0 )
if( !m_arrayTips.empty() )
{
m_fSecsUntilSwitch -= fDeltaTime;
if( m_fSecsUntilSwitch < 0 ) // time to switch states
{
m_iCurTipIndex++;
m_iCurTipIndex = m_iCurTipIndex % m_arrayTips.GetSize();
m_iCurTipIndex = m_iCurTipIndex % m_arrayTips.size();
m_fSecsUntilSwitch = TIP_SHOW_TIME;
m_textTip.SetText( m_arrayTips[m_iCurTipIndex] );
}