Integrate C++11 branch into 5_1-new
This commit is contained in:
+49
-62
@@ -9,7 +9,6 @@
|
||||
#include "PrefsManager.h"
|
||||
#include "SongManager.h"
|
||||
#include "XmlFile.h"
|
||||
#include "Foreach.h"
|
||||
#include "UnlockManager.h"
|
||||
#include "ThemeMetric.h"
|
||||
#include "LocalizedString.h"
|
||||
@@ -158,7 +157,7 @@ Steps* SongUtil::GetOneSteps(
|
||||
vector<Steps*> vpSteps;
|
||||
GetSteps( pSong, vpSteps, st, dc, iMeterLow, iMeterHigh, sDescription, sCredit, bIncludeAutoGen, uHash, 1 ); // get max 1
|
||||
if( vpSteps.empty() )
|
||||
return NULL;
|
||||
return nullptr;
|
||||
else
|
||||
return vpSteps[0];
|
||||
}
|
||||
@@ -178,7 +177,7 @@ Steps* SongUtil::GetStepsByDifficulty( const Song *pSong, StepsType st, Difficul
|
||||
return pSteps;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Steps* SongUtil::GetStepsByMeter( const Song *pSong, StepsType st, int iMeterLow, int iMeterHigh )
|
||||
@@ -196,7 +195,7 @@ Steps* SongUtil::GetStepsByMeter( const Song *pSong, StepsType st, int iMeterLow
|
||||
return pSteps;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Steps* SongUtil::GetStepsByDescription( const Song *pSong, StepsType st, RString sDescription )
|
||||
@@ -204,7 +203,7 @@ Steps* SongUtil::GetStepsByDescription( const Song *pSong, StepsType st, RString
|
||||
vector<Steps*> vNotes;
|
||||
GetSteps( pSong, vNotes, st, Difficulty_Invalid, -1, -1, sDescription, "" );
|
||||
if( vNotes.size() == 0 )
|
||||
return NULL;
|
||||
return nullptr;
|
||||
else
|
||||
return vNotes[0];
|
||||
}
|
||||
@@ -214,7 +213,7 @@ Steps* SongUtil::GetStepsByCredit( const Song *pSong, StepsType st, RString sCre
|
||||
vector<Steps*> vNotes;
|
||||
GetSteps(pSong, vNotes, st, Difficulty_Invalid, -1, -1, "", sCredit );
|
||||
if( vNotes.size() == 0 )
|
||||
return NULL;
|
||||
return nullptr;
|
||||
else
|
||||
return vNotes[0];
|
||||
}
|
||||
@@ -225,7 +224,7 @@ Steps* SongUtil::GetClosestNotes( const Song *pSong, StepsType st, Difficulty dc
|
||||
ASSERT( dc != Difficulty_Invalid );
|
||||
|
||||
const vector<Steps*>& vpSteps = (st == StepsType_Invalid)? pSong->GetAllSteps() : pSong->GetStepsByStepsType(st);
|
||||
Steps *pClosest = NULL;
|
||||
Steps *pClosest = nullptr;
|
||||
int iClosestDistance = 999;
|
||||
for( unsigned i=0; i<vpSteps.size(); i++ ) // for each of the Song's Steps
|
||||
{
|
||||
@@ -475,7 +474,7 @@ void SongUtil::SortSongPointerArrayByGrades( vector<Song*> &vpSongsInOut, bool b
|
||||
|
||||
int iCounts[NUM_Grade];
|
||||
const Profile *pProfile = PROFILEMAN->GetMachineProfile();
|
||||
ASSERT( pProfile != NULL );
|
||||
ASSERT( pProfile != nullptr );
|
||||
pProfile->GetGrades( pSong, GAMESTATE->GetCurrentStyle(GAMESTATE->GetMasterPlayerNumber())->m_StepsType, iCounts );
|
||||
|
||||
RString foo;
|
||||
@@ -552,7 +551,7 @@ void SongUtil::SortSongPointerArrayByNumPlays( vector<Song*> &vpSongsInOut, Prof
|
||||
|
||||
void SongUtil::SortSongPointerArrayByNumPlays( vector<Song*> &vpSongsInOut, const Profile* pProfile, bool bDescending )
|
||||
{
|
||||
ASSERT( pProfile != NULL );
|
||||
ASSERT( pProfile != nullptr );
|
||||
for(unsigned i = 0; i < vpSongsInOut.size(); ++i)
|
||||
g_mapSongSortVal[vpSongsInOut[i]] = ssprintf("%9i", pProfile->GetSongNumTimesPlayed(vpSongsInOut[i]));
|
||||
stable_sort( vpSongsInOut.begin(), vpSongsInOut.end(), bDescending ? CompareSongPointersBySortValueDescending : CompareSongPointersBySortValueAscending );
|
||||
@@ -561,7 +560,7 @@ void SongUtil::SortSongPointerArrayByNumPlays( vector<Song*> &vpSongsInOut, cons
|
||||
|
||||
RString SongUtil::GetSectionNameFromSongAndSort( const Song* pSong, SortOrder so )
|
||||
{
|
||||
if( pSong == NULL )
|
||||
if( pSong == nullptr )
|
||||
return RString();
|
||||
|
||||
switch( so )
|
||||
@@ -718,11 +717,11 @@ void SongUtil::SortByMostRecentlyPlayedForMachine( vector<Song*> &vpSongsInOut )
|
||||
{
|
||||
Profile *pProfile = PROFILEMAN->GetMachineProfile();
|
||||
|
||||
FOREACH_CONST( Song*, vpSongsInOut, s )
|
||||
for (Song const *s : vpSongsInOut)
|
||||
{
|
||||
int iNumTimesPlayed = pProfile->GetSongNumTimesPlayed( *s );
|
||||
RString val = iNumTimesPlayed ? pProfile->GetSongLastPlayedDateTime(*s).GetString() : "0";
|
||||
g_mapSongSortVal[*s] = val;
|
||||
int iNumTimesPlayed = pProfile->GetSongNumTimesPlayed( s );
|
||||
RString val = iNumTimesPlayed ? pProfile->GetSongLastPlayedDateTime(s).GetString() : "0";
|
||||
g_mapSongSortVal[s] = val;
|
||||
}
|
||||
|
||||
stable_sort( vpSongsInOut.begin(), vpSongsInOut.end(), CompareSongPointersBySortValueDescending );
|
||||
@@ -731,10 +730,8 @@ void SongUtil::SortByMostRecentlyPlayedForMachine( vector<Song*> &vpSongsInOut )
|
||||
|
||||
bool SongUtil::IsEditDescriptionUnique( const Song* pSong, StepsType st, const RString &sPreferredDescription, const Steps *pExclude )
|
||||
{
|
||||
FOREACH_CONST( Steps*, pSong->GetAllSteps(), s )
|
||||
for (Steps const *pSteps : pSong->GetAllSteps())
|
||||
{
|
||||
Steps *pSteps = *s;
|
||||
|
||||
if( pSteps->GetDifficulty() != Difficulty_Edit )
|
||||
continue;
|
||||
if( pSteps->m_StepsType != st )
|
||||
@@ -749,10 +746,8 @@ bool SongUtil::IsEditDescriptionUnique( const Song* pSong, StepsType st, const R
|
||||
|
||||
bool SongUtil::IsChartNameUnique( const Song* pSong, StepsType st, const RString &name, const Steps *pExclude )
|
||||
{
|
||||
FOREACH_CONST( Steps*, pSong->GetAllSteps(), s )
|
||||
for (Steps const *pSteps : pSong->GetAllSteps())
|
||||
{
|
||||
Steps *pSteps = *s;
|
||||
|
||||
if( pSteps->m_StepsType != st )
|
||||
continue;
|
||||
if( pSteps == pExclude )
|
||||
@@ -765,7 +760,7 @@ bool SongUtil::IsChartNameUnique( const Song* pSong, StepsType st, const RString
|
||||
|
||||
RString SongUtil::MakeUniqueEditDescription( const Song *pSong, StepsType st, const RString &sPreferredDescription )
|
||||
{
|
||||
if( IsEditDescriptionUnique( pSong, st, sPreferredDescription, NULL ) )
|
||||
if( IsEditDescriptionUnique( pSong, st, sPreferredDescription, nullptr ) )
|
||||
return sPreferredDescription;
|
||||
|
||||
RString sTemp;
|
||||
@@ -776,7 +771,7 @@ RString SongUtil::MakeUniqueEditDescription( const Song *pSong, StepsType st, co
|
||||
RString sNum = ssprintf("%d", i+1);
|
||||
sTemp = sPreferredDescription.Left( MAX_STEPS_DESCRIPTION_LENGTH - sNum.size() ) + sNum;
|
||||
|
||||
if( IsEditDescriptionUnique(pSong, st, sTemp, NULL) )
|
||||
if( IsEditDescriptionUnique(pSong, st, sTemp, nullptr) )
|
||||
return sTemp;
|
||||
}
|
||||
|
||||
@@ -804,7 +799,7 @@ bool SongUtil::ValidateCurrentEditStepsDescription( const RString &sAnswer, RStr
|
||||
}
|
||||
|
||||
static const RString sInvalidChars = "\\/:*?\"<>|";
|
||||
if( strpbrk(sAnswer, sInvalidChars) != NULL )
|
||||
if( strpbrk(sAnswer, sInvalidChars) != nullptr )
|
||||
{
|
||||
sErrorOut = ssprintf( EDIT_NAME_CANNOT_CONTAIN.GetValue(), sInvalidChars.c_str() );
|
||||
return false;
|
||||
@@ -813,12 +808,12 @@ bool SongUtil::ValidateCurrentEditStepsDescription( const RString &sAnswer, RStr
|
||||
// Steps name must be unique for this song.
|
||||
vector<Steps*> v;
|
||||
GetSteps( pSong, v, StepsType_Invalid, Difficulty_Edit );
|
||||
FOREACH_CONST( Steps*, v, s )
|
||||
for (Steps const *s : v)
|
||||
{
|
||||
if( pSteps == *s )
|
||||
if( pSteps == s )
|
||||
continue; // don't compare name against ourself
|
||||
|
||||
if( (*s)->GetDescription() == sAnswer )
|
||||
if( s->GetDescription() == sAnswer )
|
||||
{
|
||||
sErrorOut = EDIT_NAME_CONFLICTS;
|
||||
return false;
|
||||
@@ -854,7 +849,7 @@ bool SongUtil::ValidateCurrentStepsChartName(const RString &answer, RString &err
|
||||
if (answer.empty()) return true;
|
||||
|
||||
static const RString sInvalidChars = "\\/:*?\"<>|";
|
||||
if( strpbrk(answer, sInvalidChars) != NULL )
|
||||
if( strpbrk(answer, sInvalidChars) != nullptr )
|
||||
{
|
||||
error = ssprintf( CHART_NAME_CANNOT_CONTAIN.GetValue(), sInvalidChars.c_str() );
|
||||
return false;
|
||||
@@ -888,7 +883,7 @@ bool SongUtil::ValidateCurrentStepsCredit( const RString &sAnswer, RString &sErr
|
||||
|
||||
// Borrow from EditDescription testing. Perhaps this should be abstracted? -Wolfman2000
|
||||
static const RString sInvalidChars = "\\/:*?\"<>|";
|
||||
if( strpbrk(sAnswer, sInvalidChars) != NULL )
|
||||
if( strpbrk(sAnswer, sInvalidChars) != nullptr )
|
||||
{
|
||||
sErrorOut = ssprintf( AUTHOR_NAME_CANNOT_CONTAIN.GetValue(), sInvalidChars.c_str() );
|
||||
return false;
|
||||
@@ -936,15 +931,14 @@ bool SongUtil::ValidateCurrentStepsMusic(const RString &answer, RString &error)
|
||||
void SongUtil::GetAllSongGenres( vector<RString> &vsOut )
|
||||
{
|
||||
set<RString> genres;
|
||||
FOREACH_CONST( Song*, SONGMAN->GetAllSongs(), song )
|
||||
for (Song const *song : SONGMAN->GetAllSongs())
|
||||
{
|
||||
if( !(*song)->m_sGenre.empty() )
|
||||
genres.insert( (*song)->m_sGenre );
|
||||
if( !song->m_sGenre.empty() )
|
||||
genres.insert( song->m_sGenre );
|
||||
}
|
||||
|
||||
FOREACHS_CONST( RString, genres, s )
|
||||
for (RString const &genre : genres)
|
||||
{
|
||||
vsOut.push_back( *s );
|
||||
vsOut.push_back( genre );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -952,12 +946,11 @@ void SongUtil::FilterSongs( const SongCriteria &sc, const vector<Song*> &in,
|
||||
vector<Song*> &out, bool doCareAboutGame )
|
||||
{
|
||||
out.reserve( in.size() );
|
||||
FOREACH_CONST( Song*, in, s )
|
||||
for (Song *s : in)
|
||||
{
|
||||
if( sc.Matches( *s ) && (!doCareAboutGame || IsSongPlayable(*s) ) )
|
||||
if( sc.Matches( s ) && (!doCareAboutGame || IsSongPlayable(s) ) )
|
||||
{
|
||||
|
||||
out.push_back( *s );
|
||||
out.push_back( s );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -966,7 +959,7 @@ void SongUtil::GetPlayableStepsTypes( const Song *pSong, set<StepsType> &vOut )
|
||||
{
|
||||
vector<const Style*> vpPossibleStyles;
|
||||
// If AutoSetStyle, or a Style hasn't been chosen, check StepsTypes for all Styles.
|
||||
if( CommonMetrics::AUTO_SET_STYLE || GAMESTATE->GetCurrentStyle(PLAYER_INVALID) == NULL )
|
||||
if( CommonMetrics::AUTO_SET_STYLE || GAMESTATE->GetCurrentStyle(PLAYER_INVALID) == nullptr )
|
||||
GAMEMAN->GetCompatibleStyles( GAMESTATE->m_pCurGame, GAMESTATE->GetNumPlayersEnabled(), vpPossibleStyles );
|
||||
else
|
||||
vpPossibleStyles.push_back( GAMESTATE->GetCurrentStyle(PLAYER_INVALID) );
|
||||
@@ -992,16 +985,16 @@ void SongUtil::GetPlayableStepsTypes( const Song *pSong, set<StepsType> &vOut )
|
||||
}
|
||||
|
||||
set<StepsType> vStepsTypes;
|
||||
FOREACH( const Style*, vpPossibleStyles, s )
|
||||
vStepsTypes.insert( (*s)->m_StepsType );
|
||||
for (Style const *s : vpPossibleStyles)
|
||||
vStepsTypes.insert( s->m_StepsType );
|
||||
|
||||
/* filter out hidden StepsTypes, and remove steps that we don't have enough
|
||||
* stages left to play. */
|
||||
// this being const may have caused some problems... -aj
|
||||
const vector<StepsType> &vstToShow = CommonMetrics::STEPS_TYPES_TO_SHOW.GetValue();
|
||||
FOREACHS( StepsType, vStepsTypes, st )
|
||||
for (StepsType const &type : vStepsTypes)
|
||||
{
|
||||
bool bShowThisStepsType = find( vstToShow.begin(), vstToShow.end(), *st ) != vstToShow.end();
|
||||
bool bShowThisStepsType = find( vstToShow.begin(), vstToShow.end(), type ) != vstToShow.end();
|
||||
|
||||
int iNumPlayers = GAMESTATE->GetNumPlayersEnabled();
|
||||
iNumPlayers = max( iNumPlayers, 1 );
|
||||
@@ -1011,7 +1004,7 @@ void SongUtil::GetPlayableStepsTypes( const Song *pSong, set<StepsType> &vOut )
|
||||
GAMESTATE->GetNumStagesMultiplierForSong(pSong);
|
||||
|
||||
if( bShowThisStepsType && bEnoughStages )
|
||||
vOut.insert( *st );
|
||||
vOut.insert( type );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1020,8 +1013,8 @@ void SongUtil::GetPlayableSteps( const Song *pSong, vector<Steps*> &vOut )
|
||||
set<StepsType> vStepsType;
|
||||
GetPlayableStepsTypes( pSong, vStepsType );
|
||||
|
||||
FOREACHS( StepsType, vStepsType, st )
|
||||
SongUtil::GetSteps( pSong, vOut, *st );
|
||||
for (StepsType const &type : vStepsType)
|
||||
SongUtil::GetSteps( pSong, vOut, type );
|
||||
|
||||
StepsUtil::RemoveLockedSteps( pSong, vOut );
|
||||
StepsUtil::SortNotesArrayByDifficulty( vOut );
|
||||
@@ -1046,15 +1039,9 @@ bool SongUtil::IsSongPlayable( Song *s )
|
||||
{
|
||||
const vector<Steps*> & steps = s->GetAllSteps();
|
||||
// I'm sure there is a foreach loop, but I don't
|
||||
FOREACH( Steps*, const_cast<vector<Steps*>&>(steps), step )
|
||||
{
|
||||
if (IsStepsPlayable(s, *step))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
return std::any_of(steps.begin(), steps.end(), [&](Steps *step) {
|
||||
return IsStepsPlayable(s, step);
|
||||
});
|
||||
}
|
||||
|
||||
bool SongUtil::GetStepsTypeAndDifficultyFromSortOrder( SortOrder so, StepsType &stOut, Difficulty &dcOut )
|
||||
@@ -1091,15 +1078,15 @@ bool SongUtil::GetStepsTypeAndDifficultyFromSortOrder( SortOrder so, StepsType &
|
||||
stOut = GAMESTATE->GetCurrentStyle(GAMESTATE->GetMasterPlayerNumber())->m_StepsType; // in case we don't find any matches below
|
||||
vector<const Style*> vpStyles;
|
||||
GAMEMAN->GetStylesForGame(GAMESTATE->m_pCurGame,vpStyles);
|
||||
FOREACH_CONST( const Style*, vpStyles, i )
|
||||
for (Style const *i : vpStyles)
|
||||
{
|
||||
if( (*i)->m_StyleType == StyleType_OnePlayerTwoSides )
|
||||
if( i->m_StyleType == StyleType_OnePlayerTwoSides )
|
||||
{
|
||||
// Ugly hack to ignore pump's half-double.
|
||||
bool bContainsHalf = ((RString)(*i)->m_szName).find("half") != RString::npos;
|
||||
bool bContainsHalf = ((RString)i->m_szName).find("half") != RString::npos;
|
||||
if( bContainsHalf )
|
||||
continue;
|
||||
stOut = (*i)->m_StepsType;
|
||||
stOut = i->m_StepsType;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -1129,7 +1116,7 @@ void SongID::FromSong( const Song *p )
|
||||
|
||||
Song *SongID::ToSong() const
|
||||
{
|
||||
Song *pRet = NULL;
|
||||
Song *pRet = nullptr;
|
||||
if( !m_Cache.Get(&pRet) )
|
||||
{
|
||||
if(!sDir.empty())
|
||||
@@ -1169,7 +1156,7 @@ RString SongID::ToString() const
|
||||
|
||||
bool SongID::IsValid() const
|
||||
{
|
||||
return ToSong() != NULL;
|
||||
return ToSong() != nullptr;
|
||||
}
|
||||
|
||||
// lua start
|
||||
@@ -1207,7 +1194,7 @@ namespace
|
||||
LIST_METHOD( GetPlayableSteps ),
|
||||
LIST_METHOD( IsStepsTypePlayable ),
|
||||
LIST_METHOD( IsStepsPlayable ),
|
||||
{ NULL, NULL }
|
||||
{ nullptr, nullptr }
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user