diff --git a/stepmania/src/CryptManager.cpp b/stepmania/src/CryptManager.cpp index 18abf76a1a..1c0eb55610 100644 --- a/stepmania/src/CryptManager.cpp +++ b/stepmania/src/CryptManager.cpp @@ -232,7 +232,7 @@ static RString BinaryToHex( const unsigned char *string, int iNumBytes ) return s; } -RString CryptManager::GetMD5( RString fn ) +RString CryptManager::GetMD5ForFile( RString fn ) { struct MD5Context md5c; unsigned char digest[16]; @@ -257,6 +257,18 @@ RString CryptManager::GetMD5( RString fn ) return BinaryToHex( digest, sizeof(digest) ); } +RString CryptManager::GetMD5ForString( RString sData ) +{ + struct MD5Context md5c; + unsigned char digest[16]; + + MD5Init(&md5c); + MD5Update(&md5c, reinterpret_cast(sData.c_str()), sData.size()); + MD5Final(digest, &md5c); + + return BinaryToHex( digest, sizeof(digest) ); +} + RString CryptManager::GetPublicKeyFileName() { ASSERT( PREFSMAN->m_bSignProfileData ); diff --git a/stepmania/src/CryptManager.h b/stepmania/src/CryptManager.h index 053af62cb9..061c523e39 100644 --- a/stepmania/src/CryptManager.h +++ b/stepmania/src/CryptManager.h @@ -19,7 +19,8 @@ public: static RString Sign( RString sPath ); static bool Verify( RString sPath, RString sSignature ); - static RString GetMD5( RString fn ); // in Hex + static RString GetMD5ForFile( RString fn ); // in Hex + static RString GetMD5ForString( RString sData ); // in Hex static RString GetPublicKeyFileName(); }; diff --git a/stepmania/src/ScreenEvaluation.cpp b/stepmania/src/ScreenEvaluation.cpp index 9057dcf7d3..14ee8b99eb 100644 --- a/stepmania/src/ScreenEvaluation.cpp +++ b/stepmania/src/ScreenEvaluation.cpp @@ -871,7 +871,7 @@ void ScreenEvaluation::Input( const InputEventPlus &input ) const HighScore &hs = STATSMAN->m_CurStageStats.m_player[pn].m_HighScore; Screenshot screenshot; screenshot.sFileName = sFileName; - screenshot.sMD5 = CRYPTMAN->GetMD5( sPath ); + screenshot.sMD5 = CRYPTMAN->GetMD5ForFile( sPath ); screenshot.highScore = hs; pProfile->AddScreenshot( screenshot ); } diff --git a/stepmania/src/SongManager.cpp b/stepmania/src/SongManager.cpp index 84b4c8a77f..88f53f56e7 100644 --- a/stepmania/src/SongManager.cpp +++ b/stepmania/src/SongManager.cpp @@ -559,8 +559,23 @@ int SongManager::GetNumUnlockedSongs() const int num = 0; FOREACH_CONST( Song*, m_pSongs, i ) { - if( !UNLOCKMAN->SongIsLocked( *i ) ) - num++; + if( UNLOCKMAN->SongIsLocked( *i ) ) + continue; + num++; + } + return num; +} + +int SongManager::GetNumSelectableAndUnlockedSongs() const +{ + int num = 0; + FOREACH_CONST( Song*, m_pSongs, i ) + { + if( UNLOCKMAN->SongIsLocked( *i ) ) + continue; + if( (*i)->m_SelectionDisplay != Song::SHOW_ALWAYS ) + continue; + num++; } return num; } @@ -1730,14 +1745,15 @@ public: } static int FindSong( T* p, lua_State *L ) { Song *pS = p->FindSong(SArg(1)); if(pS) pS->PushSelf(L); else lua_pushnil(L); return 1; } static int FindCourse( T* p, lua_State *L ) { Course *pC = p->FindCourse(SArg(1)); if(pC) pC->PushSelf(L); else lua_pushnil(L); return 1; } - static int GetRandomSong( T* p, lua_State *L ) { Song *pS = p->GetRandomSong(); if(pS) pS->PushSelf(L); else lua_pushnil(L); return 1; } - static int GetRandomCourse( T* p, lua_State *L ){ Course *pC = p->GetRandomCourse(); if(pC) pC->PushSelf(L); else lua_pushnil(L); return 1; } - static int GetNumSongs( T* p, lua_State *L ) { lua_pushnumber( L, p->GetNumSongs() ); return 1; } + static int GetRandomSong( T* p, lua_State *L ) { Song *pS = p->GetRandomSong(); if(pS) pS->PushSelf(L); else lua_pushnil(L); return 1; } + static int GetRandomCourse( T* p, lua_State *L ) { Course *pC = p->GetRandomCourse(); if(pC) pC->PushSelf(L); else lua_pushnil(L); return 1; } + static int GetNumSongs( T* p, lua_State *L ) { lua_pushnumber( L, p->GetNumSongs() ); return 1; } static int GetNumUnlockedSongs( T* p, lua_State *L ) { lua_pushnumber( L, p->GetNumUnlockedSongs() ); return 1; } - static int GetNumAdditionalSongs( T* p, lua_State *L ) { lua_pushnumber( L, p->GetNumAdditionalSongs() ); return 1; } - static int GetNumSongGroups( T* p, lua_State *L ) { lua_pushnumber( L, p->GetNumSongGroups() ); return 1; } - static int GetNumCourses( T* p, lua_State *L ) { lua_pushnumber( L, p->GetNumCourses() ); return 1; } - static int GetNumCourseGroups( T* p, lua_State *L ) { lua_pushnumber( L, p->GetNumCourseGroups() ); return 1; } + static int GetNumSelectableAndUnlockedSongs( T* p, lua_State *L ) { lua_pushnumber( L, p->GetNumSelectableAndUnlockedSongs() ); return 1; } + static int GetNumAdditionalSongs( T* p, lua_State *L ) { lua_pushnumber( L, p->GetNumAdditionalSongs() ); return 1; } + static int GetNumSongGroups( T* p, lua_State *L ) { lua_pushnumber( L, p->GetNumSongGroups() ); return 1; } + static int GetNumCourses( T* p, lua_State *L ) { lua_pushnumber( L, p->GetNumCourses() ); return 1; } + static int GetNumCourseGroups( T* p, lua_State *L ) { lua_pushnumber( L, p->GetNumCourseGroups() ); return 1; } static int GetSongFromSteps( T* p, lua_State *L ) { Song *pSong = NULL; @@ -1758,6 +1774,7 @@ public: ADD_METHOD( GetRandomCourse ); ADD_METHOD( GetNumSongs ); ADD_METHOD( GetNumUnlockedSongs ); + ADD_METHOD( GetNumSelectableAndUnlockedSongs ); ADD_METHOD( GetNumAdditionalSongs ); ADD_METHOD( GetNumSongGroups ); ADD_METHOD( GetNumCourses ); diff --git a/stepmania/src/SongManager.h b/stepmania/src/SongManager.h index 666481e70e..e4e4327aec 100644 --- a/stepmania/src/SongManager.h +++ b/stepmania/src/SongManager.h @@ -87,6 +87,7 @@ public: Course *FindCourse( RString sGroup, RString sName ); int GetNumSongs() const; int GetNumUnlockedSongs() const; + int GetNumSelectableAndUnlockedSongs() const; int GetNumAdditionalSongs() const; int GetNumSongGroups() const; int GetNumCourses() const;