Code -> UnlockEntryID

UnlockedSongs -> UnlockedEntryIDs
UnlockIndex -> UnlockEntryID
This commit is contained in:
Chris Danford
2006-01-28 22:08:16 +00:00
parent bbf22a9647
commit c52ab6fa5e
6 changed files with 48 additions and 48 deletions
+4 -4
View File
@@ -44,7 +44,7 @@ void GameCommand::Init()
m_pTrail = NULL;
m_pCharacter = NULL;
m_SortOrder = SORT_INVALID;
m_iUnlockIndex = -1;
m_iUnlockEntryID = -1;
m_sSoundPath = "";
m_vsScreensToPrepare.clear();
m_iWeightPounds = -1;
@@ -336,7 +336,7 @@ void GameCommand::LoadOne( const Command& cmd )
else if( sName == "unlock" )
{
m_iUnlockIndex = atoi( sValue );
m_iUnlockEntryID = atoi( sValue );
}
else if( sName == "sound" )
@@ -687,8 +687,8 @@ void GameCommand::ApplySelf( const vector<PlayerNumber> &vpns ) const
GAMESTATE->m_sPreferredSongGroup.Set( m_sSongGroup );
if( m_SortOrder != SORT_INVALID )
GAMESTATE->m_PreferredSortOrder = m_SortOrder;
if( m_iUnlockIndex != -1 )
UNLOCKMAN->UnlockCode( m_iUnlockIndex );
if( m_iUnlockEntryID != -1 )
UNLOCKMAN->UnlockEntryID( m_iUnlockEntryID );
if( m_sSoundPath != "" )
SOUND->PlayOnce( THEME->GetPathS( "", m_sSoundPath ) );
if( m_iWeightPounds != -1 )
+1 -1
View File
@@ -71,7 +71,7 @@ public:
std::map<RString,RString> m_SetEnv;
RString m_sSongGroup;
SortOrder m_SortOrder;
int m_iUnlockIndex; // -1 for no unlock
int m_iUnlockEntryID; // -1 for no unlock
RString m_sSoundPath; // "" for no sound
vector<RString> m_vsScreensToPrepare;
int m_iWeightPounds; // -1 == none specified
+4 -4
View File
@@ -114,7 +114,7 @@ void Profile::InitGeneralData()
m_iNumExtraStagesPassed = 0;
m_iNumExtraStagesFailed = 0;
m_iNumToasties = 0;
m_UnlockedSongs.clear();
m_UnlockedEntryIDs.clear();
m_sLastPlayedMachineGuid = "";
m_LastPlayedDate.Init();
m_iTotalTapsAndHolds = 0;
@@ -534,7 +534,7 @@ void Profile::SetDefaultModifiers( const Game* pGameType, const RString &sModifi
bool Profile::IsCodeUnlocked( int iCode ) const
{
return m_UnlockedSongs.find( iCode ) != m_UnlockedSongs.end();
return m_UnlockedEntryIDs.find( iCode ) != m_UnlockedEntryIDs.end();
}
@@ -1050,7 +1050,7 @@ XNode* Profile::SaveGeneralDataCreateNode() const
{
XNode* pUnlockedSongs = pGeneralDataNode->AppendChild("UnlockedSongs");
FOREACHS_CONST( int, m_UnlockedSongs, it )
FOREACHS_CONST( int, m_UnlockedEntryIDs, it )
pUnlockedSongs->AppendChild( ssprintf("Unlock%i", *it) );
}
@@ -1235,7 +1235,7 @@ void Profile::LoadGeneralDataFromNode( const XNode* pNode )
{
int iUnlock;
if( sscanf(song->m_sName.c_str(),"Unlock%d",&iUnlock) == 1 )
m_UnlockedSongs.insert( iUnlock );
m_UnlockedEntryIDs.insert( iUnlock );
}
}
}
+1 -1
View File
@@ -132,7 +132,7 @@ public:
int m_iTotalRolls;
int m_iTotalMines;
int m_iTotalHands;
set<int> m_UnlockedSongs;
set<int> m_UnlockedEntryIDs;
mutable RString m_sLastPlayedMachineGuid; // mutable because we overwrite this on save, and I don't want to remove const from the whole save chain. -Chris
mutable DateTime m_LastPlayedDate;
/* These stats count twice in the machine profile if two players are playing;
+30 -30
View File
@@ -44,13 +44,13 @@ void UnlockManager::UnlockSong( const Song *song )
const UnlockEntry *p = FindSong( song );
if( !p )
return; // does not exist
if( p->m_iCode == -1 )
if( p->m_iEntryID == -1 )
return;
UnlockCode( p->m_iCode );
UnlockEntryID( p->m_iEntryID );
}
int UnlockManager::FindCode( const RString &sName ) const
int UnlockManager::FindEntryID( const RString &sName ) const
{
const UnlockEntry *pEntry = NULL;
@@ -71,7 +71,7 @@ int UnlockManager::FindCode( const RString &sName ) const
return -1;
}
return pEntry->m_iCode;
return pEntry->m_iEntryID;
}
bool UnlockManager::CourseIsLocked( const Course *course ) const
@@ -109,7 +109,7 @@ bool UnlockManager::SongIsRouletteOnly( const Song *song ) const
return false;
/* If the song is locked by a code, and it's a roulette code, honor IsLocked. */
if( p->m_iCode == -1 || m_RouletteCodes.find( p->m_iCode ) == m_RouletteCodes.end() )
if( p->m_iEntryID == -1 || m_RouletteCodes.find( p->m_iEntryID ) == m_RouletteCodes.end() )
return false;
return p->IsLocked();
@@ -285,7 +285,7 @@ bool UnlockEntry::IsLocked() const
if( m_fRequired[i] && fScores[i] >= m_fRequired[i] )
return false;
if( m_iCode != -1 && PROFILEMAN->GetMachineProfile()->m_UnlockedSongs.find(m_iCode) != PROFILEMAN->GetMachineProfile()->m_UnlockedSongs.end() )
if( m_iEntryID != -1 && PROFILEMAN->GetMachineProfile()->m_UnlockedEntryIDs.find(m_iEntryID) != PROFILEMAN->GetMachineProfile()->m_UnlockedEntryIDs.end() )
return false;
return true;
@@ -341,7 +341,7 @@ void UnlockManager::Load()
// Hack: Lua only has a floating point type, and codes may be big enough
// that converting them from string to float to int introduces rounding
// error. Convert directly to int.
current.m_iCode = atoi( (RString) cmd.GetArg(1) );
current.m_iEntryID = atoi( (RString) cmd.GetArg(1) );
}
else if( sName == "roulette" )
{
@@ -356,7 +356,7 @@ void UnlockManager::Load()
}
if( bRoulette )
m_RouletteCodes.insert( current.m_iCode );
m_RouletteCodes.insert( current.m_iEntryID );
m_UnlockEntries.push_back( current );
}
@@ -370,7 +370,7 @@ void UnlockManager::Load()
if( e->m_fRequired[j] )
str += ssprintf( "%s = %f; ", UnlockTriggerToString(j).c_str(), e->m_fRequired[j] );
str += ssprintf( "code = %i ", e->m_iCode );
str += ssprintf( "entryID = %i ", e->m_iEntryID );
str += e->IsLocked()? "locked":"unlocked";
if( e->m_pSong )
str += ( " (found song)" );
@@ -442,21 +442,21 @@ void UnlockManager::UpdateCachedPointers()
void UnlockManager::UnlockCode( int num )
void UnlockManager::UnlockEntryID( int iEntryID )
{
FOREACH_PlayerNumber( pn )
if( PROFILEMAN->IsPersistentProfile(pn) )
PROFILEMAN->GetProfile(pn)->m_UnlockedSongs.insert( num );
PROFILEMAN->GetProfile(pn)->m_UnlockedEntryIDs.insert( iEntryID );
PROFILEMAN->GetMachineProfile()->m_UnlockedSongs.insert( num );
PROFILEMAN->GetMachineProfile()->m_UnlockedEntryIDs.insert( iEntryID );
}
void UnlockManager::PreferUnlockCode( int iCode )
void UnlockManager::PreferUnlockEntryID( int iUnlockEntryID )
{
for( unsigned i = 0; i < m_UnlockEntries.size(); ++i )
{
UnlockEntry &pEntry = m_UnlockEntries[i];
if( pEntry.m_iCode != iCode )
if( pEntry.m_iEntryID != iUnlockEntryID )
continue;
if( pEntry.m_pSong != NULL )
@@ -478,24 +478,24 @@ void UnlockManager::GetUnlocksByType( UnlockEntry::Type t, vector<UnlockEntry *>
apEntries.push_back( &m_UnlockEntries[i] );
}
void UnlockManager::GetSongsUnlockedByCode( vector<Song *> &apSongsOut, int iCode )
void UnlockManager::GetSongsUnlockedByEntryID( vector<Song *> &apSongsOut, int iUnlockEntryID )
{
vector<UnlockEntry *> apEntries;
GetUnlocksByType( UnlockEntry::TYPE_SONG, apEntries );
for( unsigned i = 0; i < apEntries.size(); ++i )
if( apEntries[i]->m_iCode == iCode )
if( apEntries[i]->m_iEntryID == iUnlockEntryID )
apSongsOut.push_back( apEntries[i]->m_pSong );
}
void UnlockManager::GetStepsUnlockedByCode( vector<Song *> &apSongsOut, vector<Difficulty> &apDifficultyOut, int iCode )
void UnlockManager::GetStepsUnlockedByEntryID( vector<Song *> &apSongsOut, vector<Difficulty> &apDifficultyOut, int iUnlockEntryID )
{
vector<UnlockEntry *> apEntries;
GetUnlocksByType( UnlockEntry::TYPE_STEPS, apEntries );
for( unsigned i = 0; i < apEntries.size(); ++i )
{
if( apEntries[i]->m_iCode == iCode )
if( apEntries[i]->m_iEntryID == iUnlockEntryID )
{
apSongsOut.push_back( apEntries[i]->m_pSong );
apDifficultyOut.push_back( apEntries[i]->m_dc );
@@ -510,24 +510,24 @@ class LunaUnlockManager: public Luna<UnlockManager>
public:
LunaUnlockManager() { LUA->Register( Register ); }
static int FindCode( T* p, lua_State *L ) { RString sName = SArg(1); int i = p->FindCode(sName); if( i == -1 ) lua_pushnil(L); else lua_pushnumber(L, i); return 1; }
static int UnlockCode( T* p, lua_State *L ) { int iCode = IArg(1); p->UnlockCode(iCode); return 0; }
static int PreferUnlockCode( T* p, lua_State *L ) { int iCode = IArg(1); p->PreferUnlockCode(iCode); return 0; }
static int FindEntryID( T* p, lua_State *L ) { RString sName = SArg(1); int i = p->FindEntryID(sName); if( i == -1 ) lua_pushnil(L); else lua_pushnumber(L, i); return 1; }
static int UnlockEntryID( T* p, lua_State *L ) { int iUnlockEntryID = IArg(1); p->UnlockEntryID(iUnlockEntryID); return 0; }
static int PreferUnlockEntryID( T* p, lua_State *L ) { int iUnlockEntryID = IArg(1); p->PreferUnlockEntryID(iUnlockEntryID); return 0; }
static int GetNumUnlocks( T* p, lua_State *L ) { lua_pushnumber( L, p->GetNumUnlocks() ); return 1; }
static int GetSongsUnlockedByCode( T* p, lua_State *L )
static int GetSongsUnlockedByEntryID( T* p, lua_State *L )
{
vector<Song *> apSongs;
UNLOCKMAN->GetSongsUnlockedByCode( apSongs, IArg(1) );
UNLOCKMAN->GetSongsUnlockedByEntryID( apSongs, IArg(1) );
LuaHelpers::CreateTableFromArray( apSongs, L );
return 1;
}
static int GetStepsUnlockedByCode( T* p, lua_State *L )
static int GetStepsUnlockedByEntryID( T* p, lua_State *L )
{
// Return the song each steps are associated with, too.
vector<Song *> apSongs;
vector<Difficulty> apDifficulty;
UNLOCKMAN->GetStepsUnlockedByCode( apSongs, apDifficulty, IArg(1) );
UNLOCKMAN->GetStepsUnlockedByEntryID( apSongs, apDifficulty, IArg(1) );
LuaHelpers::CreateTableFromArray( apSongs, L );
LuaHelpers::CreateTableFromArray( apDifficulty, L );
return 2;
@@ -535,12 +535,12 @@ public:
static void Register(lua_State *L)
{
ADD_METHOD( FindCode );
ADD_METHOD( UnlockCode );
ADD_METHOD( PreferUnlockCode );
ADD_METHOD( FindEntryID );
ADD_METHOD( UnlockEntryID );
ADD_METHOD( PreferUnlockEntryID );
ADD_METHOD( GetNumUnlocks );
ADD_METHOD( GetSongsUnlockedByCode );
ADD_METHOD( GetStepsUnlockedByCode );
ADD_METHOD( GetSongsUnlockedByEntryID );
ADD_METHOD( GetStepsUnlockedByEntryID );
Luna<T>::Register( L );
+8 -8
View File
@@ -39,7 +39,7 @@ struct UnlockEntry
m_pCourse = NULL;
ZERO( m_fRequired );
m_iCode = -1;
m_iEntryID = -1;
}
enum Type {
@@ -60,7 +60,7 @@ struct UnlockEntry
Course *m_pCourse;
float m_fRequired[NUM_UnlockTrigger];
int m_iCode;
int m_iEntryID;
bool IsValid() const;
bool IsLocked() const;
@@ -92,19 +92,19 @@ public:
void GetPoints( const Profile *pProfile, float fScores[NUM_UnlockTrigger] ) const;
// Unlock an entry by code.
void UnlockCode( int num );
void UnlockEntryID( int iEntryID );
/*
* If a code is associated with at least one song or course, set the preferred song
* and/or course in GAMESTATE to them.
*/
void PreferUnlockCode( int iCode );
void PreferUnlockEntryID( int iEntryID );
// Unlocks a song.
void UnlockSong( const Song *song );
// Return the associated code.
int FindCode( const RString &sName ) const;
// Return the associated EntryID.
int FindEntryID( const RString &sName ) const;
// All locked songs are stored here
vector<UnlockEntry> m_UnlockEntries;
@@ -113,8 +113,8 @@ public:
void UpdateCachedPointers();
void GetUnlocksByType( UnlockEntry::Type t, vector<UnlockEntry *> &apEntries );
void GetSongsUnlockedByCode( vector<Song *> &apSongsOut, int iCode );
void GetStepsUnlockedByCode( vector<Song *> &apSongsOut, vector<Difficulty> &apStepsOut, int iCode );
void GetSongsUnlockedByEntryID( vector<Song *> &apSongsOut, int iEntryID );
void GetStepsUnlockedByEntryID( vector<Song *> &apSongsOut, vector<Difficulty> &apStepsOut, int iEntryID );
// Lua
void PushSelf( lua_State *L );