From a0e805e5117c9ec50c790e07df717addd9ce4ab1 Mon Sep 17 00:00:00 2001 From: Brian Phlipot Date: Wed, 10 Aug 2022 11:56:11 -0600 Subject: [PATCH] Add std:: prefixes to all shuffle calls. Use unique_ptr instead of shared_ptr. --- src/Course.cpp | 4 ++-- src/CourseUtil.cpp | 2 +- src/MusicWheel.cpp | 2 +- src/ScreenOptionsCourseOverview.cpp | 2 +- src/ScreenOptionsReviewWorkout.cpp | 2 +- src/SongManager.cpp | 4 ++-- src/arch/Sound/RageSoundDriver_WDMKS.cpp | 17 ++++++++--------- 7 files changed, 16 insertions(+), 17 deletions(-) diff --git a/src/Course.cpp b/src/Course.cpp index 59d7246e0b..1d83b27a7d 100644 --- a/src/Course.cpp +++ b/src/Course.cpp @@ -368,7 +368,7 @@ static void CourseSortSongs( SongSort sort, std::vector &vpPossibleSongs, { DEFAULT_FAIL(sort); case SongSort_Randomize: - shuffle( vpPossibleSongs.begin(), vpPossibleSongs.end(), rnd ); + std::shuffle( vpPossibleSongs.begin(), vpPossibleSongs.end(), rnd ); break; case SongSort_MostPlays: if( PROFILEMAN ) @@ -428,7 +428,7 @@ bool Course::GetTrailUnsorted( StepsType st, CourseDifficulty cd, Trail &trail ) * will change every time it's viewed, and the displayed order will have no * bearing on what you'll actually play. */ tmp_entries = m_vEntries; - shuffle( tmp_entries.begin(), tmp_entries.end(), rnd ); + std::shuffle( tmp_entries.begin(), tmp_entries.end(), rnd ); } const std::vector &entries = m_bShuffle ? tmp_entries:m_vEntries; diff --git a/src/CourseUtil.cpp b/src/CourseUtil.cpp index 1cc2af8a7a..3e84bba373 100644 --- a/src/CourseUtil.cpp +++ b/src/CourseUtil.cpp @@ -304,7 +304,7 @@ void CourseUtil::AutogenOniFromArtist( const RString &sArtistName, RString sArti * song set changes. */ { RandomGen rng( GetHashForString( sArtistName ) + aSongs.size() ); - shuffle( aSongs.begin(), aSongs.end(), rng ); + std::shuffle( aSongs.begin(), aSongs.end(), rng ); } // Only use up to four songs. diff --git a/src/MusicWheel.cpp b/src/MusicWheel.cpp index 3f2cb85f95..277c2d9b85 100644 --- a/src/MusicWheel.cpp +++ b/src/MusicWheel.cpp @@ -1333,7 +1333,7 @@ void MusicWheel::StartRandom() { // Shuffle and use the roulette wheel. RandomGen rnd; - shuffle( getWheelItemsData(SORT_ROULETTE).begin(), getWheelItemsData(SORT_ROULETTE).end(), rnd ); + std::shuffle( getWheelItemsData(SORT_ROULETTE).begin(), getWheelItemsData(SORT_ROULETTE).end(), rnd ); GAMESTATE->m_SortOrder.Set( SORT_ROULETTE ); } else diff --git a/src/ScreenOptionsCourseOverview.cpp b/src/ScreenOptionsCourseOverview.cpp index c3353bfb13..0b10954f70 100644 --- a/src/ScreenOptionsCourseOverview.cpp +++ b/src/ScreenOptionsCourseOverview.cpp @@ -202,7 +202,7 @@ void ScreenOptionsCourseOverview::ProcessMenuStart( const InputEventPlus &input case CourseOverviewRow_Shuffle: { Course *pCourse = GAMESTATE->m_pCurCourse; - shuffle( pCourse->m_vEntries.begin(), pCourse->m_vEntries.end(), g_RandomNumberGenerator ); + std::shuffle( pCourse->m_vEntries.begin(), pCourse->m_vEntries.end(), g_RandomNumberGenerator ); Trail *pTrail = pCourse->GetTrailForceRegenCache( GAMESTATE->GetCurrentStyle(input.pn)->m_StepsType ); GAMESTATE->m_pCurTrail[PLAYER_1].Set( pTrail ); SCREENMAN->PlayStartSound(); diff --git a/src/ScreenOptionsReviewWorkout.cpp b/src/ScreenOptionsReviewWorkout.cpp index 90806b16b9..1181c247d6 100644 --- a/src/ScreenOptionsReviewWorkout.cpp +++ b/src/ScreenOptionsReviewWorkout.cpp @@ -146,7 +146,7 @@ void ScreenOptionsCourseOverview::ProcessMenuStart( const InputEventPlus &input case ReviewWorkoutRow_Shuffle: { Course *pCourse = GAMESTATE->m_pCurCourse; - shuffle( pCourse->m_vEntries.begin(), pCourse->m_vEntries.end(), g_RandomNumberGenerator ); + std::shuffle( pCourse->m_vEntries.begin(), pCourse->m_vEntries.end(), g_RandomNumberGenerator ); Trail *pTrail = pCourse->GetTrailForceRegenCache( GAMESTATE->m_pCurStyle->m_StepsType ); GAMESTATE->m_pCurTrail[PLAYER_1].Set( pTrail ); SCREENMAN->PlayStartSound(); diff --git a/src/SongManager.cpp b/src/SongManager.cpp index 5ee4a31a4a..411573f927 100644 --- a/src/SongManager.cpp +++ b/src/SongManager.cpp @@ -1585,10 +1585,10 @@ void SongManager::UpdateShuffled() { // update shuffled m_pShuffledSongs = m_pSongs; - shuffle( m_pShuffledSongs.begin(), m_pShuffledSongs.end(), g_RandomNumberGenerator ); + std::shuffle( m_pShuffledSongs.begin(), m_pShuffledSongs.end(), g_RandomNumberGenerator ); m_pShuffledCourses = m_pCourses; - shuffle( m_pShuffledCourses.begin(), m_pShuffledCourses.end(), g_RandomNumberGenerator ); + std::shuffle( m_pShuffledCourses.begin(), m_pShuffledCourses.end(), g_RandomNumberGenerator ); } void SongManager::UpdatePreferredSort(RString sPreferredSongs, RString sPreferredCourses) diff --git a/src/arch/Sound/RageSoundDriver_WDMKS.cpp b/src/arch/Sound/RageSoundDriver_WDMKS.cpp index 7ed6227dbb..d90cdec44f 100644 --- a/src/arch/Sound/RageSoundDriver_WDMKS.cpp +++ b/src/arch/Sound/RageSoundDriver_WDMKS.cpp @@ -103,7 +103,7 @@ struct WinWdmFilter CloseHandle( m_hHandle ); } - std::shared_ptr CreatePin( unsigned long iPinId, RString &sError ); + std::unique_ptr CreatePin( unsigned long iPinId, RString &sError ); WinWdmPin *InstantiateRenderPin( DeviceSampleFormat &PreferredOutputSampleFormat, int &iPreferredOutputChannels, @@ -114,7 +114,7 @@ struct WinWdmFilter void Release(); HANDLE m_hHandle; - std::vector> m_apPins; + std::vector> m_apPins; RString m_sFilterName; RString m_sFriendlyName; int m_iUsageCount; @@ -274,7 +274,7 @@ static bool WdmGetPinPropertyMulti( * The pin object holds all the configuration information about the pin * before it is opened, and then the handle of the pin after is opened */ -std::shared_ptr WinWdmFilter::CreatePin( unsigned long iPinId, RString &sError ) +std::unique_ptr WinWdmFilter::CreatePin( unsigned long iPinId, RString &sError ) { { /* Get the COMMUNICATION property */ @@ -369,7 +369,7 @@ std::shared_ptr WinWdmFilter::CreatePin( unsigned long iPinId, RStrin } /* Allocate the new PIN object */ - auto pPin = std::make_shared( this, iPinId ); + auto pPin = std::make_unique( this, iPinId ); /* Get DATARANGEs */ KSMULTIPLE_ITEM *pDataRangesItem; @@ -551,7 +551,7 @@ WinWdmFilter *WinWdmFilter::Create( const RString &sFilterName, const RString &s /* Create the pin with this Id */ auto pNewPin = pFilter->CreatePin( iPinId, sError ); if( pNewPin ) - pFilter->m_apPins.push_back( pNewPin ); + pFilter->m_apPins.push_back( std::move(pNewPin) ); } if( pFilter->m_apPins.empty() ) @@ -617,9 +617,8 @@ void WinWdmFilter::Release() */ WinWdmPin *WinWdmFilter::InstantiateRenderPin( const WAVEFORMATEX *wfex, RString &sError ) { - for( size_t i = 0; i < m_apPins.size(); ++i ) + for (const auto& pPin : m_apPins) { - auto pPin = m_apPins[i]; if( pPin->Instantiate(wfex, sError) ) { sError = ""; @@ -715,7 +714,7 @@ WinWdmPin *WinWdmFilter::InstantiateRenderPin( */ std::vector aSampleRates; { - for (auto pPin : m_apPins) + for (const auto& pPin : m_apPins) { for (KSDATARANGE_AUDIO const &range : pPin->m_dataRangesItem) { @@ -1279,7 +1278,7 @@ RString RageSoundDriver_WDMKS::Init() const WinWdmFilter *pFilter = apFilters[i]; LOG->Trace( "Device #%i: %s", i, pFilter->m_sFriendlyName.c_str() ); int j = 0; - for (auto pPin : pFilter->m_apPins) + for (const auto& pPin : pFilter->m_apPins) { LOG->Trace( " Pin %i", j++ ); for (KSDATARANGE_AUDIO const &range : pPin->m_dataRangesItem)