first pass at merging CourseDifficulty into Difficulty

CourseDifficulty names still exist, since it's useful to distinguish them
in command names
This commit is contained in:
Glenn Maynard
2004-06-04 02:05:56 +00:00
parent ffebc3125a
commit b93d1bfd5e
17 changed files with 70 additions and 71 deletions
+1 -1
View File
@@ -204,7 +204,7 @@ void BPMDisplay::SetBPM( const Course* pCourse )
ASSERT( pCourse );
StepsType st = GAMESTATE->GetCurrentStyleDef()->m_StepsType;
Trail *pTrail = pCourse->GetTrail( st, COURSE_DIFFICULTY_REGULAR );
Trail *pTrail = pCourse->GetTrail( st );
ASSERT( pTrail );
DisplayBpms bpms;
+23 -16
View File
@@ -21,7 +21,7 @@
#include "Foreach.h"
/* Amount to increase meter ranges to make them difficult: */
const int COURSE_DIFFICULTY_CLASS_CHANGE[NUM_COURSE_DIFFICULTIES] = { -1, 0, 1 };
const int COURSE_DIFFICULTY_CLASS_CHANGE[NUM_DIFFICULTIES] = { -1, -1, 0, 1, 1 };
/* Maximum lower value of ranges when difficult: */
const int MAX_BOTTOM_RANGE = 10;
@@ -91,11 +91,11 @@ void Course::LoadFromCRSFile( CString sPath )
else if( 0 == stricmp(sValueName, "METER") )
{
if( sParams.params.size() == 2 )
m_iCustomMeter[COURSE_DIFFICULTY_REGULAR] = atoi( sParams[1] ); /* compat */
m_iCustomMeter[DIFFICULTY_MEDIUM] = atoi( sParams[1] ); /* compat */
else if( sParams.params.size() == 3 )
{
const CourseDifficulty cd = StringToCourseDifficulty( sParams[1] );
if( cd == COURSE_DIFFICULTY_INVALID )
if( cd == DIFFICULTY_INVALID )
{
LOG->Warn( "Course file '%s' contains an invalid #METER string: \"%s\"",
m_sPath.c_str(), sParams[1].c_str() );
@@ -472,7 +472,7 @@ void Course::AutogenOniFromArtist( CString sArtistName, CString sArtistNameTrans
bool Course::IsPlayableIn( StepsType st ) const
{
return GetTrail( st, COURSE_DIFFICULTY_REGULAR ) != NULL;
return GetTrail( st ) != NULL;
}
static vector<Song*> GetFilteredBestSongs( StepsType st )
@@ -533,7 +533,7 @@ CString Course::GetDisplayName() const
* course difficulty doesn't exist, NULL is returned. */
Trail* Course::GetTrail( StepsType st, CourseDifficulty cd ) const
{
ASSERT( cd != COURSE_DIFFICULTY_INVALID );
ASSERT( cd != DIFFICULTY_INVALID );
//
// Look in the Trail cache
@@ -570,16 +570,16 @@ bool Course::GetTrailSorted( StepsType st, CourseDifficulty cd, Trail &trail ) c
if( this->m_bSortByMeter )
{
/* Sort according to COURSE_DIFFICULTY_REGULAR, since the order of songs
/* Sort according to DIFFICULTY_MEDIUM, since the order of songs
* must not change across difficulties. */
Trail SortTrail;
if( cd == COURSE_DIFFICULTY_REGULAR )
if( cd == DIFFICULTY_MEDIUM )
SortTrail = trail;
else
{
bool bOK = GetTrailUnsorted( st, COURSE_DIFFICULTY_REGULAR, SortTrail );
bool bOK = GetTrailUnsorted( st, DIFFICULTY_MEDIUM, SortTrail );
/* If we have any other difficulty, we must have COURSE_DIFFICULTY_REGULAR. */
/* If we have any other difficulty, we must have DIFFICULTY_MEDIUM. */
ASSERT( bOK );
}
ASSERT_M( trail.m_vEntries.size() == SortTrail.m_vEntries.size(),
@@ -606,6 +606,13 @@ bool Course::GetTrailUnsorted( StepsType st, CourseDifficulty cd, Trail &trail )
{
trail.Init();
switch( cd )
{
case DIFFICULTY_BEGINNER:
case DIFFICULTY_CHALLENGE:
return false;
}
//
// Construct a new Trail, add it to the cache, then return it.
//
@@ -637,13 +644,13 @@ bool Course::GetTrailUnsorted( StepsType st, CourseDifficulty cd, Trail &trail )
trail.m_CourseDifficulty = cd;
/* Set to true if CourseDifficulty is able to change something. */
bool bCourseDifficultyIsSignificant = (cd == COURSE_DIFFICULTY_REGULAR);
bool bCourseDifficultyIsSignificant = (cd == DIFFICULTY_MEDIUM);
for( unsigned i=0; i<entries.size(); i++ )
{
const CourseEntry &e = entries[i];
CourseDifficulty entry_difficulty = cd;
if( e.no_difficult && entry_difficulty == COURSE_DIFFICULTY_DIFFICULT )
entry_difficulty = COURSE_DIFFICULTY_REGULAR;
if( e.no_difficult && entry_difficulty == DIFFICULTY_HARD )
entry_difficulty = DIFFICULTY_MEDIUM;
Song* pSong = NULL; // fill this in
Steps* pSteps = NULL; // fill this in
@@ -744,7 +751,7 @@ bool Course::GetTrailUnsorted( StepsType st, CourseDifficulty cd, Trail &trail )
continue; // this song entry isn't playable. Skip.
Difficulty dc = pSteps->GetDifficulty();
if( entry_difficulty != COURSE_DIFFICULTY_REGULAR )
if( entry_difficulty != DIFFICULTY_MEDIUM )
{
/* See if we can find a NoteData after adjusting the difficulty by COURSE_DIFFICULTY_CLASS_CHANGE.
* If we can't, just use the one we already have. */
@@ -810,7 +817,7 @@ bool Course::GetTrailUnsorted( StepsType st, CourseDifficulty cd, Trail &trail )
trail.m_iSpecifiedMeter = m_iCustomMeter[cd];
/* If the course difficulty never actually changed anything, then this difficulty
* is equivalent to COURSE_DIFFICULTY_REGULAR; it doesn't exist. */
* is equivalent to DIFFICULTY_MEDIUM; it doesn't exist. */
return bCourseDifficultyIsSignificant;
}
@@ -923,7 +930,7 @@ bool Course::GetTotalSeconds( StepsType st, float& fSecondsOut ) const
if( !IsFixed() )
return false;
Trail* pTrail = GetTrail( st, COURSE_DIFFICULTY_REGULAR );
Trail* pTrail = GetTrail( st, DIFFICULTY_MEDIUM );
fSecondsOut = pTrail->GetLengthSeconds();
return true;
@@ -967,7 +974,7 @@ void Course::UpdateCourseStats( StepsType st )
return;
}
Trail* pTrail = GetTrail( st, COURSE_DIFFICULTY_REGULAR );
Trail* pTrail = GetTrail( st, DIFFICULTY_MEDIUM );
m_SortOrder_TotalDifficulty += pTrail->GetTotalMeter();
+6 -6
View File
@@ -85,7 +85,7 @@ public:
bool m_bRepeat; // repeat after last song? "Endless"
bool m_bRandomize; // play the songs in a random order
int m_iLives; // -1 means use bar life meter
int m_iCustomMeter[NUM_COURSE_DIFFICULTIES]; // -1 = no meter specified
int m_iCustomMeter[NUM_DIFFICULTIES]; // -1 = no meter specified
bool m_bSortByMeter;
vector<CourseEntry> m_entries;
@@ -95,9 +95,9 @@ public:
CString GetTranslitName() const { return m_sNameTranslit.size()? m_sNameTranslit: m_sName; }
// Dereferences course_entries and returns only the playable Songs and Steps
Trail* GetTrail( StepsType st, CourseDifficulty cd ) const;
Trail* GetTrail( StepsType st, CourseDifficulty cd=DIFFICULTY_MEDIUM ) const;
void GetTrails( vector<Trail*> &AddTo, StepsType st ) const;
float GetMeter( StepsType st, CourseDifficulty cd ) const;
float GetMeter( StepsType st, CourseDifficulty cd=DIFFICULTY_MEDIUM ) const;
bool HasMods() const;
bool AllSongsAreFixed() const;
@@ -135,9 +135,9 @@ private:
bool GetTrailUnsorted( StepsType st, CourseDifficulty cd, Trail &trail ) const;
bool GetTrailSorted( StepsType st, CourseDifficulty cd, Trail &trail ) const;
mutable Trail m_TrailCache[NUM_STEPS_TYPES][NUM_COURSE_DIFFICULTIES];
mutable bool m_TrailCacheValid[NUM_STEPS_TYPES][NUM_COURSE_DIFFICULTIES];
mutable bool m_TrailCacheNull[NUM_STEPS_TYPES][NUM_COURSE_DIFFICULTIES];
mutable Trail m_TrailCache[NUM_STEPS_TYPES][NUM_DIFFICULTIES];
mutable bool m_TrailCacheValid[NUM_STEPS_TYPES][NUM_DIFFICULTIES];
mutable bool m_TrailCacheNull[NUM_STEPS_TYPES][NUM_DIFFICULTIES];
};
#endif
+1 -1
View File
@@ -149,7 +149,7 @@ void CourseUtil::SortCoursePointerArrayByAvgDifficulty( vector<Course*> &apCours
course_sort_val.clear();
for(unsigned i = 0; i < apCourses.size(); ++i)
{
Trail* pTrail = apCourses[i]->GetTrail( GAMESTATE->GetCurrentStyleDef()->m_StepsType, COURSE_DIFFICULTY_REGULAR );
Trail* pTrail = apCourses[i]->GetTrail( GAMESTATE->GetCurrentStyleDef()->m_StepsType );
ASSERT( pTrail ); /* don't give unplayable courses! */
course_sort_val[apCourses[i]] = (float) pTrail->GetMeter();
}
+5 -3
View File
@@ -43,11 +43,13 @@ Difficulty StringToDifficulty( const CString& sDC )
}
static const CString CourseDifficultyNames[NUM_COURSE_DIFFICULTIES] =
static const CString CourseDifficultyNames[NUM_DIFFICULTIES] =
{
"(not used)",
"Easy",
"Regular",
"Difficult",
"(not used)",
};
XToString( CourseDifficulty );
XToThemedString( CourseDifficulty );
@@ -55,12 +57,12 @@ StringToX( CourseDifficulty );
CourseDifficulty GetNextShownCourseDifficulty( CourseDifficulty cd )
{
for( CourseDifficulty d=(CourseDifficulty)(cd+1); d<NUM_COURSE_DIFFICULTIES; ((int&)d)++ )
for( CourseDifficulty d=(CourseDifficulty)(cd+1); d<NUM_DIFFICULTIES; ((int&)d)++ )
{
if( GAMESTATE->IsCourseDifficultyShown(d) )
return d;
}
return COURSE_DIFFICULTY_INVALID;
return DIFFICULTY_INVALID;
}
/*
+7 -14
View File
@@ -23,22 +23,15 @@ CString DifficultyToThemedString( Difficulty dc );
Difficulty StringToDifficulty( const CString& sDC );
enum CourseDifficulty
{
COURSE_DIFFICULTY_EASY,
COURSE_DIFFICULTY_REGULAR,
COURSE_DIFFICULTY_DIFFICULT,
NUM_COURSE_DIFFICULTIES,
COURSE_DIFFICULTY_INVALID
};
#define FOREACH_CourseDifficulty( cd ) FOREACH_ENUM( CourseDifficulty, NUM_COURSE_DIFFICULTIES, cd )
#define FOREACH_ShownCourseDifficulty( cd ) for( CourseDifficulty cd=GetNextShownCourseDifficulty((CourseDifficulty)-1); cd!=COURSE_DIFFICULTY_INVALID; cd=GetNextShownCourseDifficulty(cd) )
typedef Difficulty CourseDifficulty;
#define FOREACH_CourseDifficulty FOREACH_Difficulty
#define FOREACH_ShownCourseDifficulty( cd ) for( Difficulty cd=GetNextShownCourseDifficulty((CourseDifficulty)-1); cd!=DIFFICULTY_INVALID; cd=GetNextShownCourseDifficulty(cd) )
const CString& CourseDifficultyToString( CourseDifficulty dc );
CString CourseDifficultyToThemedString( CourseDifficulty dc );
CourseDifficulty StringToCourseDifficulty( const CString& sDC );
const CString& CourseDifficultyToString( Difficulty dc );
CString CourseDifficultyToThemedString( Difficulty dc );
Difficulty StringToCourseDifficulty( const CString& sDC );
CourseDifficulty GetNextShownCourseDifficulty( CourseDifficulty pn );
Difficulty GetNextShownCourseDifficulty( Difficulty pn );
#endif
+2 -8
View File
@@ -69,14 +69,8 @@ void DifficultyIcon::SetFromDifficulty( PlayerNumber pn, Difficulty dc )
void DifficultyIcon::SetFromCourseDifficulty( PlayerNumber pn, CourseDifficulty cd )
{
m_bBlank = false;
switch( cd )
{
case COURSE_DIFFICULTY_EASY: SetFromDifficulty(pn,DIFFICULTY_EASY); break;
case COURSE_DIFFICULTY_REGULAR: SetFromDifficulty(pn,DIFFICULTY_MEDIUM); break;
case COURSE_DIFFICULTY_DIFFICULT: SetFromDifficulty(pn,DIFFICULTY_HARD); break;
default: ASSERT(0);
}
/* XXX remove */
SetFromDifficulty( pn, cd );
}
/*
+4 -4
View File
@@ -137,7 +137,7 @@ void DifficultyMeter::SetFromTrail( const Trail* pTrail )
Unset();
return;
}
/*
Difficulty FakeDifficulty;
switch( pTrail->m_CourseDifficulty )
{
@@ -146,9 +146,9 @@ void DifficultyMeter::SetFromTrail( const Trail* pTrail )
case COURSE_DIFFICULTY_DIFFICULT: FakeDifficulty = DIFFICULTY_HARD; break;
default: ASSERT(0);
}
SetFromMeterAndDifficulty( pTrail->GetMeter(), FakeDifficulty );
SetDifficulty( DifficultyToString(FakeDifficulty) + "Course" );
*/
SetFromMeterAndDifficulty( pTrail->GetMeter(), pTrail->m_CourseDifficulty );
SetDifficulty( CourseDifficultyToString(pTrail->m_CourseDifficulty) + "Course" );
}
void DifficultyMeter::Unset()
+6 -6
View File
@@ -124,7 +124,7 @@ void GameState::Reset()
FOREACH_PlayerNumber( p )
{
m_PreferredDifficulty[p] = DIFFICULTY_INVALID;
m_PreferredCourseDifficulty[p] = COURSE_DIFFICULTY_REGULAR;
m_PreferredCourseDifficulty[p] = DIFFICULTY_MEDIUM;
}
m_SortOrder = SORT_INVALID;
m_PlayMode = PLAY_MODE_INVALID;
@@ -273,7 +273,7 @@ void GameState::PlayersFinalized()
m_SortOrder = pProfile->m_SortOrder;
if( pProfile->m_LastDifficulty != DIFFICULTY_INVALID )
m_PreferredDifficulty[pn] = pProfile->m_LastDifficulty;
if( pProfile->m_LastCourseDifficulty != COURSE_DIFFICULTY_INVALID )
if( pProfile->m_LastCourseDifficulty != DIFFICULTY_INVALID )
m_PreferredCourseDifficulty[pn] = pProfile->m_LastCourseDifficulty;
if( m_pPreferredSong == NULL && pProfile->m_pLastSong )
m_pPreferredSong = pProfile->m_pLastSong;
@@ -399,7 +399,7 @@ void GameState::SaveCurrentSettingsToProfile( PlayerNumber pn )
pProfile->m_SortOrder = m_SortOrder;
if( m_PreferredDifficulty[pn] != DIFFICULTY_INVALID )
pProfile->m_LastDifficulty = m_PreferredDifficulty[pn];
if( m_PreferredCourseDifficulty[pn] != COURSE_DIFFICULTY_INVALID )
if( m_PreferredCourseDifficulty[pn] != DIFFICULTY_INVALID )
pProfile->m_LastCourseDifficulty = m_PreferredCourseDifficulty[pn];
if( m_pPreferredSong )
pProfile->m_pLastSong = m_pPreferredSong;
@@ -1511,7 +1511,7 @@ void GameState::GetRankingFeats( PlayerNumber pn, vector<RankingFeat> &asFeatsOu
feat.Type = RankingFeat::COURSE;
feat.pCourse = pCourse;
feat.Feat = ssprintf("MR #%d in %s", i+1, pCourse->m_sName.c_str() );
if( cd != COURSE_DIFFICULTY_REGULAR )
if( cd != DIFFICULTY_MEDIUM )
feat.Feat += " " + CourseDifficultyToThemedString(cd);
feat.pStringToFill = &hs.sName;
feat.grade = GRADE_NO_DATA;
@@ -1704,7 +1704,7 @@ static void GetCourseDifficultiesToShow( set<CourseDifficulty> &ret )
for( unsigned i = 0; i < asDiff.size(); ++i )
{
CourseDifficulty cd = StringToCourseDifficulty(asDiff[i]);
if( cd == NUM_COURSE_DIFFICULTIES )
if( cd == NUM_DIFFICULTIES )
RageException::Throw( "Unknown difficulty \"%s\" in CourseDifficultiesToShow", asDiff[i].c_str() );
cache.insert( cd );
}
@@ -1736,7 +1736,7 @@ bool GameState::ChangePreferredCourseDifficulty( PlayerNumber pn, int dir )
while( 1 )
{
cd = (CourseDifficulty)(cd+dir);
if( cd < 0 || cd >= NUM_COURSE_DIFFICULTIES )
if( cd < 0 || cd >= NUM_DIFFICULTIES )
return false;
if( asDiff.find(cd) == asDiff.end() )
continue; /* not available */
+3 -3
View File
@@ -24,7 +24,7 @@ void ModeChoice::Init()
m_style = STYLE_INVALID;
m_pm = PLAY_MODE_INVALID;
m_dc = DIFFICULTY_INVALID;
m_CourseDifficulty = COURSE_DIFFICULTY_INVALID;
m_CourseDifficulty = DIFFICULTY_INVALID;
m_sModifiers = "";
m_sAnnouncer = "";
m_sScreen = "";
@@ -436,7 +436,7 @@ void ModeChoice::Apply( PlayerNumber pn ) const
}
if( m_pTrail )
GAMESTATE->m_pCurTrail[pn] = m_pTrail;
if( m_CourseDifficulty != COURSE_DIFFICULTY_INVALID )
if( m_CourseDifficulty != DIFFICULTY_INVALID )
GAMESTATE->ChangePreferredCourseDifficulty( pn, m_CourseDifficulty );
if( m_pCharacter )
GAMESTATE->m_pCurCharacters[pn] = m_pCharacter;
@@ -470,7 +470,7 @@ bool ModeChoice::IsZero() const
m_pCourse != NULL ||
m_pTrail != NULL ||
m_pCharacter != NULL ||
m_CourseDifficulty != COURSE_DIFFICULTY_INVALID )
m_CourseDifficulty != DIFFICULTY_INVALID )
return false;
return true;
+1 -1
View File
@@ -83,7 +83,7 @@ void Profile::InitGeneralData()
m_sDefaultModifiers = "";
m_SortOrder = SORT_INVALID;
m_LastDifficulty = DIFFICULTY_INVALID;
m_LastCourseDifficulty = COURSE_DIFFICULTY_INVALID;
m_LastCourseDifficulty = DIFFICULTY_INVALID;
m_pLastSong = NULL;
m_pLastCourse = NULL;
m_iTotalPlays = 0;
+1 -1
View File
@@ -545,7 +545,7 @@ CString ScreenOptions::GetExplanationTitle( int iRow ) const
{
Course *pCourse = GAMESTATE->m_pCurCourse;
StepsType st = GAMESTATE->GetCurrentStyleDef()->m_StepsType;
Trail* pTrail = pCourse->GetTrail(st,COURSE_DIFFICULTY_REGULAR);
Trail* pTrail = pCourse->GetTrail( st );
ASSERT( pTrail );
pTrail->GetDisplayBpms( bpms );
}
+1 -1
View File
@@ -327,7 +327,7 @@ ScreenRanking::ScreenRanking( CString sClassName ) : ScreenAttract( sClassName )
if( pts.pCourse == NULL )
continue;
pts.pTrail = pts.pCourse->GetTrail( pts.nt, COURSE_DIFFICULTY_REGULAR );
pts.pTrail = pts.pCourse->GetTrail( pts.nt );
if( pts.pTrail == NULL )
continue;
+1 -1
View File
@@ -1532,7 +1532,7 @@ void ScreenSelectMusic::AfterMusicChange()
{
Course* pCourse = m_MusicWheel.GetSelectedCourse();
StepsType st = GAMESTATE->GetCurrentStyleDef()->m_StepsType;
Trail *pTrail = pCourse->GetTrail( st, COURSE_DIFFICULTY_REGULAR );
Trail *pTrail = pCourse->GetTrail( st );
ASSERT( pTrail );
pCourse->GetTrails( m_vpTrails, GAMESTATE->GetCurrentStyleDef()->m_StepsType );
+4 -1
View File
@@ -99,6 +99,9 @@ void SongManager::InitAll( LoadingWindow *ld )
InitSongsFromDisk( ld );
InitCoursesFromDisk( ld );
InitAutogenCourses();
/* This shouldn't need to be here; if it's taking long enough that this is
* even visible, we should be fixing it, not showing a progress display. */
if( ld )
ld->SetText( "Saving Catalog.xml ..." );
SaveCatalogXml( DATA_DIR );
@@ -726,7 +729,7 @@ bool SongManager::GetExtraStageInfoFromCourse( bool bExtra2, CString sPreferredG
course.LoadFromCRSFile( sCoursePath );
if( course.GetEstimatedNumStages() <= 0 ) return false;
Trail *pTrail = course.GetTrail( GAMESTATE->GetCurrentStyleDef()->m_StepsType, COURSE_DIFFICULTY_REGULAR );
Trail *pTrail = course.GetTrail( GAMESTATE->GetCurrentStyleDef()->m_StepsType );
if( pTrail->m_vEntries.empty() )
return false;
+1 -1
View File
@@ -51,7 +51,7 @@ public:
void Init()
{
m_StepsType = STEPS_TYPE_INVALID;
m_CourseDifficulty = COURSE_DIFFICULTY_INVALID;
m_CourseDifficulty = DIFFICULTY_INVALID;
m_iSpecifiedMeter = -1;
m_vEntries.clear();
}
+3 -3
View File
@@ -11,7 +11,7 @@ void TrailID::FromTrail( const Trail *p )
if( p == NULL )
{
st = STEPS_TYPE_INVALID;
cd = COURSE_DIFFICULTY_INVALID;
cd = DIFFICULTY_INVALID;
}
else
{
@@ -24,7 +24,7 @@ Trail *TrailID::ToTrail( const Course *p, bool bAllowNull ) const
{
ASSERT( p );
if( st == STEPS_TYPE_INVALID || cd == COURSE_DIFFICULTY_INVALID )
if( st == STEPS_TYPE_INVALID || cd == DIFFICULTY_INVALID )
return NULL;
Trail *ret = p->GetTrail( st, cd );
@@ -67,7 +67,7 @@ CString TrailID::ToString() const
bool TrailID::IsValid() const
{
return st != STEPS_TYPE_INVALID && cd != COURSE_DIFFICULTY_INVALID;
return st != STEPS_TYPE_INVALID && cd != DIFFICULTY_INVALID;
}
bool TrailID::operator<( const TrailID &rhs ) const