add GetNumSelectableAndUnlockedSongs, add GetMD5ForString

This commit is contained in:
Chris Danford
2006-05-16 00:47:02 +00:00
parent 787d1f214c
commit ede57d64ad
5 changed files with 43 additions and 12 deletions
+13 -1
View File
@@ -232,7 +232,7 @@ static RString BinaryToHex( const unsigned char *string, int iNumBytes )
return s; return s;
} }
RString CryptManager::GetMD5( RString fn ) RString CryptManager::GetMD5ForFile( RString fn )
{ {
struct MD5Context md5c; struct MD5Context md5c;
unsigned char digest[16]; unsigned char digest[16];
@@ -257,6 +257,18 @@ RString CryptManager::GetMD5( RString fn )
return BinaryToHex( digest, sizeof(digest) ); return BinaryToHex( digest, sizeof(digest) );
} }
RString CryptManager::GetMD5ForString( RString sData )
{
struct MD5Context md5c;
unsigned char digest[16];
MD5Init(&md5c);
MD5Update(&md5c, reinterpret_cast<const unsigned char*>(sData.c_str()), sData.size());
MD5Final(digest, &md5c);
return BinaryToHex( digest, sizeof(digest) );
}
RString CryptManager::GetPublicKeyFileName() RString CryptManager::GetPublicKeyFileName()
{ {
ASSERT( PREFSMAN->m_bSignProfileData ); ASSERT( PREFSMAN->m_bSignProfileData );
+2 -1
View File
@@ -19,7 +19,8 @@ public:
static RString Sign( RString sPath ); static RString Sign( RString sPath );
static bool Verify( RString sPath, RString sSignature ); 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(); static RString GetPublicKeyFileName();
}; };
+1 -1
View File
@@ -871,7 +871,7 @@ void ScreenEvaluation::Input( const InputEventPlus &input )
const HighScore &hs = STATSMAN->m_CurStageStats.m_player[pn].m_HighScore; const HighScore &hs = STATSMAN->m_CurStageStats.m_player[pn].m_HighScore;
Screenshot screenshot; Screenshot screenshot;
screenshot.sFileName = sFileName; screenshot.sFileName = sFileName;
screenshot.sMD5 = CRYPTMAN->GetMD5( sPath ); screenshot.sMD5 = CRYPTMAN->GetMD5ForFile( sPath );
screenshot.highScore = hs; screenshot.highScore = hs;
pProfile->AddScreenshot( screenshot ); pProfile->AddScreenshot( screenshot );
} }
+26 -9
View File
@@ -559,8 +559,23 @@ int SongManager::GetNumUnlockedSongs() const
int num = 0; int num = 0;
FOREACH_CONST( Song*, m_pSongs, i ) FOREACH_CONST( Song*, m_pSongs, i )
{ {
if( !UNLOCKMAN->SongIsLocked( *i ) ) if( UNLOCKMAN->SongIsLocked( *i ) )
num++; 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; 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 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 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 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 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 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 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 GetNumSelectableAndUnlockedSongs( T* p, lua_State *L ) { lua_pushnumber( L, p->GetNumSelectableAndUnlockedSongs() ); return 1; }
static int GetNumSongGroups( T* p, lua_State *L ) { lua_pushnumber( L, p->GetNumSongGroups() ); return 1; } static int GetNumAdditionalSongs( T* p, lua_State *L ) { lua_pushnumber( L, p->GetNumAdditionalSongs() ); return 1; }
static int GetNumCourses( T* p, lua_State *L ) { lua_pushnumber( L, p->GetNumCourses() ); return 1; } static int GetNumSongGroups( T* p, lua_State *L ) { lua_pushnumber( L, p->GetNumSongGroups() ); return 1; }
static int GetNumCourseGroups( T* p, lua_State *L ) { lua_pushnumber( L, p->GetNumCourseGroups() ); 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 ) static int GetSongFromSteps( T* p, lua_State *L )
{ {
Song *pSong = NULL; Song *pSong = NULL;
@@ -1758,6 +1774,7 @@ public:
ADD_METHOD( GetRandomCourse ); ADD_METHOD( GetRandomCourse );
ADD_METHOD( GetNumSongs ); ADD_METHOD( GetNumSongs );
ADD_METHOD( GetNumUnlockedSongs ); ADD_METHOD( GetNumUnlockedSongs );
ADD_METHOD( GetNumSelectableAndUnlockedSongs );
ADD_METHOD( GetNumAdditionalSongs ); ADD_METHOD( GetNumAdditionalSongs );
ADD_METHOD( GetNumSongGroups ); ADD_METHOD( GetNumSongGroups );
ADD_METHOD( GetNumCourses ); ADD_METHOD( GetNumCourses );
+1
View File
@@ -87,6 +87,7 @@ public:
Course *FindCourse( RString sGroup, RString sName ); Course *FindCourse( RString sGroup, RString sName );
int GetNumSongs() const; int GetNumSongs() const;
int GetNumUnlockedSongs() const; int GetNumUnlockedSongs() const;
int GetNumSelectableAndUnlockedSongs() const;
int GetNumAdditionalSongs() const; int GetNumAdditionalSongs() const;
int GetNumSongGroups() const; int GetNumSongGroups() const;
int GetNumCourses() const; int GetNumCourses() const;