From 7e9905995d5f55b8b5909856ee2ab29bbba551de Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Thu, 31 Oct 2002 03:16:02 +0000 Subject: [PATCH] some more s/GetSize/size/ and other minor STLisms --- stepmania/src/CodeDetector.cpp | 4 ++-- stepmania/src/GameInput.cpp | 2 +- stepmania/src/GameManager.cpp | 8 ++++---- stepmania/src/GameState.cpp | 2 +- stepmania/src/InputMapper.cpp | 2 +- stepmania/src/InputQueue.cpp | 8 ++++---- stepmania/src/InputQueue.h | 2 +- stepmania/src/MenuElements.cpp | 4 ++-- stepmania/src/NoteField.cpp | 8 ++++---- stepmania/src/NotesLoaderDWI.cpp | 10 +++++----- stepmania/src/OptionIconRow.cpp | 5 +++-- stepmania/src/OptionIconRow.h | 2 +- stepmania/src/PlayerOptions.cpp | 2 +- stepmania/src/RageDisplay.cpp | 6 +++--- stepmania/src/RageInput.cpp | 2 +- stepmania/src/RageMovieTexture.cpp | 2 +- stepmania/src/RageSound.cpp | 4 ++-- stepmania/src/RageTexture.cpp | 4 ++-- stepmania/src/RandomSample.cpp | 8 ++++---- stepmania/src/ScreenMusicScroll.cpp | 13 +++++------- stepmania/src/ScreenMusicScroll.h | 8 ++++---- stepmania/src/ScreenSelectDifficulty.cpp | 4 ++-- stepmania/src/ScreenSelectDifficulty.h | 8 ++++---- stepmania/src/ScreenSelectGame.cpp | 6 +++--- stepmania/src/ScreenSelectMusic.cpp | 25 +++++++++++------------- stepmania/src/ScreenTitleMenu.cpp | 4 ++-- stepmania/src/SongOptions.cpp | 2 +- 27 files changed, 75 insertions(+), 80 deletions(-) diff --git a/stepmania/src/CodeDetector.cpp b/stepmania/src/CodeDetector.cpp index a04fc62f4d..a4bcc60229 100644 --- a/stepmania/src/CodeDetector.cpp +++ b/stepmania/src/CodeDetector.cpp @@ -94,14 +94,14 @@ void RefreshCacheItem( int iIndex ) CStringArray asButtonNames; split( sButtonsNames, ",", asButtonNames, false ); - if( asButtonNames.GetSize() < 2 ) + if( asButtonNames.size() < 2 ) { LOG->Trace( "The code '%s' is less than 2 buttons, so it will be ignored.", sCodeName.GetString() ); item.iNumButtons = 0; return; } - for( int i=0; i 0 ) + if( !arrayPossibleFileNames.empty() ) return arrayPossibleFileNames[0]; throw RageException( "The NoteSkin element '%s %s' is missing from '%s'.", sButtonName.GetString(), sElementName.GetString(), sDir.GetString() ); @@ -1331,7 +1331,7 @@ void GameManager::GetEnabledGames( CArray& aGamesOut ) Game game = (Game)g; CStringArray asNoteSkins; GetNoteSkinNames( game, asNoteSkins ); - if( asNoteSkins.GetSize() > 0 ) + if( !asNoteSkins.empty() ) aGamesOut.Add( game ); } } @@ -1344,7 +1344,7 @@ void GameManager::GetNoteSkinNames( Game game, CStringArray &AddTo ) const GetDirListing( sBaseSkinFolder + "*.*", AddTo, true ); // strip out "CVS" - for( int i=AddTo.GetSize()-1; i>=0; i-- ) + for( int i=AddTo.size()-1; i>=0; i-- ) if( 0 == stricmp("cvs", AddTo[i]) ) AddTo.RemoveAt( i ); } diff --git a/stepmania/src/GameState.cpp b/stepmania/src/GameState.cpp index afe948ed64..6509de51be 100644 --- a/stepmania/src/GameState.cpp +++ b/stepmania/src/GameState.cpp @@ -301,7 +301,7 @@ float GameState::GetElapsedSeconds() case PLAY_MODE_ENDLESS: { float fSecondsTotal = 0; - for( int i=0; im_fMusicLengthSeconds; fSecondsTotal += max( 0, m_fMusicSeconds ); return fSecondsTotal; diff --git a/stepmania/src/InputMapper.cpp b/stepmania/src/InputMapper.cpp index bbbc96aee2..8761472341 100644 --- a/stepmania/src/InputMapper.cpp +++ b/stepmania/src/InputMapper.cpp @@ -90,7 +90,7 @@ void InputMapper::ReadMappingsFromDisk() CStringArray sDeviceInputStrings; split( value, ",", sDeviceInputStrings, false ); - for( int i=0; i= MAX_INPUT_QUEUE_LENGTH ) // full - m_aQueue[c].RemoveAt( 0, m_aQueue[c].GetSize()-MAX_INPUT_QUEUE_LENGTH+1 ); + if( m_aQueue[c].size() >= MAX_INPUT_QUEUE_LENGTH ) // full + m_aQueue[c].RemoveAt( 0, m_aQueue[c].size()-MAX_INPUT_QUEUE_LENGTH+1 ); m_aQueue[c].Add( GameButtonAndTime(GameI.button,TIMER->GetTimeSinceStart()) ); }; @@ -43,7 +43,7 @@ bool InputQueue::MatchesPattern( const GameController c, const MenuButton* butto float fOldestTimeAllowed = TIMER->GetTimeSinceStart() - fMaxSecondsBack; int sequence_index = iNumButtons-1; // count down - for( int queue_index=m_aQueue[c].GetSize()-1; queue_index>=0; queue_index-- ) // iterate newest to oldest + for( int queue_index=m_aQueue[c].size()-1; queue_index>=0; queue_index-- ) // iterate newest to oldest { GameButtonAndTime BandT = m_aQueue[c][queue_index]; GameInput GameI( c, BandT.button ); @@ -72,7 +72,7 @@ bool InputQueue::MatchesPattern( const GameController c, const GameButton* butto float fOldestTimeAllowed = TIMER->GetTimeSinceStart() - fMaxSecondsBack; int sequence_index = iNumButtons-1; // count down - for( int queue_index=m_aQueue[c].GetSize()-1; queue_index>=0; queue_index-- ) // iterate newest to oldest + for( int queue_index=m_aQueue[c].size()-1; queue_index>=0; queue_index-- ) // iterate newest to oldest { GameButtonAndTime BandT = m_aQueue[c][queue_index]; if( BandT.button != button_sequence[sequence_index] || diff --git a/stepmania/src/InputQueue.h b/stepmania/src/InputQueue.h index f57df126b6..71269858ee 100644 --- a/stepmania/src/InputQueue.h +++ b/stepmania/src/InputQueue.h @@ -14,7 +14,7 @@ #include "GameInput.h" #include "MenuInput.h" -const int MAX_INPUT_QUEUE_LENGTH = 8; +const unsigned MAX_INPUT_QUEUE_LENGTH = 8; class InputQueue { diff --git a/stepmania/src/MenuElements.cpp b/stepmania/src/MenuElements.cpp index 1486082754..4efbd6e618 100644 --- a/stepmania/src/MenuElements.cpp +++ b/stepmania/src/MenuElements.cpp @@ -124,7 +124,7 @@ void MenuElements::TweenTopLayerOnScreen() apActorsInTopFrame.Add( &m_sprTopEdge ); apActorsInTopFrame.Add( &m_sprStyleIcon ); apActorsInTopFrame.Add( &m_MenuTimer ); - for( int i=0; iGetX(); apActorsInTopFrame[i]->SetX( fOriginalX+SCREEN_WIDTH ); @@ -162,7 +162,7 @@ void MenuElements::TweenTopLayerOffScreen() apActorsInTopFrame.Add( &m_sprTopEdge ); apActorsInTopFrame.Add( &m_sprStyleIcon ); apActorsInTopFrame.Add( &m_MenuTimer ); - for( int i=0; iGetX(); apActorsInTopFrame[i]->BeginTweening( MENU_ELEMENTS_TWEEN_TIME, TWEEN_BOUNCE_BEGIN ); diff --git a/stepmania/src/NoteField.cpp b/stepmania/src/NoteField.cpp index 4d1349fd04..484c59ceab 100644 --- a/stepmania/src/NoteField.cpp +++ b/stepmania/src/NoteField.cpp @@ -166,7 +166,7 @@ void NoteField::DrawPrimitives() if( GAMESTATE->m_bEditing ) { - int i; + unsigned i; // // Draw measure bars @@ -180,21 +180,21 @@ void NoteField::DrawPrimitives() // BPM text // CArray &aBPMSegments = GAMESTATE->m_pCurSong->m_BPMSegments; - for( i=0; i &aStopSegments = GAMESTATE->m_pCurSong->m_StopSegments; - for( i=0; i &aBackgroundChanges = GAMESTATE->m_pCurSong->m_BackgroundChanges; - for( i=0; i 1 ) + if( aFileNames.size() > 1 ) throw RageException( "There is more than one DWI file in '%s'. There should be only one!", sPath.GetString() ); /* We should have exactly one; if we had none, we shouldn't have been * called to begin with. */ - ASSERT( aFileNames.GetSize() == 1 ); + ASSERT( aFileNames.size() == 1 ); return LoadFromDWIFile( sPath + aFileNames[0], out ); } diff --git a/stepmania/src/OptionIconRow.cpp b/stepmania/src/OptionIconRow.cpp index dd0968f840..409e654935 100644 --- a/stepmania/src/OptionIconRow.cpp +++ b/stepmania/src/OptionIconRow.cpp @@ -86,7 +86,8 @@ int OptionToPreferredColumn( CString sOptionText ) void OptionIconRow::Refresh( PlayerNumber pn ) { // init - for( int i=0; im_PlayerOptions[pn].GetString(); @@ -97,7 +98,7 @@ void OptionIconRow::Refresh( PlayerNumber pn ) CString asTabs[NUM_OPTION_COLS-1]; // fill these with what will be displayed on the tabs // for each option, look for the best column to place it in - for( i=0; iTrace( "WARNING: Tried to play a RandomSample that has 0 sounds loaded." ); return; @@ -74,7 +74,7 @@ void RandomSample::PlayRandom() int iIndexToPlay = 0; for( int i=0; i<5; i++ ) { - iIndexToPlay = rand() % m_pSamples.GetSize(); + iIndexToPlay = rand() % m_pSamples.size(); if( iIndexToPlay != m_iIndexLastPlayed ) break; } diff --git a/stepmania/src/ScreenMusicScroll.cpp b/stepmania/src/ScreenMusicScroll.cpp index 08ef3ddf10..96ff1fa7fd 100644 --- a/stepmania/src/ScreenMusicScroll.cpp +++ b/stepmania/src/ScreenMusicScroll.cpp @@ -129,14 +129,14 @@ const CString CREDIT_LINES[] = "", "Please, join the StepMania team and help us out!", }; -const int NUM_CREDIT_LINES = sizeof(CREDIT_LINES) / sizeof(CString); +const unsigned NUM_CREDIT_LINES = sizeof(CREDIT_LINES) / sizeof(CString); ScreenMusicScroll::ScreenMusicScroll() { LOG->Trace( "ScreenMusicScroll::ScreenMusicScroll()" ); - int i; + unsigned i; GAMESTATE->Reset(); // so that credits message for both players will show @@ -149,7 +149,7 @@ ScreenMusicScroll::ScreenMusicScroll() m_iNumLines = 0; - for( i=0; iGetPathTo("Fonts","music scroll") ); @@ -193,11 +193,8 @@ void ScreenMusicScroll::Update( float fDeltaTime ) { Screen::Update( fDeltaTime ); - for( int i=0; i SCREEN_TOP-20 && m_textLines[i].GetY() < SCREEN_BOTTOM+20 ) diff --git a/stepmania/src/ScreenMusicScroll.h b/stepmania/src/ScreenMusicScroll.h index d304b16436..736b8aa257 100644 --- a/stepmania/src/ScreenMusicScroll.h +++ b/stepmania/src/ScreenMusicScroll.h @@ -17,9 +17,9 @@ #include "MenuElements.h" -const int MAX_MUSIC_LINES = 1200; -const int MAX_CREDIT_LINES = 100; -const int MAX_TOTAL_LINES = MAX_MUSIC_LINES + MAX_CREDIT_LINES; +const unsigned MAX_MUSIC_LINES = 1200; +const unsigned MAX_CREDIT_LINES = 100; +const unsigned MAX_TOTAL_LINES = MAX_MUSIC_LINES + MAX_CREDIT_LINES; class ScreenMusicScroll : public Screen @@ -40,7 +40,7 @@ private: BGAnimation m_Background; BitmapText m_textLines[MAX_TOTAL_LINES]; - int m_iNumLines; + unsigned m_iNumLines; float m_fTimeLeftInScreen; TransitionFade m_Fade; diff --git a/stepmania/src/ScreenSelectDifficulty.cpp b/stepmania/src/ScreenSelectDifficulty.cpp index 469467e924..039de22256 100644 --- a/stepmania/src/ScreenSelectDifficulty.cpp +++ b/stepmania/src/ScreenSelectDifficulty.cpp @@ -455,9 +455,9 @@ void ScreenSelectDifficulty::MenuBack( PlayerNumber pn ) void ScreenSelectDifficulty::TweenOffScreen() { - int p; + unsigned p; - for( p=0; p < m_SubActors.GetSize(); p++ ) + for( p=0; p < m_SubActors.size(); p++ ) m_SubActors[p]->StopTweening(); for( p=0; p aGames; GAMEMAN->GetEnabledGames( aGames ); - for( int i=0; iGetGameDefForGame(game)->m_szName; @@ -70,10 +70,10 @@ void ScreenSelectGame::ImportOptions() * note skins; reset it to the first available. */ CArray aGames; GAMEMAN->GetEnabledGames( aGames ); - ASSERT(aGames.GetSize()); + ASSERT(!aGames.empty()); m_iSelectedOption[0][SG_GAME] = 0; - for(int sel = 0; sel < aGames.GetSize(); ++sel) + for(unsigned sel = 0; sel < aGames.size(); ++sel) if(aGames[sel] == GAMESTATE->m_CurGame) m_iSelectedOption[0][SG_GAME] = sel; } diff --git a/stepmania/src/ScreenSelectMusic.cpp b/stepmania/src/ScreenSelectMusic.cpp index aa5eb56546..851b6915a4 100644 --- a/stepmania/src/ScreenSelectMusic.cpp +++ b/stepmania/src/ScreenSelectMusic.cpp @@ -302,15 +302,14 @@ void ScreenSelectMusic::TweenOnScreen() void ScreenSelectMusic::TweenOffScreen() { - int i; - m_sprBannerFrame.FadeOff( 0, "bounce left", TWEEN_TIME*2 ); m_Banner.FadeOff( 0, "bounce left", TWEEN_TIME*2 ); m_BPMDisplay.FadeOff( 0, "bounce left", TWEEN_TIME*2 ); m_textStage.FadeOff( 0, "bounce left", TWEEN_TIME*2 ); m_sprCDTitle.FadeOff( 0, "bounce left", TWEEN_TIME*2 ); - for( int p=0; pBeginTweening( TWEEN_TIME, TWEEN_BIAS_END ); apActorsInScore[i]->SetTweenX( SCORE_CONNECTED_TO_MUSIC_WHEEL ? apActorsInScore[i]->GetX()+400 : apActorsInScore[i]->GetX()-400 ); @@ -359,7 +358,7 @@ void ScreenSelectMusic::TweenScoreOnAndOffAfterChangeSort() apActorsInScore.Add( &m_sprHighScoreFrame[p] ); apActorsInScore.Add( &m_HighScore[p] ); } - for( int i=0; iStopTweening(); @@ -465,7 +464,7 @@ void ScreenSelectMusic::EasierDifficulty( PlayerNumber pn ) if( !GAMESTATE->IsPlayerEnabled(pn) ) return; - if( m_arrayNotes[pn].GetSize() == 0 ) + if( m_arrayNotes[pn].empty() ) return; if( m_iSelection[pn] == 0 ) return; @@ -485,9 +484,9 @@ void ScreenSelectMusic::HarderDifficulty( PlayerNumber pn ) if( !GAMESTATE->IsPlayerEnabled(pn) ) return; - if( m_arrayNotes[pn].GetSize() == 0 ) + if( m_arrayNotes[pn].empty() ) return; - if( m_iSelection[pn] == m_arrayNotes[pn].GetSize()-1 ) + if( m_iSelection[pn] == int(m_arrayNotes[pn].size()-1) ) return; m_iSelection[pn]++; @@ -673,9 +672,9 @@ void ScreenSelectMusic::AfterNotesChange( PlayerNumber pn ) if( !GAMESTATE->IsPlayerEnabled(pn) ) return; - m_iSelection[pn] = clamp( m_iSelection[pn], 0, m_arrayNotes[pn].GetSize()-1 ); // bounds clamping + m_iSelection[pn] = clamp( m_iSelection[pn], 0, int(m_arrayNotes[pn].size()-1) ); // bounds clamping - Notes* pNotes = m_arrayNotes[pn].GetSize()>0 ? m_arrayNotes[pn][m_iSelection[pn]] : NULL; + Notes* pNotes = m_arrayNotes[pn].empty()? NULL: m_arrayNotes[pn][m_iSelection[pn]]; GAMESTATE->m_pCurNotes[pn] = pNotes; @@ -711,9 +710,7 @@ void ScreenSelectMusic::AfterMusicChange() { CString sGroup = m_MusicWheel.GetSelectedSection(); for( int p=0; pIsPlayerEnabled( PlayerNumber(p) ) ) continue; - for( int i=0; im_Difficulty == GAMESTATE->m_PreferredDifficulty[p] ) { @@ -753,7 +750,7 @@ void ScreenSelectMusic::AfterMusicChange() } } - m_iSelection[p] = clamp( m_iSelection[p], 0, m_arrayNotes[p].GetSize() ) ; + m_iSelection[p] = clamp( m_iSelection[p], 0, int(m_arrayNotes[p].size()) ) ; } } break; diff --git a/stepmania/src/ScreenTitleMenu.cpp b/stepmania/src/ScreenTitleMenu.cpp index 1329ab1b8a..2ebd071c83 100644 --- a/stepmania/src/ScreenTitleMenu.cpp +++ b/stepmania/src/ScreenTitleMenu.cpp @@ -127,7 +127,7 @@ ScreenTitleMenu::ScreenTitleMenu() m_textSongs.LoadFromFont( THEME->GetPathTo("Fonts","normal") ); m_textSongs.SetHorizAlign( Actor::align_left ); - m_textSongs.SetText( ssprintf("Found %d Songs", SONGMAN->m_pSongs.GetSize()) ); + m_textSongs.SetText( ssprintf("Found %u Songs", SONGMAN->m_pSongs.size()) ); m_textSongs.SetDiffuse( RageColor(0.6f,0.6f,0.6f,1) ); // light gray m_textSongs.SetXY( SONGS_X, SONGS_Y ); m_textSongs.SetZoom( 0.5f ); @@ -365,7 +365,7 @@ void ScreenTitleMenu::MenuStart( PlayerNumber pn ) m_Fade.CloseWipingRight( SM_GoToNextScreen ); break; case CHOICE_EDIT: - if( SONGMAN->m_pSongs.GetSize() == 0 ) + if( SONGMAN->m_pSongs.empty() ) { m_soundInvalid.PlayRandom(); } diff --git a/stepmania/src/SongOptions.cpp b/stepmania/src/SongOptions.cpp index 4baf444a10..79cd7ac95c 100644 --- a/stepmania/src/SongOptions.cpp +++ b/stepmania/src/SongOptions.cpp @@ -67,7 +67,7 @@ void SongOptions::FromString( CString sOptions ) CStringArray asBits; split( sOptions, ",", asBits, true ); - for( int i=0; i