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

This commit is contained in:
Glenn Maynard
2002-10-31 02:46:42 +00:00
parent d770105b2f
commit 2b16872bd5
5 changed files with 113 additions and 111 deletions
+26 -25
View File
@@ -75,7 +75,7 @@ Background::~Background()
void Background::Unload() void Background::Unload()
{ {
for( int i=0; i<m_BGAnimations.GetSize(); i++ ) for( unsigned i=0; i<m_BGAnimations.size(); i++ )
delete m_BGAnimations[i]; delete m_BGAnimations[i];
m_BGAnimations.clear(); m_BGAnimations.clear();
@@ -104,7 +104,7 @@ BGAnimation *Background::GetBGA(const Song *pSong, const BackgroundChange &anise
// Look for BG movies in the song dir // Look for BG movies in the song dir
GetDirListing( pSong->m_sSongDir+aniseg.m_sBGName, asFiles, false, true ); GetDirListing( pSong->m_sSongDir+aniseg.m_sBGName, asFiles, false, true );
if( asFiles.GetSize() > 0 ) if( !asFiles.empty() )
{ {
pTempBGA = new BGAnimation; pTempBGA = new BGAnimation;
pTempBGA->LoadFromMovie( asFiles[0], true, true ); pTempBGA->LoadFromMovie( asFiles[0], true, true );
@@ -112,7 +112,7 @@ BGAnimation *Background::GetBGA(const Song *pSong, const BackgroundChange &anise
} }
// Look for BGAnims in the song dir // Look for BGAnims in the song dir
GetDirListing( pSong->m_sSongDir+aniseg.m_sBGName, asFiles, true, true ); GetDirListing( pSong->m_sSongDir+aniseg.m_sBGName, asFiles, true, true );
if( asFiles.GetSize() > 0 ) if( !asFiles.empty() )
{ {
pTempBGA = new BGAnimation; pTempBGA = new BGAnimation;
pTempBGA->LoadFromAniDir( asFiles[0], bgpath ); pTempBGA->LoadFromAniDir( asFiles[0], bgpath );
@@ -121,7 +121,7 @@ BGAnimation *Background::GetBGA(const Song *pSong, const BackgroundChange &anise
// Look for movies in the RandomMovies dir // Look for movies in the RandomMovies dir
GetDirListing( RANDOMMOVIES_DIR+aniseg.m_sBGName, asFiles, false, true ); GetDirListing( RANDOMMOVIES_DIR+aniseg.m_sBGName, asFiles, false, true );
if( asFiles.GetSize() > 0 ) if( !asFiles.empty() )
{ {
pTempBGA = new BGAnimation; pTempBGA = new BGAnimation;
pTempBGA->LoadFromMovie( asFiles[0], true, false ); pTempBGA->LoadFromMovie( asFiles[0], true, false );
@@ -130,7 +130,7 @@ BGAnimation *Background::GetBGA(const Song *pSong, const BackgroundChange &anise
// Look for BGAnims in the BGAnims dir // Look for BGAnims in the BGAnims dir
GetDirListing( BG_ANIMS_DIR+aniseg.m_sBGName, asFiles, true, true ); GetDirListing( BG_ANIMS_DIR+aniseg.m_sBGName, asFiles, true, true );
if( asFiles.GetSize() > 0 ) if( !asFiles.empty() )
{ {
pTempBGA = new BGAnimation; pTempBGA = new BGAnimation;
pTempBGA->LoadFromAniDir( asFiles[0], bgpath ); pTempBGA->LoadFromAniDir( asFiles[0], bgpath );
@@ -139,7 +139,7 @@ BGAnimation *Background::GetBGA(const Song *pSong, const BackgroundChange &anise
// Look for BGAnims in the BGAnims dir // Look for BGAnims in the BGAnims dir
GetDirListing( VISUALIZATIONS_DIR+aniseg.m_sBGName, asFiles, false, true ); GetDirListing( VISUALIZATIONS_DIR+aniseg.m_sBGName, asFiles, false, true );
if( asFiles.GetSize() > 0 ) if( !asFiles.empty() )
{ {
pTempBGA = new BGAnimation; pTempBGA = new BGAnimation;
pTempBGA->LoadFromVisualization( asFiles[0], bgpath ); pTempBGA->LoadFromVisualization( asFiles[0], bgpath );
@@ -189,7 +189,7 @@ void Background::LoadFromSong( Song* pSong )
// Load the animations used by the song's pre-defined animation plan. // Load the animations used by the song's pre-defined animation plan.
// the song has a plan. Use it. // the song has a plan. Use it.
for( int i=0; i<pSong->m_BackgroundChanges.GetSize(); i++ ) for( unsigned i=0; i<pSong->m_BackgroundChanges.size(); i++ )
{ {
const BackgroundChange& aniseg = pSong->m_BackgroundChanges[i]; const BackgroundChange& aniseg = pSong->m_BackgroundChanges[i];
bool bFade = i==0; bool bFade = i==0;
@@ -200,7 +200,7 @@ void Background::LoadFromSong( Song* pSong )
{ {
m_BGAnimations.Add( pTempBGA ); m_BGAnimations.Add( pTempBGA );
// add to the plan // add to the plan
m_aBGSegments.Add( BGSegment(aniseg.m_fStartBeat, m_BGAnimations.GetSize()-1, bFade) ); m_aBGSegments.Add( BGSegment(aniseg.m_fStartBeat, m_BGAnimations.size()-1, bFade) );
} }
} }
@@ -243,9 +243,9 @@ void Background::LoadFromSong( Song* pSong )
GetDirListing( VISUALIZATIONS_DIR + "*.mpeg", arrayPossibleMovies, false, true ); GetDirListing( VISUALIZATIONS_DIR + "*.mpeg", arrayPossibleMovies, false, true );
BGAnimation *pTempBGA = NULL; BGAnimation *pTempBGA = NULL;
if( arrayPossibleMovies.GetSize() > 0 ) if( !arrayPossibleMovies.empty() )
{ {
int index = rand() % arrayPossibleMovies.GetSize(); unsigned index = rand() % arrayPossibleMovies.size();
pTempBGA = new BGAnimation; pTempBGA = new BGAnimation;
pTempBGA->LoadFromVisualization( arrayPossibleMovies[index], sSongBackgroundPath ); pTempBGA->LoadFromVisualization( arrayPossibleMovies[index], sSongBackgroundPath );
} }
@@ -262,12 +262,12 @@ void Background::LoadFromSong( Song* pSong )
CStringArray arrayPossibleAnims; CStringArray arrayPossibleAnims;
GetDirListing( BG_ANIMS_DIR+"*.*", arrayPossibleAnims, true, true ); GetDirListing( BG_ANIMS_DIR+"*.*", arrayPossibleAnims, true, true );
// strip out "cvs" and "danger // strip out "cvs" and "danger
for( int i=arrayPossibleAnims.GetSize()-1; i>=0; i-- ) for( int i=arrayPossibleAnims.size()-1; i>=0; i-- )
if( 0==stricmp(arrayPossibleAnims[i].Right(3),"cvs") || 0==stricmp(arrayPossibleAnims[i].Right(3),"danger") ) if( 0==stricmp(arrayPossibleAnims[i].Right(3),"cvs") || 0==stricmp(arrayPossibleAnims[i].Right(3),"danger") )
arrayPossibleAnims.RemoveAt(i); arrayPossibleAnims.RemoveAt(i);
for( i=0; i<4 && arrayPossibleAnims.GetSize()>0; i++ ) for( i=0; i<4 && !arrayPossibleAnims.empty(); i++ )
{ {
int index = rand() % arrayPossibleAnims.GetSize(); unsigned index = rand() % arrayPossibleAnims.size();
BGAnimation *pTempBGA = new BGAnimation; BGAnimation *pTempBGA = new BGAnimation;
pTempBGA->LoadFromAniDir( arrayPossibleAnims[index], sSongBackgroundPath ); pTempBGA->LoadFromAniDir( arrayPossibleAnims[index], sSongBackgroundPath );
m_BGAnimations.Add( pTempBGA ); m_BGAnimations.Add( pTempBGA );
@@ -281,9 +281,9 @@ void Background::LoadFromSong( Song* pSong )
GetDirListing( RANDOMMOVIES_DIR + "*.avi", arrayPossibleMovies, false, true ); GetDirListing( RANDOMMOVIES_DIR + "*.avi", arrayPossibleMovies, false, true );
GetDirListing( RANDOMMOVIES_DIR + "*.mpg", arrayPossibleMovies, false, true ); GetDirListing( RANDOMMOVIES_DIR + "*.mpg", arrayPossibleMovies, false, true );
GetDirListing( RANDOMMOVIES_DIR + "*.mpeg", arrayPossibleMovies, false, true ); GetDirListing( RANDOMMOVIES_DIR + "*.mpeg", arrayPossibleMovies, false, true );
for( int i=0; i<4 && arrayPossibleMovies.GetSize()>0; i++ ) for( int i=0; i<4 && !arrayPossibleMovies.empty(); i++ )
{ {
int index = rand() % arrayPossibleMovies.GetSize(); unsigned index = rand() % arrayPossibleMovies.size();
BGAnimation *pTempBGA = new BGAnimation; BGAnimation *pTempBGA = new BGAnimation;
pTempBGA->LoadFromMovie( arrayPossibleMovies[index], true, false ); pTempBGA->LoadFromMovie( arrayPossibleMovies[index], true, false );
m_BGAnimations.Add( pTempBGA ); m_BGAnimations.Add( pTempBGA );
@@ -318,24 +318,24 @@ void Background::LoadFromSong( Song* pSong )
/* If we have only 2, only generate a single animation segment for for the /* If we have only 2, only generate a single animation segment for for the
* whole song. Otherwise, if it's a movie, it'll loop every four measures; we * whole song. Otherwise, if it's a movie, it'll loop every four measures; we
* want it to play continuously. */ * want it to play continuously. */
if( m_BGAnimations.GetSize() == 2) { if( m_BGAnimations.size() == 2) {
m_aBGSegments.Add( BGSegment(fFirstBeat,1,bFade) ); m_aBGSegments.Add( BGSegment(fFirstBeat,1,bFade) );
} else { } else {
// change BG every 4 bars // change BG every 4 bars
for( float f=fFirstBeat; f<fLastBeat; f+=16 ) for( float f=fFirstBeat; f<fLastBeat; f+=16 )
{ {
int index; int index;
if( m_BGAnimations.GetSize()==1 ) if( m_BGAnimations.size()==1 )
index = 0; index = 0;
else if( f == fFirstBeat ) else if( f == fFirstBeat )
index = 1; // force the first random background to play first index = 1; // force the first random background to play first
else else
index = 1 + rand()%(m_BGAnimations.GetSize()-1); index = 1 + rand()%(m_BGAnimations.size()-1);
m_aBGSegments.Add( BGSegment(f,index,bFade) ); m_aBGSegments.Add( BGSegment(f,index,bFade) );
} }
// change BG every BPM change // change BG every BPM change
for( int i=0; i<pSong->m_BPMSegments.GetSize(); i++ ) for( unsigned i=0; i<pSong->m_BPMSegments.size(); i++ )
{ {
const BPMSegment& bpmseg = pSong->m_BPMSegments[i]; const BPMSegment& bpmseg = pSong->m_BPMSegments[i];
@@ -343,10 +343,10 @@ void Background::LoadFromSong( Song* pSong )
continue; // skip] continue; // skip]
int index; int index;
if( m_BGAnimations.GetSize()==1 ) if( m_BGAnimations.size()==1 )
index = 0; index = 0;
else else
index = 1 + int(bpmseg.m_fBPM)%(m_BGAnimations.GetSize()-1); index = 1 + int(bpmseg.m_fBPM)%(m_BGAnimations.size()-1);
m_aBGSegments.Add( BGSegment(bpmseg.m_fStartBeat,index,bFade) ); m_aBGSegments.Add( BGSegment(bpmseg.m_fStartBeat,index,bFade) );
} }
} }
@@ -358,7 +358,7 @@ void Background::LoadFromSong( Song* pSong )
SortBGSegmentArray( m_aBGSegments ); SortBGSegmentArray( m_aBGSegments );
} }
for( int i=0; i<m_BGAnimations.GetSize(); i++ ) for( unsigned i=0; i<m_BGAnimations.size(); i++ )
{ {
m_BGAnimations[i]->SetXY( (float)LEFT_EDGE, (float)TOP_EDGE ); m_BGAnimations[i]->SetXY( (float)LEFT_EDGE, (float)TOP_EDGE );
m_BGAnimations[i]->SetZoomX( fXZoom ); m_BGAnimations[i]->SetZoomX( fXZoom );
@@ -385,12 +385,13 @@ void Background::Update( float fDeltaTime )
return; return;
// Find the BGSegment we're in // Find the BGSegment we're in
for( int i=0; i<m_aBGSegments.GetSize()-1; i++ ) unsigned i;
for( i=0; i<m_aBGSegments.size()-1; i++ )
if( GAMESTATE->m_fSongBeat < m_aBGSegments[i+1].m_fStartBeat ) if( GAMESTATE->m_fSongBeat < m_aBGSegments[i+1].m_fStartBeat )
break; break;
ASSERT( i >= 0 && i<m_aBGSegments.GetSize() ); ASSERT( i >= 0 && i<m_aBGSegments.size() );
if( i > m_iCurBGSegment ) if( int(i) > m_iCurBGSegment )
{ {
// printf( "%d, %d, %f, %f\n", m_iCurBGSegment, i, m_aBGSegments[i].m_fStartBeat, GAMESTATE->m_fSongBeat ); // printf( "%d, %d, %f, %f\n", m_iCurBGSegment, i, m_aBGSegments[i].m_fStartBeat, GAMESTATE->m_fSongBeat );
BGAnimation* pOld = GetCurBGA(); BGAnimation* pOld = GetCurBGA();
+32 -34
View File
@@ -360,7 +360,7 @@ MusicWheel::MusicWheel()
{ {
CStringArray asGroupNames; CStringArray asGroupNames;
SONGMAN->GetGroupNames( asGroupNames ); SONGMAN->GetGroupNames( asGroupNames );
if( asGroupNames.GetSize() > 0 ) if( !asGroupNames.empty() )
{ {
/* XXX: Do groups get added if they're empty? /* XXX: Do groups get added if they're empty?
* This will select songs we can't use; we want the first song * This will select songs we can't use; we want the first song
@@ -368,7 +368,7 @@ MusicWheel::MusicWheel()
* -glenn */ * -glenn */
CArray<Song*, Song*> arraySongs; CArray<Song*, Song*> arraySongs;
SONGMAN->GetSongsInGroup( asGroupNames[0], arraySongs ); SONGMAN->GetSongsInGroup( asGroupNames[0], arraySongs );
if( arraySongs.GetSize() > 0 ) // still nothing selected if( !arraySongs.empty() ) // still nothing selected
GAMESTATE->m_pCurSong = arraySongs[0]; // select the first song GAMESTATE->m_pCurSong = arraySongs[0]; // select the first song
} }
} }
@@ -377,7 +377,7 @@ MusicWheel::MusicWheel()
// Select the the previously selected song (if any) // Select the the previously selected song (if any)
if( GAMESTATE->m_pCurSong ) if( GAMESTATE->m_pCurSong )
{ {
for( int i=0; i<GetCurWheelItemDatas().GetSize(); i++ ) for( unsigned i=0; i<GetCurWheelItemDatas().size(); i++ )
{ {
if( GetCurWheelItemDatas()[i].m_pSong == GAMESTATE->m_pCurSong ) if( GetCurWheelItemDatas()[i].m_pSong == GAMESTATE->m_pCurSong )
{ {
@@ -391,7 +391,7 @@ MusicWheel::MusicWheel()
// Select the the previously selected course (if any) // Select the the previously selected course (if any)
if( GAMESTATE->m_pCurCourse != NULL ) if( GAMESTATE->m_pCurCourse != NULL )
{ {
for( int i=0; i<GetCurWheelItemDatas().GetSize(); i++ ) for( unsigned i=0; i<GetCurWheelItemDatas().size(); i++ )
{ {
if( GetCurWheelItemDatas()[i].m_pCourse == GAMESTATE->m_pCurCourse ) if( GetCurWheelItemDatas()[i].m_pCourse == GAMESTATE->m_pCurCourse )
{ {
@@ -418,7 +418,7 @@ CArray<WheelItemData, WheelItemData&>& MusicWheel::GetCurWheelItemDatas()
void MusicWheel::BuildWheelItemDatas( CArray<WheelItemData, WheelItemData&> &arrayWheelItemDatas, SongSortOrder so, bool bRoulette ) void MusicWheel::BuildWheelItemDatas( CArray<WheelItemData, WheelItemData&> &arrayWheelItemDatas, SongSortOrder so, bool bRoulette )
{ {
int i; unsigned i;
switch( GAMESTATE->m_PlayMode ) switch( GAMESTATE->m_PlayMode )
{ {
@@ -430,7 +430,7 @@ void MusicWheel::BuildWheelItemDatas( CArray<WheelItemData, WheelItemData&> &arr
CArray<Song*, Song*> arraySongs; CArray<Song*, Song*> arraySongs;
// copy only songs that have at least one Notes for the current GameMode // copy only songs that have at least one Notes for the current GameMode
for( i=0; i<SONGMAN->m_pSongs.GetSize(); i++ ) for( i=0; i<SONGMAN->m_pSongs.size(); i++ )
{ {
Song* pSong = SONGMAN->m_pSongs[i]; Song* pSong = SONGMAN->m_pSongs[i];
@@ -448,7 +448,7 @@ void MusicWheel::BuildWheelItemDatas( CArray<WheelItemData, WheelItemData&> &arr
CArray<Notes*, Notes*> arraySteps; CArray<Notes*, Notes*> arraySteps;
pSong->GetNotesThatMatch( GAMESTATE->GetCurrentStyleDef()->m_NotesType, arraySteps ); pSong->GetNotesThatMatch( GAMESTATE->GetCurrentStyleDef()->m_NotesType, arraySteps );
if( arraySteps.GetSize() > 0 ) if( !arraySteps.empty() )
arraySongs.Add( pSong ); arraySongs.Add( pSong );
} }
@@ -470,7 +470,7 @@ void MusicWheel::BuildWheelItemDatas( CArray<WheelItemData, WheelItemData&> &arr
// break; // break;
case SORT_MOST_PLAYED: case SORT_MOST_PLAYED:
SortSongPointerArrayByMostPlayed( arraySongs ); SortSongPointerArrayByMostPlayed( arraySongs );
if( arraySongs.GetSize() > 30 ) if( arraySongs.size() > 30 )
arraySongs.erase(arraySongs.begin()+30, arraySongs.end()); arraySongs.erase(arraySongs.begin()+30, arraySongs.end());
break; break;
default: default:
@@ -502,7 +502,7 @@ void MusicWheel::BuildWheelItemDatas( CArray<WheelItemData, WheelItemData&> &arr
// make WheelItemDatas with sections // make WheelItemDatas with sections
CString sLastSection = ""; CString sLastSection = "";
RageColor colorSection; RageColor colorSection;
for( int i=0; i< arraySongs.GetSize(); i++ ) for( unsigned i=0; i< arraySongs.size(); i++ )
{ {
Song* pSong = arraySongs[i]; Song* pSong = arraySongs[i];
CString sThisSection = GetSectionNameFromSongAndSort( pSong, so ); CString sThisSection = GetSectionNameFromSongAndSort( pSong, so );
@@ -523,7 +523,7 @@ void MusicWheel::BuildWheelItemDatas( CArray<WheelItemData, WheelItemData&> &arr
} }
else else
{ {
for( int i=0; i<arraySongs.GetSize(); i++ ) for( unsigned i=0; i<arraySongs.size(); i++ )
{ {
Song* pSong = arraySongs[i]; Song* pSong = arraySongs[i];
if( GAMESTATE->m_sPreferredGroup != "ALL MUSIC" && pSong->m_sGroupName != GAMESTATE->m_sPreferredGroup ) if( GAMESTATE->m_sPreferredGroup != "ALL MUSIC" && pSong->m_sGroupName != GAMESTATE->m_sPreferredGroup )
@@ -550,7 +550,7 @@ void MusicWheel::BuildWheelItemDatas( CArray<WheelItemData, WheelItemData&> &arr
bool bFoundExtraSong = false; bool bFoundExtraSong = false;
for( int i=0; i<arrayWheelItemDatas.GetSize(); i++ ) for( unsigned i=0; i<arrayWheelItemDatas.size(); i++ )
{ {
if( arrayWheelItemDatas[i].m_pSong == pSong ) if( arrayWheelItemDatas[i].m_pSong == pSong )
{ {
@@ -567,23 +567,23 @@ void MusicWheel::BuildWheelItemDatas( CArray<WheelItemData, WheelItemData&> &arr
case PLAY_MODE_ONI: case PLAY_MODE_ONI:
case PLAY_MODE_ENDLESS: case PLAY_MODE_ENDLESS:
{ {
int i; unsigned i;
CArray<Course*,Course*> apCourses; CArray<Course*,Course*> apCourses;
switch( GAMESTATE->m_PlayMode ) switch( GAMESTATE->m_PlayMode )
{ {
case PLAY_MODE_ONI: case PLAY_MODE_ONI:
for( i=0; i<SONGMAN->m_aOniCourses.GetSize(); i++ ) for( i=0; i<SONGMAN->m_aOniCourses.size(); i++ )
apCourses.Add( &SONGMAN->m_aOniCourses[i] ); apCourses.Add( &SONGMAN->m_aOniCourses[i] );
SortCoursePointerArrayByDifficulty( apCourses ); SortCoursePointerArrayByDifficulty( apCourses );
break; break;
case PLAY_MODE_ENDLESS: case PLAY_MODE_ENDLESS:
for( i=0; i<SONGMAN->m_aEndlessCourses.GetSize(); i++ ) for( i=0; i<SONGMAN->m_aEndlessCourses.size(); i++ )
apCourses.Add( &SONGMAN->m_aEndlessCourses[i] ); apCourses.Add( &SONGMAN->m_aEndlessCourses[i] );
break; break;
} }
for( int c=0; c<apCourses.GetSize(); c++ ) // foreach course for( unsigned c=0; c<apCourses.size(); c++ ) // foreach course
{ {
Course* pCourse = apCourses[c]; Course* pCourse = apCourses[c];
@@ -593,7 +593,7 @@ void MusicWheel::BuildWheelItemDatas( CArray<WheelItemData, WheelItemData&> &arr
CStringArray asModifiers; CStringArray asModifiers;
pCourse->GetSongAndNotesForCurrentStyle( apSongs, apNotes, asModifiers, false ); pCourse->GetSongAndNotesForCurrentStyle( apSongs, apNotes, asModifiers, false );
if( apNotes.GetSize() > 0 ) if( !apNotes.empty() )
arrayWheelItemDatas.Add( WheelItemData(TYPE_COURSE, NULL, "", pCourse, pCourse->GetColor()) ); arrayWheelItemDatas.Add( WheelItemData(TYPE_COURSE, NULL, "", pCourse, pCourse->GetColor()) );
} }
} }
@@ -603,7 +603,7 @@ void MusicWheel::BuildWheelItemDatas( CArray<WheelItemData, WheelItemData&> &arr
} }
// init crowns // init crowns
for( i=0; i<arrayWheelItemDatas.GetSize(); i++ ) for( i=0; i<arrayWheelItemDatas.size(); i++ )
{ {
Song* pSong = arrayWheelItemDatas[i].m_pSong; Song* pSong = arrayWheelItemDatas[i].m_pSong;
if( pSong == NULL ) if( pSong == NULL )
@@ -617,16 +617,14 @@ void MusicWheel::BuildWheelItemDatas( CArray<WheelItemData, WheelItemData&> &arr
if( so == SORT_MOST_PLAYED ) if( so == SORT_MOST_PLAYED )
{ {
// init crown icons // init crown icons
for( int i=0; i< min(3,arrayWheelItemDatas.GetSize()); i++ ) for( i=0; i< min(3u,arrayWheelItemDatas.size()); i++ )
{ {
WheelItemData& WID = arrayWheelItemDatas[i]; WheelItemData& WID = arrayWheelItemDatas[i];
WID.m_IconType = MusicStatusDisplay::IconType(MusicStatusDisplay::crown1 + i); WID.m_IconType = MusicStatusDisplay::IconType(MusicStatusDisplay::crown1 + i);
} }
} }
if( arrayWheelItemDatas.empty() )
if( arrayWheelItemDatas.GetSize() == 0 )
{ {
arrayWheelItemDatas.Add( WheelItemData(TYPE_SECTION, NULL, "- EMPTY -", NULL, RageColor(1,0,0,1)) ); arrayWheelItemDatas.Add( WheelItemData(TYPE_SECTION, NULL, "- EMPTY -", NULL, RageColor(1,0,0,1)) );
} }
@@ -684,7 +682,7 @@ void MusicWheel::RebuildWheelItemDisplays()
{ {
// rewind to first index that will be displayed; // rewind to first index that will be displayed;
int iIndex = m_iSelection; int iIndex = m_iSelection;
if( m_iSelection > GetCurWheelItemDatas().GetSize()-1 ) if( m_iSelection > int(GetCurWheelItemDatas().size()-1) )
m_iSelection = 0; m_iSelection = 0;
for( int i=0; i<NUM_WHEEL_ITEMS_TO_DRAW/2; i++ ) for( int i=0; i<NUM_WHEEL_ITEMS_TO_DRAW/2; i++ )
@@ -693,7 +691,7 @@ void MusicWheel::RebuildWheelItemDisplays()
{ {
iIndex--; iIndex--;
if( iIndex < 0 ) if( iIndex < 0 )
iIndex = GetCurWheelItemDatas().GetSize()-1; iIndex = GetCurWheelItemDatas().size()-1;
} }
while( GetCurWheelItemDatas()[iIndex].m_WheelItemType == TYPE_SONG while( GetCurWheelItemDatas()[iIndex].m_WheelItemType == TYPE_SONG
&& GetCurWheelItemDatas()[iIndex].m_sSectionName != "" && GetCurWheelItemDatas()[iIndex].m_sSectionName != ""
@@ -712,7 +710,7 @@ void MusicWheel::RebuildWheelItemDisplays()
do do
{ {
iIndex++; iIndex++;
if( iIndex > GetCurWheelItemDatas().GetSize()-1 ) if( iIndex > int(GetCurWheelItemDatas().size()-1) )
iIndex = 0; iIndex = 0;
} }
while( GetCurWheelItemDatas()[iIndex].m_WheelItemType == TYPE_SONG while( GetCurWheelItemDatas()[iIndex].m_WheelItemType == TYPE_SONG
@@ -773,16 +771,16 @@ void MusicWheel::Update( float fDeltaTime )
{ {
ActorFrame::Update( fDeltaTime ); ActorFrame::Update( fDeltaTime );
unsigned i;
for( int i=0; i<NUM_WHEEL_ITEMS_TO_DRAW; i++ ) for( i=0; i<NUM_WHEEL_ITEMS_TO_DRAW; i++ )
{ {
WheelItemDisplay& display = m_WheelItemDisplays[i]; WheelItemDisplay& display = m_WheelItemDisplays[i];
display.Update( fDeltaTime ); display.Update( fDeltaTime );
} }
float fScrollPercentage = (m_iSelection-m_fPositionOffsetFromSelection) / (float)GetCurWheelItemDatas().GetSize(); float fScrollPercentage = (m_iSelection-m_fPositionOffsetFromSelection) / (float)GetCurWheelItemDatas().size();
float fPercentItemsShowing = NUM_WHEEL_ITEMS_TO_DRAW / (float)GetCurWheelItemDatas().GetSize(); float fPercentItemsShowing = NUM_WHEEL_ITEMS_TO_DRAW / (float)GetCurWheelItemDatas().size();
m_ScrollBar.SetPercentage( fScrollPercentage-fPercentItemsShowing/2, fScrollPercentage+fPercentItemsShowing/2 ); m_ScrollBar.SetPercentage( fScrollPercentage-fPercentItemsShowing/2, fScrollPercentage+fPercentItemsShowing/2 );
if( m_WheelState == STATE_ROULETTE_SPINNING ) if( m_WheelState == STATE_ROULETTE_SPINNING )
@@ -815,7 +813,7 @@ void MusicWheel::Update( float fDeltaTime )
if( pPrevSelectedSong != NULL ) // the previous selected item was a song if( pPrevSelectedSong != NULL ) // the previous selected item was a song
{ {
// find the previously selected song, and select it // find the previously selected song, and select it
for( i=0; i<GetCurWheelItemDatas().GetSize(); i++ ) for( i=0; i<GetCurWheelItemDatas().size(); i++ )
{ {
if( GetCurWheelItemDatas()[i].m_pSong == pPrevSelectedSong ) if( GetCurWheelItemDatas()[i].m_pSong == pPrevSelectedSong )
{ {
@@ -827,7 +825,7 @@ void MusicWheel::Update( float fDeltaTime )
else // the previously selected item was a section else // the previously selected item was a section
{ {
// find the previously selected song, and select it // find the previously selected song, and select it
for( i=0; i<GetCurWheelItemDatas().GetSize(); i++ ) for( i=0; i<GetCurWheelItemDatas().size(); i++ )
{ {
if( GetCurWheelItemDatas()[i].m_sSectionName == sPrevSelectedSection ) if( GetCurWheelItemDatas()[i].m_sSectionName == sPrevSelectedSection )
{ {
@@ -840,7 +838,7 @@ void MusicWheel::Update( float fDeltaTime )
// If changed sort to "BEST", put selection on most popular song // If changed sort to "BEST", put selection on most popular song
if( GAMESTATE->m_SongSortOrder == SORT_MOST_PLAYED ) if( GAMESTATE->m_SongSortOrder == SORT_MOST_PLAYED )
{ {
for( i=0; i<GetCurWheelItemDatas().GetSize(); i++ ) for( i=0; i<GetCurWheelItemDatas().size(); i++ )
{ {
if( GetCurWheelItemDatas()[i].m_pSong != NULL ) if( GetCurWheelItemDatas()[i].m_pSong != NULL )
{ {
@@ -1006,7 +1004,7 @@ void MusicWheel::PrevMusic( bool bSendSongChangedMessage )
{ {
m_iSelection--; m_iSelection--;
if( m_iSelection < 0 ) if( m_iSelection < 0 )
m_iSelection = GetCurWheelItemDatas().GetSize()-1; m_iSelection = GetCurWheelItemDatas().size()-1;
} }
while( (GetCurWheelItemDatas()[m_iSelection].m_WheelItemType == TYPE_SONG || GetCurWheelItemDatas()[m_iSelection].m_WheelItemType == TYPE_COURSE) while( (GetCurWheelItemDatas()[m_iSelection].m_WheelItemType == TYPE_SONG || GetCurWheelItemDatas()[m_iSelection].m_WheelItemType == TYPE_COURSE)
&& GetCurWheelItemDatas()[m_iSelection].m_sSectionName != "" && GetCurWheelItemDatas()[m_iSelection].m_sSectionName != ""
@@ -1050,7 +1048,7 @@ void MusicWheel::NextMusic( bool bSendSongChangedMessage )
do do
{ {
m_iSelection++; m_iSelection++;
if( m_iSelection > GetCurWheelItemDatas().GetSize()-1 ) if( m_iSelection > int(GetCurWheelItemDatas().size()-1) )
m_iSelection = 0; m_iSelection = 0;
} }
while( (GetCurWheelItemDatas()[m_iSelection].m_WheelItemType == TYPE_SONG || GetCurWheelItemDatas()[m_iSelection].m_WheelItemType == TYPE_COURSE) while( (GetCurWheelItemDatas()[m_iSelection].m_WheelItemType == TYPE_SONG || GetCurWheelItemDatas()[m_iSelection].m_WheelItemType == TYPE_COURSE)
@@ -1123,7 +1121,7 @@ bool MusicWheel::Select() // return true of a playable item was chosen
m_iSelection = 0; // reset in case we can't find the last selected song m_iSelection = 0; // reset in case we can't find the last selected song
// find the section header and select it // find the section header and select it
for( int i=0; i<GetCurWheelItemDatas().GetSize(); i++ ) for( unsigned i=0; i<GetCurWheelItemDatas().size(); i++ )
{ {
if( GetCurWheelItemDatas()[i].m_WheelItemType == TYPE_SECTION if( GetCurWheelItemDatas()[i].m_WheelItemType == TYPE_SECTION
&& GetCurWheelItemDatas()[i].m_sSectionName == sThisItemSectionName ) && GetCurWheelItemDatas()[i].m_sSectionName == sThisItemSectionName )
+6 -6
View File
@@ -33,7 +33,7 @@ void SMLoader::LoadFromSMTokens(
out.m_iMeter = atoi(sMeter); out.m_iMeter = atoi(sMeter);
CStringArray saValues; CStringArray saValues;
split( sRadarValues, ",", saValues, true ); split( sRadarValues, ",", saValues, true );
if( saValues.GetSize() == NUM_RADAR_VALUES ) if( saValues.size() == NUM_RADAR_VALUES )
for( int r=0; r<NUM_RADAR_VALUES; r++ ) for( int r=0; r<NUM_RADAR_VALUES; r++ )
out.m_fRadarValues[r] = (float)atof(saValues[r]); out.m_fRadarValues[r] = (float)atof(saValues[r]);
@@ -139,7 +139,7 @@ bool SMLoader::LoadFromSMFile( CString sPath, Song &out )
CStringArray arrayFreezeExpressions; CStringArray arrayFreezeExpressions;
split( sParams[1], ",", arrayFreezeExpressions ); split( sParams[1], ",", arrayFreezeExpressions );
for( int f=0; f<arrayFreezeExpressions.GetSize(); f++ ) for( unsigned f=0; f<arrayFreezeExpressions.size(); f++ )
{ {
CStringArray arrayFreezeValues; CStringArray arrayFreezeValues;
split( arrayFreezeExpressions[f], "=", arrayFreezeValues ); split( arrayFreezeExpressions[f], "=", arrayFreezeValues );
@@ -161,7 +161,7 @@ bool SMLoader::LoadFromSMFile( CString sPath, Song &out )
CStringArray arrayBPMChangeExpressions; CStringArray arrayBPMChangeExpressions;
split( sParams[1], ",", arrayBPMChangeExpressions ); split( sParams[1], ",", arrayBPMChangeExpressions );
for( int b=0; b<arrayBPMChangeExpressions.GetSize(); b++ ) for( unsigned b=0; b<arrayBPMChangeExpressions.size(); b++ )
{ {
CStringArray arrayBPMChangeValues; CStringArray arrayBPMChangeValues;
split( arrayBPMChangeExpressions[b], "=", arrayBPMChangeValues ); split( arrayBPMChangeExpressions[b], "=", arrayBPMChangeValues );
@@ -181,7 +181,7 @@ bool SMLoader::LoadFromSMFile( CString sPath, Song &out )
CStringArray aBGChangeExpressions; CStringArray aBGChangeExpressions;
split( sParams[1], ",", aBGChangeExpressions ); split( sParams[1], ",", aBGChangeExpressions );
for( int b=0; b<aBGChangeExpressions.GetSize(); b++ ) for( unsigned b=0; b<aBGChangeExpressions.size(); b++ )
{ {
CStringArray aBGChangeValues; CStringArray aBGChangeValues;
split( aBGChangeExpressions[b], "=", aBGChangeValues ); split( aBGChangeExpressions[b], "=", aBGChangeValues );
@@ -229,12 +229,12 @@ bool SMLoader::LoadFromDir( CString sPath, Song &out )
CStringArray aFileNames; CStringArray aFileNames;
GetApplicableFiles( sPath, aFileNames ); GetApplicableFiles( sPath, aFileNames );
if( aFileNames.GetSize() > 1 ) if( aFileNames.size() > 1 )
throw RageException( "There is more than one SM file in '%s'. There should be only one!", sPath.GetString() ); throw RageException( "There is more than one SM file in '%s'. There should be only one!", sPath.GetString() );
/* We should have exactly one; if we had none, we shouldn't have been /* We should have exactly one; if we had none, we shouldn't have been
* called to begin with. */ * called to begin with. */
ASSERT( aFileNames.GetSize() == 1 ); ASSERT( aFileNames.size() == 1 );
return LoadFromSMFile( sPath + aFileNames[0], out ); return LoadFromSMFile( sPath + aFileNames[0], out );
} }
+11 -10
View File
@@ -51,10 +51,11 @@ ScreenSelectStyle::ScreenSelectStyle()
GAMESTATE->m_bPlayersCanJoin = true; GAMESTATE->m_bPlayersCanJoin = true;
GAMEMAN->GetGameplayStylesForGame( GAMESTATE->m_CurGame, m_aPossibleStyles ); GAMEMAN->GetGameplayStylesForGame( GAMESTATE->m_CurGame, m_aPossibleStyles );
ASSERT( m_aPossibleStyles.GetSize() > 0 ); // every game should have at least one Style, or else why have the Game? :-) ASSERT( !m_aPossibleStyles.empty() ); // every game should have at least one Style, or else why have the Game? :-)
m_iSelection = 0; m_iSelection = 0;
for( int i=0; i<m_aPossibleStyles.GetSize(); i++ ) unsigned i;
for( i=0; i<m_aPossibleStyles.size(); i++ )
{ {
m_sprIcon[i].Load( THEME->GetPathTo("Graphics",ssprintf("select style icons %s",GAMESTATE->GetCurrentGameDef()->m_szName) ) ); m_sprIcon[i].Load( THEME->GetPathTo("Graphics",ssprintf("select style icons %s",GAMESTATE->GetCurrentGameDef()->m_szName) ) );
m_sprIcon[i].StopAnimating(); m_sprIcon[i].StopAnimating();
@@ -80,7 +81,7 @@ ScreenSelectStyle::ScreenSelectStyle()
const StyleDef* pStyleDef = GAMEMAN->GetStyleDefForStyle( m_aPossibleStyles[m_iSelection] ); const StyleDef* pStyleDef = GAMEMAN->GetStyleDefForStyle( m_aPossibleStyles[m_iSelection] );
// Load dummy Sprites // Load dummy Sprites
for( i=0; i<m_aPossibleStyles.GetSize(); i++ ) for( i=0; i<m_aPossibleStyles.size(); i++ )
{ {
m_sprDummyPreview[i].Load( THEME->GetPathTo("Graphics",ssprintf("select style preview %s %s",pGameDef->m_szName,pStyleDef->m_szName)) ); m_sprDummyPreview[i].Load( THEME->GetPathTo("Graphics",ssprintf("select style preview %s %s",pGameDef->m_szName,pStyleDef->m_szName)) );
m_sprDummyInfo[i].Load( THEME->GetPathTo("Graphics",ssprintf("select style info %s %s",pGameDef->m_szName,pStyleDef->m_szName)) ); m_sprDummyInfo[i].Load( THEME->GetPathTo("Graphics",ssprintf("select style info %s %s",pGameDef->m_szName,pStyleDef->m_szName)) );
@@ -217,7 +218,7 @@ void ScreenSelectStyle::MenuRight( PlayerNumber pn )
{ {
// search for a style to the right of the current selection that is enabled // search for a style to the right of the current selection that is enabled
int iSwitchToStyleIndex = -1; // -1 means none found int iSwitchToStyleIndex = -1; // -1 means none found
for( int i=m_iSelection+1; i<m_aPossibleStyles.GetSize(); i++ ) for( unsigned i=m_iSelection+1; i<m_aPossibleStyles.size(); i++ )
{ {
if( IsEnabled(i) ) if( IsEnabled(i) )
{ {
@@ -281,8 +282,8 @@ void ScreenSelectStyle::MenuBack( PlayerNumber pn )
void ScreenSelectStyle::TweenOnScreen() void ScreenSelectStyle::TweenOnScreen()
{ {
for( int i=0; i<m_aPossibleStyles.GetSize(); i++ ) for( unsigned i=0; i<m_aPossibleStyles.size(); i++ )
m_sprIcon[i].FadeOn( (m_aPossibleStyles.GetSize()-i)*0.05f, "Left Accelerate", MENU_ELEMENTS_TWEEN_TIME ); m_sprIcon[i].FadeOn( (m_aPossibleStyles.size()-i)*0.05f, "Left Accelerate", MENU_ELEMENTS_TWEEN_TIME );
m_sprExplanation.FadeOn( 0, "Right Accelerate", MENU_ELEMENTS_TWEEN_TIME ); m_sprExplanation.FadeOn( 0, "Right Accelerate", MENU_ELEMENTS_TWEEN_TIME );
@@ -291,7 +292,7 @@ void ScreenSelectStyle::TweenOnScreen()
void ScreenSelectStyle::TweenOffScreen() void ScreenSelectStyle::TweenOffScreen()
{ {
for( int i=0; i<m_aPossibleStyles.GetSize(); i++ ) for( unsigned i=0; i<m_aPossibleStyles.size(); i++ )
m_sprIcon[i].FadeOff( 0, "FoldY", MENU_ELEMENTS_TWEEN_TIME ); m_sprIcon[i].FadeOff( 0, "FoldY", MENU_ELEMENTS_TWEEN_TIME );
m_sprExplanation.FadeOff( 0, "FoldY", MENU_ELEMENTS_TWEEN_TIME ); m_sprExplanation.FadeOff( 0, "FoldY", MENU_ELEMENTS_TWEEN_TIME );
@@ -322,10 +323,10 @@ bool ScreenSelectStyle::IsEnabled( int iStyleIndex )
void ScreenSelectStyle::UpdateEnabledDisabled() void ScreenSelectStyle::UpdateEnabledDisabled()
{ {
int i; unsigned i;
/* XXX: If a player joins during the tween-in, this diffuse change /* XXX: If a player joins during the tween-in, this diffuse change
* will be undone by the tween. Hmm. */ * will be undone by the tween. Hmm. */
for( i=0; i<m_aPossibleStyles.GetSize(); i++ ) for( i=0; i<m_aPossibleStyles.size(); i++ )
{ {
if( IsEnabled(i) ) if( IsEnabled(i) )
m_sprIcon[i].SetDiffuse( RageColor(1,1,1,1) ); m_sprIcon[i].SetDiffuse( RageColor(1,1,1,1) );
@@ -337,7 +338,7 @@ void ScreenSelectStyle::UpdateEnabledDisabled()
BeforeChange(); BeforeChange();
int iSwitchToStyleIndex = -1; // -1 means none found int iSwitchToStyleIndex = -1; // -1 means none found
for( i=0; i<m_aPossibleStyles.GetSize(); i++ ) for( i=0; i<m_aPossibleStyles.size(); i++ )
{ {
if( IsEnabled(i) ) if( IsEnabled(i) )
{ {
+38 -36
View File
@@ -56,13 +56,13 @@ void SongManager::InitSongArrayFromDisk( void(*callback)() )
{ {
LoadStepManiaSongDir( "Songs", callback ); LoadStepManiaSongDir( "Songs", callback );
for( int i=0; i<PREFSMAN->m_asAdditionalSongFolders.GetSize(); i++ ) for( unsigned i=0; i<PREFSMAN->m_asAdditionalSongFolders.size(); i++ )
LoadStepManiaSongDir( PREFSMAN->m_asAdditionalSongFolders[i], callback ); LoadStepManiaSongDir( PREFSMAN->m_asAdditionalSongFolders[i], callback );
if( PREFSMAN->m_DWIPath != "" ) if( PREFSMAN->m_DWIPath != "" )
LoadStepManiaSongDir( PREFSMAN->m_DWIPath + "\\Songs", callback ); LoadStepManiaSongDir( PREFSMAN->m_DWIPath + "\\Songs", callback );
LOG->Trace( "Found %d Songs.", m_pSongs.GetSize() ); LOG->Trace( "Found %d Songs.", m_pSongs.size() );
} }
void SongManager::SanityCheckGroupDir( CString sDir ) const void SongManager::SanityCheckGroupDir( CString sDir ) const
@@ -72,7 +72,7 @@ void SongManager::SanityCheckGroupDir( CString sDir ) const
GetDirListing( sDir + "\\*.mp3", arrayFiles ); GetDirListing( sDir + "\\*.mp3", arrayFiles );
GetDirListing( sDir + "\\*.ogg", arrayFiles ); GetDirListing( sDir + "\\*.ogg", arrayFiles );
GetDirListing( sDir + "\\*.wav", arrayFiles ); GetDirListing( sDir + "\\*.wav", arrayFiles );
if( arrayFiles.GetSize() > 0 ) if( !arrayFiles.empty() )
throw RageException( throw RageException(
"The folder '%s' contains music files.\n\n" "The folder '%s' contains music files.\n\n"
"This means that you have a music outside of a song folder.\n" "This means that you have a music outside of a song folder.\n"
@@ -85,11 +85,11 @@ void SongManager::SanityCheckGroupDir( CString sDir ) const
void SongManager::AddGroup( CString sDir, CString sGroupDirName ) void SongManager::AddGroup( CString sDir, CString sGroupDirName )
{ {
int j; unsigned j;
for(j = 0; j < m_arrayGroupNames.GetSize(); ++j) for(j = 0; j < m_arrayGroupNames.size(); ++j)
if( sGroupDirName == m_arrayGroupNames[j] ) break; if( sGroupDirName == m_arrayGroupNames[j] ) break;
if( j != m_arrayGroupNames.GetSize() ) if( j != m_arrayGroupNames.size() )
return; /* the group is already added */ return; /* the group is already added */
// Look for a group banner in this group folder // Look for a group banner in this group folder
@@ -100,7 +100,7 @@ void SongManager::AddGroup( CString sDir, CString sGroupDirName )
GetDirListing( ssprintf("%s\\%s\\*.bmp", sDir.GetString(), sGroupDirName.GetString()), arrayGroupBanners ); GetDirListing( ssprintf("%s\\%s\\*.bmp", sDir.GetString(), sGroupDirName.GetString()), arrayGroupBanners );
CString sBannerPath; CString sBannerPath;
if( arrayGroupBanners.GetSize() > 0 ) if( !arrayGroupBanners.empty() )
{ {
sBannerPath = ssprintf("%s\\%s\\%s", sDir.GetString(), sGroupDirName.GetString(), arrayGroupBanners[0].GetString() ); sBannerPath = ssprintf("%s\\%s\\%s", sDir.GetString(), sGroupDirName.GetString(), arrayGroupBanners[0].GetString() );
LOG->Trace( "Group banner for '%s' is '%s'.", sGroupDirName.GetString(), sBannerPath.GetString() ); LOG->Trace( "Group banner for '%s' is '%s'.", sGroupDirName.GetString(), sBannerPath.GetString() );
@@ -120,7 +120,7 @@ void SongManager::LoadStepManiaSongDir( CString sDir, void(*callback)() )
GetDirListing( sDir+"\\*.*", arrayGroupDirs, true ); GetDirListing( sDir+"\\*.*", arrayGroupDirs, true );
SortCStringArray( arrayGroupDirs ); SortCStringArray( arrayGroupDirs );
for( int i=0; i< arrayGroupDirs.GetSize(); i++ ) // for each dir in /Songs/ for( unsigned i=0; i< arrayGroupDirs.size(); i++ ) // for each dir in /Songs/
{ {
CString sGroupDirName = arrayGroupDirs[i]; CString sGroupDirName = arrayGroupDirs[i];
@@ -134,10 +134,10 @@ void SongManager::LoadStepManiaSongDir( CString sDir, void(*callback)() )
GetDirListing( ssprintf("%s\\%s\\*.*", sDir.GetString(), sGroupDirName.GetString()), arraySongDirs, true ); GetDirListing( ssprintf("%s\\%s\\*.*", sDir.GetString(), sGroupDirName.GetString()), arraySongDirs, true );
SortCStringArray( arraySongDirs ); SortCStringArray( arraySongDirs );
int j; unsigned j;
int loaded = 0; int loaded = 0;
for( j=0; j< arraySongDirs.GetSize(); j++ ) // for each song dir for( j=0; j< arraySongDirs.size(); j++ ) // for each song dir
{ {
CString sSongDirName = arraySongDirs[j]; CString sSongDirName = arraySongDirs[j];
@@ -192,7 +192,7 @@ void SongManager::LoadDWISongDir( CString DWIHome )
GetDirListing( ssprintf("%s\\Songs\\*.*", DWIHome ), MixDirs.GetString(), true ); GetDirListing( ssprintf("%s\\Songs\\*.*", DWIHome ), MixDirs.GetString(), true );
SortCStringArray( MixDirs ); SortCStringArray( MixDirs );
for( int i=0; i< MixDirs.GetSize(); i++ ) // for each dir in /Songs/ for( unsigned i=0; i< MixDirs.size(); i++ ) // for each dir in /Songs/
{ {
// the dir name will most likely be something like // the dir name will most likely be something like
// Dance Dance Revolution 4th Mix, etc. // Dance Dance Revolution 4th Mix, etc.
@@ -203,14 +203,14 @@ void SongManager::LoadDWISongDir( CString DWIHome )
GetDirListing( ssprintf("%s\\Songs\\%s\\*.*", DWIHome.GetString(), MixDirs[i].GetString()), arrayDirs, true); GetDirListing( ssprintf("%s\\Songs\\%s\\*.*", DWIHome.GetString(), MixDirs[i].GetString()), arrayDirs, true);
SortCStringArray(arrayDirs, true); SortCStringArray(arrayDirs, true);
for( int b = 0; b < arrayDirs.GetSize(); b++) for( unsigned b = 0; b < arrayDirs.size(); b++)
{ {
// Find all DWIs in this directory // Find all DWIs in this directory
CStringArray arrayDWIFiles; CStringArray arrayDWIFiles;
GetDirListing( ssprintf("%s\\Songs\\%s\\%s\\*.dwi", DWIHome.GetString(), MixDirs[i].GetString(), arrayDirs[b].GetString()), arrayDWIFiles, false); GetDirListing( ssprintf("%s\\Songs\\%s\\%s\\*.dwi", DWIHome.GetString(), MixDirs[i].GetString(), arrayDirs[b].GetString()), arrayDWIFiles, false);
SortCStringArray( arrayDWIFiles ); SortCStringArray( arrayDWIFiles );
for( int j=0; j< arrayDWIFiles.GetSize(); j++ ) // for each DWI file for( unsigned j=0; j< arrayDWIFiles.size(); j++ ) // for each DWI file
{ {
CString sDWIFileName = arrayDWIFiles[j]; CString sDWIFileName = arrayDWIFiles[j];
sDWIFileName.MakeLower(); sDWIFileName.MakeLower();
@@ -231,7 +231,7 @@ void SongManager::LoadDWISongDir( CString DWIHome )
void SongManager::FreeSongArray() void SongManager::FreeSongArray()
{ {
for( int i=0; i<m_pSongs.GetSize(); i++ ) for( unsigned i=0; i<m_pSongs.size(); i++ )
SAFE_DELETE( m_pSongs[i] ); SAFE_DELETE( m_pSongs[i] );
m_pSongs.clear(); m_pSongs.clear();
@@ -272,7 +272,7 @@ void SongManager::ReadStatisticsFromDisk()
char szNotesType[256]; char szNotesType[256];
char szNotesDescription[256]; char szNotesDescription[256];
int iRetVal; int iRetVal;
int i; unsigned i;
// Parse for Song name and Notes name // Parse for Song name and Notes name
iRetVal = sscanf( name, "%[^:]::%[^:]::%[^\n]", szSongDir, szNotesType, szNotesDescription ); iRetVal = sscanf( name, "%[^:]::%[^:]::%[^\n]", szSongDir, szNotesType, szNotesDescription );
@@ -283,7 +283,7 @@ void SongManager::ReadStatisticsFromDisk()
// Search for the corresponding Song pointer. // Search for the corresponding Song pointer.
Song* pSong = NULL; Song* pSong = NULL;
for( i=0; i<m_pSongs.GetSize(); i++ ) for( i=0; i<m_pSongs.size(); i++ )
{ {
if( m_pSongs[i]->m_sSongDir == szSongDir ) // match! if( m_pSongs[i]->m_sSongDir == szSongDir ) // match!
{ {
@@ -297,7 +297,7 @@ void SongManager::ReadStatisticsFromDisk()
// Search for the corresponding Notes pointer. // Search for the corresponding Notes pointer.
Notes* pNotes = NULL; Notes* pNotes = NULL;
for( i=0; i<pSong->m_apNotes.GetSize(); i++ ) for( i=0; i<pSong->m_apNotes.size(); i++ )
{ {
if( pSong->m_apNotes[i]->m_NotesType == notesType && if( pSong->m_apNotes[i]->m_NotesType == notesType &&
pSong->m_apNotes[i]->m_sDescription == szNotesDescription ) // match! pSong->m_apNotes[i]->m_sDescription == szNotesDescription ) // match!
@@ -335,11 +335,11 @@ void SongManager::SaveStatisticsToDisk()
ini.SetPath( g_sStatisticsFileName ); ini.SetPath( g_sStatisticsFileName );
// save song statistics // save song statistics
for( int i=0; i<m_pSongs.GetSize(); i++ ) // for each Song for( unsigned i=0; i<m_pSongs.size(); i++ ) // for each Song
{ {
Song* pSong = m_pSongs[i]; Song* pSong = m_pSongs[i];
for( int j=0; j<pSong->m_apNotes.GetSize(); j++ ) // for each Notes for( unsigned j=0; j<pSong->m_apNotes.size(); j++ ) // for each Notes
{ {
Notes* pNotes = pSong->m_apNotes[j]; Notes* pNotes = pSong->m_apNotes[j];
@@ -367,11 +367,11 @@ void SongManager::SaveStatisticsToDisk()
CString SongManager::GetGroupBannerPath( CString sGroupName ) CString SongManager::GetGroupBannerPath( CString sGroupName )
{ {
int i; unsigned i;
for(i = 0; i < m_arrayGroupNames.GetSize(); ++i) for(i = 0; i < m_arrayGroupNames.size(); ++i)
if( sGroupName == m_arrayGroupNames[i] ) break; if( sGroupName == m_arrayGroupNames[i] ) break;
if( i == m_arrayGroupNames.GetSize() ) if( i == m_arrayGroupNames.size() )
return ""; return "";
return m_GroupBannerPaths[i]; return m_GroupBannerPaths[i];
@@ -385,12 +385,13 @@ void SongManager::GetGroupNames( CStringArray &AddTo )
RageColor SongManager::GetGroupColor( const CString &sGroupName ) RageColor SongManager::GetGroupColor( const CString &sGroupName )
{ {
// search for the group index // search for the group index
for( int i=0; i<m_arrayGroupNames.GetSize(); i++ ) unsigned i;
for( i=0; i<m_arrayGroupNames.size(); i++ )
{ {
if( m_arrayGroupNames[i] == sGroupName ) if( m_arrayGroupNames[i] == sGroupName )
break; break;
} }
ASSERT( i != m_arrayGroupNames.GetSize() ); // this is not a valid group ASSERT( i != m_arrayGroupNames.size() ); // this is not a valid group
return g_GroupColors[i%NUM_GROUP_COLORS]; return g_GroupColors[i%NUM_GROUP_COLORS];
} }
@@ -398,7 +399,7 @@ RageColor SongManager::GetGroupColor( const CString &sGroupName )
RageColor SongManager::GetSongColor( Song* pSong ) RageColor SongManager::GetSongColor( Song* pSong )
{ {
ASSERT( pSong ); ASSERT( pSong );
for( int i=0; i<pSong->m_apNotes.GetSize(); i++ ) for( unsigned i=0; i<pSong->m_apNotes.size(); i++ )
{ {
Notes* pNotes = pSong->m_apNotes[i]; Notes* pNotes = pSong->m_apNotes[i];
if( pNotes->m_iMeter == 10 ) if( pNotes->m_iMeter == 10 )
@@ -411,7 +412,7 @@ RageColor SongManager::GetSongColor( Song* pSong )
void SongManager::GetSongsInGroup( const CString sGroupName, CArray<Song*, Song*> &AddTo ) void SongManager::GetSongsInGroup( const CString sGroupName, CArray<Song*, Song*> &AddTo )
{ {
for( int i=0; i<m_pSongs.GetSize(); i++ ) for( unsigned i=0; i<m_pSongs.size(); i++ )
{ {
Song* pSong = m_pSongs[i]; Song* pSong = m_pSongs[i];
if( sGroupName == m_pSongs[i]->m_sGroupName ) if( sGroupName == m_pSongs[i]->m_sGroupName )
@@ -447,7 +448,7 @@ void SongManager::InitCoursesFromDisk()
// //
CStringArray saCourseFiles; CStringArray saCourseFiles;
GetDirListing( "Courses\\*.crs", saCourseFiles ); GetDirListing( "Courses\\*.crs", saCourseFiles );
for( int i=0; i<saCourseFiles.GetSize(); i++ ) for( unsigned i=0; i<saCourseFiles.size(); i++ )
{ {
Course course; Course course;
course.LoadFromCRSFile( "Courses\\" + saCourseFiles[i], m_pSongs ); course.LoadFromCRSFile( "Courses\\" + saCourseFiles[i], m_pSongs );
@@ -460,7 +461,8 @@ void SongManager::InitCoursesFromDisk()
// //
CStringArray saGroupNames; CStringArray saGroupNames;
this->GetGroupNames( saGroupNames ); this->GetGroupNames( saGroupNames );
for( int g=0; g<saGroupNames.GetSize(); g++ ) // foreach Group unsigned g;
for( g=0; g<saGroupNames.size(); g++ ) // foreach Group
{ {
CString sGroupName = saGroupNames[g]; CString sGroupName = saGroupNames[g];
CArray<Song*, Song*> apGroupSongs; CArray<Song*, Song*> apGroupSongs;
@@ -480,12 +482,12 @@ void SongManager::InitCoursesFromDisk()
// //
// Load extra stages // Load extra stages
// //
for( g=0; g<saGroupNames.GetSize(); g++ ) // foreach Group for( g=0; g<saGroupNames.size(); g++ ) // foreach Group
{ {
CString sGroupName = saGroupNames[g]; CString sGroupName = saGroupNames[g];
CStringArray saCoursePaths; CStringArray saCoursePaths;
GetDirListing( "Songs\\" + sGroupName + "\\*.crs", saCoursePaths, false, true ); GetDirListing( "Songs\\" + sGroupName + "\\*.crs", saCoursePaths, false, true );
for( int i=0; i<saCoursePaths.GetSize(); i++ ) for( unsigned i=0; i<saCoursePaths.size(); i++ )
{ {
Course course; Course course;
course.LoadFromCRSFile( saCoursePaths[i], m_pSongs ); course.LoadFromCRSFile( saCoursePaths[i], m_pSongs );
@@ -538,13 +540,13 @@ void SongManager::GetExtraStageInfo( bool bExtra2, CString sPreferredGroup, cons
CArray<Song*,Song*> apSongs; CArray<Song*,Song*> apSongs;
SONGMAN->GetSongsInGroup( GAMESTATE->m_sPreferredGroup, apSongs ); SONGMAN->GetSongsInGroup( GAMESTATE->m_sPreferredGroup, apSongs );
for( int s=0; s<apSongs.GetSize(); s++ ) // foreach song for( unsigned s=0; s<apSongs.size(); s++ ) // foreach song
{ {
Song* pSong = apSongs[s]; Song* pSong = apSongs[s];
CArray<Notes*,Notes*> apNotes; CArray<Notes*,Notes*> apNotes;
pSong->GetNotesThatMatch( sd->m_NotesType, apNotes ); pSong->GetNotesThatMatch( sd->m_NotesType, apNotes );
for( int n=0; n<apNotes.GetSize(); n++ ) // foreach Notes for( unsigned n=0; n<apNotes.size(); n++ ) // foreach Notes
{ {
Notes* pNotes = apNotes[n]; Notes* pNotes = apNotes[n];
@@ -603,15 +605,15 @@ void SongManager::GetExtraStageInfo( bool bExtra2, CString sPreferredGroup, cons
/* Pick a random song (for the demonstration). */ /* Pick a random song (for the demonstration). */
bool SongManager::ChooseRandomSong() bool SongManager::ChooseRandomSong()
{ {
if( SONGMAN->m_pSongs.GetSize() == 0 ) if( SONGMAN->m_pSongs.empty() )
return false; return false;
int i; int i;
for( i=0; i<600; i++ ) // try 600 times for( i=0; i<600; i++ ) // try 600 times
{ {
Song* pSong = m_pSongs[ rand()%m_pSongs.GetSize() ]; Song* pSong = m_pSongs[ rand()%m_pSongs.size() ];
if( pSong->m_apNotes.GetSize() == 0 ) if( pSong->m_apNotes.empty() )
continue; // skip continue; // skip
if( !pSong->HasMusic() ) if( !pSong->HasMusic() )
@@ -619,7 +621,7 @@ bool SongManager::ChooseRandomSong()
for( int j=0; j<3; j++ ) // try 3 times for( int j=0; j<3; j++ ) // try 3 times
{ {
Notes* pNotes = pSong->m_apNotes[ rand()%pSong->m_apNotes.GetSize() ]; Notes* pNotes = pSong->m_apNotes[ rand()%pSong->m_apNotes.size() ];
if( pNotes->m_NotesType != GAMESTATE->GetCurrentStyleDef()->m_NotesType ) if( pNotes->m_NotesType != GAMESTATE->GetCurrentStyleDef()->m_NotesType )
continue; continue;