Don't use GetSteps with the really long parameter list absolutely necessary.
This commit is contained in:
Chris Danford
2004-11-24 16:25:47 +00:00
parent 0b64a246f9
commit 8fe7c75a9a
7 changed files with 74 additions and 40 deletions
+2 -4
View File
@@ -64,14 +64,12 @@ MusicBannerWheel::MusicBannerWheel()
if ( !PREFSMAN->m_bAutogenSteps ) if ( !PREFSMAN->m_bAutogenSteps )
{ {
LOG->Trace( "Removing all autogen songs from wheel." ); LOG->Trace( "Removing all autogen songs from wheel." );
vector <Steps *> songSteps;
vector <Song *> pNotAutogen; vector <Song *> pNotAutogen;
for ( unsigned i = 0; i < arraySongs.size(); i++) for ( unsigned i = 0; i < arraySongs.size(); i++)
{ {
//ONLY get non-autogenned steps //ONLY get non-autogenned steps
songSteps.clear(); Steps* pSteps = arraySongs[i]->GetStepsByDifficulty( GAMESTATE->GetCurrentStyle()->m_StepsType, DIFFICULTY_INVALID, false );
arraySongs[i]->GetSteps( songSteps, GAMESTATE->GetCurrentStyle()->m_StepsType, DIFFICULTY_INVALID, -1, -1, "", false); if ( pSteps != NULL )
if ( !songSteps.empty() )
pNotAutogen.push_back( arraySongs[i] ); pNotAutogen.push_back( arraySongs[i] );
} }
arraySongs.clear(); arraySongs.clear();
+2 -4
View File
@@ -381,10 +381,8 @@ void MusicWheel::GetSongList(vector<Song*> &arraySongs, SortOrder so, CString sP
if( so!=SORT_ROULETTE && UNLOCKMAN->SongIsLocked(pSong) ) if( so!=SORT_ROULETTE && UNLOCKMAN->SongIsLocked(pSong) )
continue; continue;
vector<Steps*> arraySteps; // If the song has at least one steps, add it.
pSong->GetSteps( arraySteps, GAMESTATE->GetCurrentStyle()->m_StepsType, DIFFICULTY_INVALID, -1, -1, "", 1 ); if( pSong->HasStepsType(GAMESTATE->GetCurrentStyle()->m_StepsType) )
if( !arraySteps.empty() )
arraySongs.push_back( pSong ); arraySongs.push_back( pSong );
} }
+4 -5
View File
@@ -983,13 +983,12 @@ void BMSLoader::SlideDuplicateDifficulties( Song &p )
* difficulties slid upwards due to (for example) having two beginner steps. * difficulties slid upwards due to (for example) having two beginner steps.
* We do a second pass in Song::TidyUpData to eliminate any remaining duplicates * We do a second pass in Song::TidyUpData to eliminate any remaining duplicates
* after this. */ * after this. */
for( int i=0; i<NUM_STEPS_TYPES; i++ ) FOREACH_StepsType( st )
{ {
StepsType st = (StepsType)i; FOREACH_Difficulty( dc )
for( unsigned j=0; j<=DIFFICULTY_CHALLENGE; j++ ) // not DIFFICULTY_EDIT
{ {
Difficulty dc = (Difficulty)j; if( dc == DIFFICULTY_EDIT )
continue;
vector<Steps*> vSteps; vector<Steps*> vSteps;
p.GetSteps( vSteps, st, dc ); p.GetSteps( vSteps, st, dc );
+37 -16
View File
@@ -372,13 +372,12 @@ void Song::DeleteDuplicateSteps( vector<Steps*> &vSteps )
* on this; see BMSLoader::SlideDuplicateDifficulties.) */ * on this; see BMSLoader::SlideDuplicateDifficulties.) */
void Song::AdjustDuplicateSteps() void Song::AdjustDuplicateSteps()
{ {
for( int i=0; i<NUM_STEPS_TYPES; i++ ) FOREACH_StepsType( st )
{ {
StepsType st = (StepsType)i; FOREACH_Difficulty( dc )
for( unsigned j=0; j<=DIFFICULTY_CHALLENGE; j++ ) // not DIFFICULTY_EDIT
{ {
Difficulty dc = (Difficulty)j; if( dc == DIFFICULTY_EDIT )
continue;
vector<Steps*> vSteps; vector<Steps*> vSteps;
this->GetSteps( vSteps, st, dc ); this->GetSteps( vSteps, st, dc );
@@ -826,9 +825,18 @@ void Song::ReCalculateRadarValuesAndLastBeat()
} }
} }
void Song::GetSteps( vector<Steps*>& arrayAddTo, StepsType st, Difficulty dc, int iMeterLow, int iMeterHigh, const CString &sDescription, bool bIncludeAutoGen, int Max ) const void Song::GetSteps(
vector<Steps*>& arrayAddTo,
StepsType st,
Difficulty dc,
int iMeterLow,
int iMeterHigh,
const CString &sDescription,
bool bIncludeAutoGen,
int iMaxToGet
) const
{ {
if( !Max ) if( !iMaxToGet )
return; return;
const vector<Steps*>& vpSteps = GetAllSteps(st); const vector<Steps*>& vpSteps = GetAllSteps(st);
@@ -849,15 +857,32 @@ void Song::GetSteps( vector<Steps*>& arrayAddTo, StepsType st, Difficulty dc, in
arrayAddTo.push_back( pSteps ); arrayAddTo.push_back( pSteps );
if( Max != -1 ) if( iMaxToGet != -1 )
{ {
--Max; --iMaxToGet;
if( !Max ) if( !iMaxToGet )
break; break;
} }
} }
} }
Steps* Song::GetSteps(
StepsType st,
Difficulty dc,
int iMeterLow,
int iMeterHigh,
const CString &sDescription,
bool bIncludeAutoGen
) const
{
vector<Steps*> vpSteps;
GetSteps( vpSteps, st, dc, iMeterLow, iMeterHigh, sDescription, bIncludeAutoGen, 1 ); // get max 1
if( vpSteps.empty() )
return NULL;
else
return vpSteps[0];
}
Steps* Song::GetStepsByDifficulty( StepsType st, Difficulty dc, bool bIncludeAutoGen ) const Steps* Song::GetStepsByDifficulty( StepsType st, Difficulty dc, bool bIncludeAutoGen ) const
{ {
const vector<Steps*>& vpSteps = GetAllSteps(st); const vector<Steps*>& vpSteps = GetAllSteps(st);
@@ -941,16 +966,12 @@ bool Song::SongCompleteForStyle( const Style *st ) const
bool Song::HasStepsType( StepsType st ) const bool Song::HasStepsType( StepsType st ) const
{ {
vector<Steps*> add; return GetSteps( st ) != NULL;
GetSteps( add, st, DIFFICULTY_INVALID, -1, -1, "", true, 1 );
return !add.empty();
} }
bool Song::HasStepsTypeAndDifficulty( StepsType st, Difficulty dc ) const bool Song::HasStepsTypeAndDifficulty( StepsType st, Difficulty dc ) const
{ {
vector<Steps*> add; return GetSteps( st, dc ) != NULL;
GetSteps( add, st, dc, -1, -1, "", true, 1 );
return !add.empty();
} }
void Song::Save() void Song::Save()
+1 -1
View File
@@ -1206,7 +1206,7 @@ void SongManager::LoadAllFromProfiles()
continue; continue;
} }
SMLoader::LoadEdit( fn, (ProfileSlot) s ); SMLoader::LoadEdit( fn, s );
} }
} }
+10 -9
View File
@@ -154,16 +154,17 @@ Steps *StepsID::ToSteps( const Song *p, bool bAllowNull, bool bUseCache ) const
return it->second; return it->second;
} }
vector<Steps*> vNotes;
if( dc == DIFFICULTY_EDIT )
p->GetSteps( vNotes, st, dc, -1, -1, sDescription, true, 1 );
else
p->GetSteps( vNotes, st, dc, -1, -1, "", true, 1 );
Steps *ret = NULL; Steps *ret = NULL;
if( !vNotes.empty() ) if( dc == DIFFICULTY_EDIT )
ret = vNotes[0]; {
else if( !bAllowNull ) ret = p->GetSteps( st, dc, -1, -1, sDescription, true );
}
else
{
ret = p->GetSteps( st, dc, -1, -1, "", true );
}
if( !bAllowNull )
RageException::Throw( "%i, %i, \"%s\"", st, dc, sDescription.c_str() ); RageException::Throw( "%i, %i, \"%s\"", st, dc, sDescription.c_str() );
if( bUseCache ) if( bUseCache )
+18 -1
View File
@@ -173,7 +173,24 @@ public:
bool HasStepsType( StepsType st ) const; bool HasStepsType( StepsType st ) const;
bool HasStepsTypeAndDifficulty( StepsType st, Difficulty dc ) const; bool HasStepsTypeAndDifficulty( StepsType st, Difficulty dc ) const;
const vector<Steps*>& GetAllSteps( StepsType st=STEPS_TYPE_INVALID ) const { return st==STEPS_TYPE_INVALID? m_vpSteps:m_vpStepsByType[st]; } const vector<Steps*>& GetAllSteps( StepsType st=STEPS_TYPE_INVALID ) const { return st==STEPS_TYPE_INVALID? m_vpSteps:m_vpStepsByType[st]; }
void GetSteps( vector<Steps*>& arrayAddTo, StepsType st = STEPS_TYPE_INVALID, Difficulty dc = DIFFICULTY_INVALID, int iMeterLow = -1, int iMeterHigh = -1, const CString &sDescription = "", bool bIncludeAutoGen = true, int Max = -1 ) const; void GetSteps(
vector<Steps*>& arrayAddTo,
StepsType st = STEPS_TYPE_INVALID,
Difficulty dc = DIFFICULTY_INVALID,
int iMeterLow = -1,
int iMeterHigh = -1,
const CString &sDescription = "",
bool bIncludeAutoGen = true,
int iMaxToGet = -1
) const;
Steps* GetSteps(
StepsType st = STEPS_TYPE_INVALID,
Difficulty dc = DIFFICULTY_INVALID,
int iMeterLow = -1,
int iMeterHigh = -1,
const CString &sDescription = "",
bool bIncludeAutoGen = true
) const;
Steps* GetStepsByDifficulty( StepsType st, Difficulty dc, bool bIncludeAutoGen = true ) const; Steps* GetStepsByDifficulty( StepsType st, Difficulty dc, bool bIncludeAutoGen = true ) const;
Steps* GetStepsByMeter( StepsType st, int iMeterLow, int iMeterHigh ) const; Steps* GetStepsByMeter( StepsType st, int iMeterLow, int iMeterHigh ) const;
Steps* GetStepsByDescription( StepsType st, CString sDescription ) const; Steps* GetStepsByDescription( StepsType st, CString sDescription ) const;