diff --git a/stepmania/src/Course.cpp b/stepmania/src/Course.cpp index d7cd129df9..cccf980fb6 100644 --- a/stepmania/src/Course.cpp +++ b/stepmania/src/Course.cpp @@ -39,6 +39,7 @@ Course::Course() m_bRandomize = false; m_bDifficult = false; m_iLives = -1; + m_iMeter = -1; SetDefaultScore(); } @@ -107,6 +108,43 @@ PlayMode Course::GetPlayMode() const return PLAY_MODE_NONSTOP; } +const int DifficultMeterRamp = 3; +int Course::GetMeter() const +{ + if( m_iMeter != -1 ) + return m_iMeter + GAMESTATE->m_bDifficultCourses? DifficultMeterRamp:0; + + vector ci; + GetCourseInfo( GAMESTATE->GetCurrentStyleDef()->m_NotesType, ci ); + + /* Take the aveage meter. */ + float fTotalMeter = 0; + for( unsigned c = 0; c < ci.size(); ++c ) + { + if( ci[c].Random ) + { + switch( GetDifficulty(ci[c]) ) + { + case DIFFICULTY_INVALID: + { + int iMeterLow, iMeterHigh; + GetMeterRange(ci[c], iMeterLow, iMeterHigh); + fTotalMeter += int( (iMeterLow + iMeterHigh) / 2.0f ); + break; + } + case DIFFICULTY_BEGINNER: fTotalMeter += 1; break; + case DIFFICULTY_EASY: fTotalMeter += 2; break; + case DIFFICULTY_MEDIUM: fTotalMeter += 5; break; + case DIFFICULTY_HARD: fTotalMeter += 7; break; + case DIFFICULTY_CHALLENGE: fTotalMeter += 9; break; + } + } + else + fTotalMeter += ci[c].Notes->GetMeter(); + } + return (int)roundf( fTotalMeter / ci.size() ); +} + void Course::LoadFromCRSFile( CString sPath ) { m_sPath = sPath; // save path @@ -154,6 +192,9 @@ void Course::LoadFromCRSFile( CString sPath ) else if( 0 == stricmp(sValueName, "LIVES") ) m_iLives = atoi( sParams[1] ); + else if( 0 == stricmp(sValueName, "METER") ) + m_iMeter = atoi( sParams[1] ); + else if( 0 == stricmp(sValueName, "SONG") ) { Entry new_entry; @@ -275,6 +316,7 @@ void Course::Save() fprintf( fp, "#COURSE:%s;\n", m_sName.c_str() ); fprintf( fp, "#REPEAT:%s;\n", m_bRepeat ? "YES" : "NO" ); fprintf( fp, "#LIVES:%i;\n", m_iLives ); + fprintf( fp, "#METER:%i;\n", m_iMeter ); for( unsigned i=0; i &apSongs m_bRepeat = true; m_bRandomize = true; m_iLives = -1; + m_iMeter = -1; m_sName = SONGMAN->ShortenGroupName( sGroupName ); m_sBannerPath = SONGMAN->GetGroupBannerPath( sGroupName ); diff --git a/stepmania/src/Course.h b/stepmania/src/Course.h index df88331ed5..c868153578 100644 --- a/stepmania/src/Course.h +++ b/stepmania/src/Course.h @@ -58,6 +58,7 @@ public: bool m_bRandomize; // play the songs in a random order bool m_bDifficult; // only make something difficult once int m_iLives; // -1 means use bar life meter + int m_iMeter; // -1 autogens struct Info { @@ -94,6 +95,7 @@ public: bool IsOni() const { return !m_bRepeat && m_iLives > 0; } // use battery life meter bool IsEndless() const { return m_bRepeat; } PlayMode GetPlayMode() const; + int GetMeter() const; void LoadFromCRSFile( CString sPath ); void Save();