diff --git a/stepmania/src/StageStats.cpp b/stepmania/src/StageStats.cpp index d1dbf28c78..85c90860ee 100644 --- a/stepmania/src/StageStats.cpp +++ b/stepmania/src/StageStats.cpp @@ -264,6 +264,39 @@ void StageStats::CommitScores( bool bSummary ) } +bool StageStats::PlayerHasHighScore( PlayerNumber pn ) const +{ + const Song *pSong = m_vpPlayedSongs[0]; + const Steps *pSteps = m_player[pn].m_vpPlayedSteps[0]; + const Course *pCourse = GAMESTATE->m_pCurCourse; + const Trail *pTrail = GAMESTATE->m_pCurTrail[pn]; + + // If this is a SHOW_NEVER song, then it's probably a training. + // Don't show a high score + if( pSong->m_SelectionDisplay == Song::SHOW_NEVER ) + return false; + + const HighScoreList &hsl = + GAMESTATE->IsCourseMode() ? + PROFILEMAN->GetMachineProfile()->GetCourseHighScoreList(pCourse, pTrail) : + PROFILEMAN->GetMachineProfile()->GetStepsHighScoreList(pSong, pSteps); + + int iScore = m_player[pn].m_iScore; + float fPercentDP = m_player[pn].GetPercentDancePoints(); + for( int h=0; h<(int)hsl.vHighScores.size() && hm_iMaxHighScoresPerListForMachine; ++h ) + { + const HighScore &hs = hsl.vHighScores[h]; + if( hs.GetName() == RANKING_TO_FILL_IN_MARKER[pn] && + hs.GetPercentDP() == fPercentDP && + hs.GetScore() == iScore ) + { + return true; + } + } + + return false; +} + // lua start #include "LuaBinding.h" @@ -296,6 +329,11 @@ public: static int GetGameplaySeconds( T* p, lua_State *L ) { lua_pushnumber(L, p->m_fGameplaySeconds); return 1; } static int OnePassed( T* p, lua_State *L ) { lua_pushboolean(L, p->OnePassed()); return 1; } static int AllFailed( T* p, lua_State *L ) { lua_pushboolean(L, p->AllFailed()); return 1; } + static int PlayerHasHighScore( T* p, lua_State *L ) + { + lua_pushboolean(L, p->PlayerHasHighScore(Enum::Check(L, 1))); + return 1; + } LunaStageStats() { @@ -306,6 +344,7 @@ public: ADD_METHOD( GetGameplaySeconds ); ADD_METHOD( OnePassed ); ADD_METHOD( AllFailed ); + ADD_METHOD( PlayerHasHighScore ); } }; diff --git a/stepmania/src/StageStats.h b/stepmania/src/StageStats.h index 94977ac933..7284afaed2 100644 --- a/stepmania/src/StageStats.h +++ b/stepmania/src/StageStats.h @@ -48,6 +48,7 @@ public: PlayerStageStats m_multiPlayer[NUM_MultiPlayer]; void CommitScores( bool bSummary ); + bool PlayerHasHighScore( PlayerNumber pn ) const; // Lua void PushSelf( lua_State *L );