diff --git a/stepmania/src/GroupList.cpp b/stepmania/src/GroupList.cpp index 19af4e2009..16700c0f89 100644 --- a/stepmania/src/GroupList.cpp +++ b/stepmania/src/GroupList.cpp @@ -18,9 +18,9 @@ GroupList::GroupList() void GroupList::DoneAddingGroups() { - int i; + unsigned i; - for( i=0; iGetPathTo("Graphics","select group button") ); m_sprButton[i].SetXY( BUTTON_X, BUTTON_START_Y + i*BUTTON_SPACING_Y ); @@ -28,7 +28,7 @@ void GroupList::DoneAddingGroups() this->AddChild( &m_screenLabels[i] ); } - for( i=0; iGetPathTo("Fonts","select group button label") ); m_screenLabels[i].SetXY( BUTTON_X, BUTTON_START_Y + i*BUTTON_SPACING_Y ); @@ -44,7 +44,7 @@ void GroupList::DoneAddingGroups() void GroupList::SetLabels() { - for( int i=0; iShortenGroupName( label ) ); @@ -91,7 +91,7 @@ void GroupList::Up() BeforeChange(); if( m_iSelection == 0 ) - SetSelection(m_textLabels.GetSize()-1); + SetSelection(m_textLabels.size()-1); else SetSelection(m_iSelection-1); @@ -102,7 +102,7 @@ void GroupList::Down() { BeforeChange(); - SetSelection((m_iSelection+1) % m_textLabels.GetSize()); + SetSelection((m_iSelection+1) % m_textLabels.size()); AfterChange(); } @@ -112,7 +112,7 @@ void GroupList::AddGroup(CString name) m_textLabels.Add(name); } -void GroupList::SetSelection( int sel ) +void GroupList::SetSelection( unsigned sel ) { BeforeChange(); @@ -121,7 +121,7 @@ void GroupList::SetSelection( int sel ) if( m_iSelection >= MAX_GROUPS_ONSCREEN/2 ) m_iTop++; } else if( sel == m_iSelection-1 ) { - if(m_iSelection < m_textLabels.GetSize() - MAX_GROUPS_ONSCREEN/2) + if(m_iSelection < m_textLabels.size() - MAX_GROUPS_ONSCREEN/2) m_iTop--; } else { /* We're jumping somewhere else; just put the top somewhere @@ -130,7 +130,7 @@ void GroupList::SetSelection( int sel ) } m_iSelection=sel; - m_iTop = clamp( m_iTop, 0, m_textLabels.GetSize()-MAX_GROUPS_ONSCREEN ); + m_iTop = clamp( m_iTop, 0u, m_textLabels.size()-MAX_GROUPS_ONSCREEN ); /* The current selection must always be visible. */ ASSERT( m_iTop <= m_iSelection ); @@ -143,7 +143,7 @@ void GroupList::SetSelection( int sel ) void GroupList::TweenOnScreen() { - for( int i=0; i m_textLabels; /* Currently selected label. */ - int m_iSelection; + unsigned m_iSelection; /* Label that's currently at the top of the screen. */ - int m_iTop; + unsigned m_iTop; void BeforeChange(); void AfterChange(); @@ -24,7 +24,7 @@ class GroupList: public ActorFrame { public: GroupList(); - void SetSelection(int sel); + void SetSelection(unsigned sel); int GetSelection() const { return m_iSelection; } CString GetSelectionName() const { return m_textLabels[m_iSelection]; } void Up(); diff --git a/stepmania/src/Song.cpp b/stepmania/src/Song.cpp index c9da672763..a142b77383 100644 --- a/stepmania/src/Song.cpp +++ b/stepmania/src/Song.cpp @@ -89,7 +89,7 @@ Song::Song() Song::~Song() { - for( int i=0; i m_StopSegments[j].m_fStartBeat || m_StopSegments[j].m_fStartBeat > fStartBeatNextSegment ) @@ -300,7 +300,7 @@ bool Song::LoadFromSongDir( CString sDir ) // save group name CStringArray sDirectoryParts; split( m_sSongDir, "\\", sDirectoryParts, false ); - m_sGroupName = sDirectoryParts[sDirectoryParts.GetSize()-3]; // second from last item + m_sGroupName = sDirectoryParts[sDirectoryParts.size()-3]; // second from last item // // First look in the cache for this song (without loading NoteData) @@ -345,16 +345,16 @@ bool Song::LoadFromSongDir( CString sDir ) m_sSongFileName = m_sSongDir; CStringArray asFileNames; GetDirListing( m_sSongDir+"*.sm", asFileNames ); - if( asFileNames.GetSize() > 0 ) + if( !asFileNames.empty() ) m_sSongFileName += asFileNames[0]; else { GetDirListing( m_sSongDir+"*.dwi", asFileNames ); - if( asFileNames.GetSize() > 0 ) { + if( !asFileNames.empty() ) { m_sSongFileName += asFileNames[0]; /* XXX: This would mess up "vote.for.dwight.d.eisenhower.dwi". */ m_sSongFileName.Replace( ".dwi", ".sm" ); } else { - m_sSongFileName += sDirectoryParts[sDirectoryParts.GetSize()-2]; // last item + m_sSongFileName += sDirectoryParts[sDirectoryParts.size()-2]; // last item m_sSongFileName += ".sm"; } } @@ -370,7 +370,7 @@ void Song::TidyUpData() if( m_sMainTitle == "" ) m_sMainTitle = "Untitled song"; m_sSubTitle.TrimRight(); if( m_sArtist == "" ) m_sArtist = "Unknown artist"; - if( m_BPMSegments.GetSize() == 0 ) + if( m_BPMSegments.empty() ) throw RageException( "No #BPM specified in '%s%s.'", m_sSongDir.GetString(), m_sSongFileName.GetString() ); if( !HasMusic() ) @@ -380,7 +380,7 @@ void Song::TidyUpData() GetDirListing( m_sSongDir + CString("*.ogg"), arrayPossibleMusic ); GetDirListing( m_sSongDir + CString("*.wav"), arrayPossibleMusic ); - if( arrayPossibleMusic.GetSize() > 0 ) // we found a match + if( !arrayPossibleMusic.empty() ) // we found a match m_sMusicFile = arrayPossibleMusic[0]; // Don't throw on missing music. -Chris // else @@ -423,7 +423,7 @@ void Song::TidyUpData() GetDirListing( m_sSongDir + CString("*banner*.jpg"), arrayPossibleBanners ); GetDirListing( m_sSongDir + CString("*banner*.bmp"), arrayPossibleBanners ); GetDirListing( m_sSongDir + CString("*banner*.gif"), arrayPossibleBanners ); - if( arrayPossibleBanners.GetSize() > 0 ) + if( !arrayPossibleBanners.empty() ) m_sBannerFile = arrayPossibleBanners[0]; } @@ -441,7 +441,7 @@ void Song::TidyUpData() GetDirListing( m_sSongDir + CString("*background*.jpg"), arrayPossibleBGs ); GetDirListing( m_sSongDir + CString("*background*.bmp"), arrayPossibleBGs ); GetDirListing( m_sSongDir + CString("*background*.gif"), arrayPossibleBGs ); - if( arrayPossibleBGs.GetSize() > 0 ) + if( !arrayPossibleBGs.empty() ) m_sBackgroundFile = arrayPossibleBGs[0]; } @@ -455,7 +455,7 @@ void Song::TidyUpData() GetDirListing( m_sSongDir + CString("*cdtitle*.jpg"), arrayPossibleCDTitles ); GetDirListing( m_sSongDir + CString("*cdtitle*.bmp"), arrayPossibleCDTitles ); GetDirListing( m_sSongDir + CString("*cdtitle*.gif"), arrayPossibleCDTitles ); - if( arrayPossibleCDTitles.GetSize() > 0 ) + if( !arrayPossibleCDTitles.empty() ) m_sCDTitleFile = arrayPossibleCDTitles[0]; } @@ -468,8 +468,8 @@ void Song::TidyUpData() GetDirListing( m_sSongDir + CString("*.jpg"), arrayImages ); GetDirListing( m_sSongDir + CString("*.bmp"), arrayImages ); GetDirListing( m_sSongDir + CString("*.gif"), arrayImages ); - - for( int i=0; i apNotes; GetNotesThatMatch( nt, apNotes ); - if( apNotes.GetSize() == 1 ) + if( apNotes.size() == 1 ) if( 0 == apNotes[0]->m_sDescription.CompareNoCase("smaniac") ) { apNotes[0]->m_sDescription = "Challenge"; @@ -569,7 +569,7 @@ void Song::TidyUpData() void Song::GetNotesThatMatch( NotesType nt, CArray& arrayAddTo ) const { - for( int i=0; im_NotesType == nt ) arrayAddTo.Add( m_apNotes[i] ); @@ -586,7 +586,7 @@ bool Song::SongCompleteForStyle( const StyleDef *st ) const bool Song::SongHasNotesType( NotesType nt ) const { - for( int i=0; i < m_apNotes.GetSize(); i++ ) // foreach Notes + for( unsigned i=0; i < m_apNotes.size(); i++ ) // foreach Notes if( m_apNotes[i]->m_NotesType == nt ) return true; return false; @@ -594,7 +594,7 @@ bool Song::SongHasNotesType( NotesType nt ) const bool Song::SongHasNotesTypeAndDifficulty( NotesType nt, Difficulty dc ) const { - for( int i=0; i < m_apNotes.GetSize(); i++ ) // foreach Notes + for( unsigned i=0; i < m_apNotes.size(); i++ ) // foreach Notes if( m_apNotes[i]->m_NotesType == nt && m_apNotes[i]->m_Difficulty == dc ) return true; return false; @@ -627,7 +627,7 @@ void Song::Save() GetDirListing( m_sSongDir + "*.ksf", arrayOldFileNames ); GetDirListing( m_sSongDir + "*.sm", arrayOldFileNames ); - for( int i=0; iTrace( "Song::SaveToSMDir('%s')", sPath.GetString() ); - int i; + unsigned i; FILE* fp = fopen( sPath, "w" ); if( fp == NULL ) @@ -682,34 +682,34 @@ void Song::SaveToSMFile( CString sPath, bool bSavingCache ) fprintf( fp, ";\n" ); fprintf( fp, "#BPMS:" ); - for( i=0; im_sDescription.Find("(autogen)") == -1 ) // If notes aren't autogen @@ -752,7 +752,7 @@ void Song::AddAutoGenNotes() // if( !SongHasNotesType(NOTES_TYPE_PUMP_SINGLE) ) aMissingNotesTypes.Add( NOTES_TYPE_PUMP_SINGLE ); // if( !SongHasNotesType(NOTES_TYPE_PUMP_DOUBLE) ) aMissingNotesTypes.Add( NOTES_TYPE_PUMP_DOUBLE ); // -// for( int i=0; iNotesTypeToNumTracks(ntMissing); - int j; + unsigned j; // look for an exact match that was created by autogen - for( j=0; jNotesTypeToNumTracks(pOriginalNotes->m_NotesType) ) @@ -797,7 +797,7 @@ next_notes_type: int iTrackDifference = abs(iNumTracks-iNumTracksOfMissing); CArray apNotes; this->GetNotesThatMatch( nt, apNotes ); - if( iTrackDifference 0 && apNotes[0]->m_sDescription.Find("autogen")==-1 ) + if( iTrackDifference < iBestTrackDifference && !apNotes.empty() && apNotes[0]->m_sDescription.Find("autogen")==-1 ) { ntBestMatch = nt; iBestTrackDifference = iTrackDifference; @@ -807,7 +807,7 @@ next_notes_type: if( ntBestMatch == -1 ) continue; - for( j=0; jm_NotesType != ntBestMatch ) @@ -839,7 +839,7 @@ Grade Song::GetGradeForDifficulty( const StyleDef *st, int p, Difficulty dc ) co Grade grade = GRADE_NO_DATA; - for( int i=0; im_Difficulty == dc ) @@ -856,7 +856,7 @@ bool Song::IsNew() const bool Song::IsEasy( NotesType nt ) const { - for( int i=0; im_NotesType != nt ) @@ -902,10 +902,10 @@ int CompareSongPointersByDifficulty(const Song *pSong1, const Song *pSong2) int iEasiestMeter1 = 1000; // infinity int iEasiestMeter2 = 1000; // infinity - int i; - for( i=0; im_iMeter ); - for( i=0; im_iMeter ); if( iEasiestMeter1 < iEasiestMeter2 ) @@ -1005,16 +1005,16 @@ bool Song::RouletteDisplayed() const return m_SelectionDisplay != SHOW_NEVER; } -bool Song::HasMusic() const {return m_sMusicFile != "" && IsAFile(GetMusicPath()); }; -bool Song::HasBanner() const {return m_sBannerFile != "" && IsAFile(GetBannerPath()); }; -bool Song::HasBackground() const {return m_sBackgroundFile != "" && IsAFile(GetBackgroundPath()); }; -bool Song::HasCDTitle() const {return m_sCDTitleFile != "" && IsAFile(GetCDTitlePath()); }; -bool Song::HasBGChanges() const {return m_BackgroundChanges.GetSize() > 0; }; +bool Song::HasMusic() const {return m_sMusicFile != "" && IsAFile(GetMusicPath()); } +bool Song::HasBanner() const {return m_sBannerFile != "" && IsAFile(GetBannerPath()); } +bool Song::HasBackground() const {return m_sBackgroundFile != "" && IsAFile(GetBackgroundPath()); } +bool Song::HasCDTitle() const {return m_sCDTitleFile != "" && IsAFile(GetCDTitlePath()); } +bool Song::HasBGChanges() const {return !m_BackgroundChanges.empty(); } int Song::GetNumTimesPlayed() const { int iTotalNumTimesPlayed = 0; - for( int i=0; im_iNumTimesPlayed; }