From 9aead72d034372c97695a261593699beebff1e53 Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Wed, 15 Aug 2007 21:01:23 +0000 Subject: [PATCH] CourseID --- stepmania/src/ScreenUnlockStatus.cpp | 2 +- stepmania/src/SongManager.cpp | 4 ++-- stepmania/src/UnlockManager.cpp | 18 +++++++++--------- stepmania/src/UnlockManager.h | 4 ++-- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/stepmania/src/ScreenUnlockStatus.cpp b/stepmania/src/ScreenUnlockStatus.cpp index ec1de4bbae..c09af41ffb 100644 --- a/stepmania/src/ScreenUnlockStatus.cpp +++ b/stepmania/src/ScreenUnlockStatus.cpp @@ -117,7 +117,7 @@ void ScreenUnlockStatus::Init() break; case UnlockRewardType_Course: { - const Course *pCourse = entry.m_pCourse; + const Course *pCourse = entry.m_Course.ToCourse(); ASSERT( pCourse ); text->SetMaxWidth( MaxWidth ); diff --git a/stepmania/src/SongManager.cpp b/stepmania/src/SongManager.cpp index e547382694..65e34389c6 100644 --- a/stepmania/src/SongManager.cpp +++ b/stepmania/src/SongManager.cpp @@ -1452,8 +1452,8 @@ void SongManager::UpdatePreferredSort() FOREACH( UnlockEntry, UNLOCKMAN->m_UnlockEntries, ue ) { if( ue->m_Type == UnlockRewardType_Course ) - if( ue->m_pCourse ) - vpUnlockCourses.push_back( ue->m_pCourse ); + if( ue->m_Course.IsValid() ) + vpUnlockCourses.push_back( ue->m_Course.ToCourse() ); } FOREACH( CoursePointerVector, m_vPreferredCourseSort, v ) diff --git a/stepmania/src/UnlockManager.cpp b/stepmania/src/UnlockManager.cpp index 5174606062..35110e9cb3 100644 --- a/stepmania/src/UnlockManager.cpp +++ b/stepmania/src/UnlockManager.cpp @@ -210,7 +210,7 @@ const UnlockEntry *UnlockManager::FindSteps( const Song *pSong, const Steps *pSt const UnlockEntry *UnlockManager::FindCourse( const Course *pCourse ) const { FOREACH_CONST( UnlockEntry, m_UnlockEntries, e ) - if( e->m_pCourse == pCourse ) + if( e->m_Course.ToCourse() == pCourse ) return &(*e); return NULL; } @@ -316,7 +316,7 @@ bool UnlockEntry::IsValid() const return m_Song.IsValid() && m_dc != Difficulty_Invalid; case UnlockRewardType_Course: - return m_pCourse != NULL; + return m_Course.IsValid(); case UnlockRewardType_Modifier: return true; @@ -371,7 +371,7 @@ RString UnlockEntry::GetDescription() const case UnlockRewardType_Steps: return (pSong ? pSong->GetDisplayFullTitle() : "") + ", " + DifficultyToLocalizedString( m_dc ); case UnlockRewardType_Course: - return m_pCourse ? m_pCourse->GetDisplayFullTitle() : ""; + return m_Course.IsValid() ? m_Course.ToCourse()->GetDisplayFullTitle() : ""; case UnlockRewardType_Modifier: return CommonMetrics::LocalizeOptionItem( GetModifier(), false ); } @@ -389,7 +389,7 @@ RString UnlockEntry::GetBannerFile() const case UnlockRewardType_Steps: return pSong ? pSong->GetBannerPath() : ""; case UnlockRewardType_Course: - return m_pCourse ? m_pCourse->GetBannerPath() : ""; + return m_Course.ToCourse() ? m_Course.ToCourse()->GetBannerPath() : ""; case UnlockRewardType_Modifier: return ""; } @@ -499,7 +499,7 @@ void UnlockManager::Load() str += e->IsLocked()? "locked":"unlocked"; if( e->m_Song.IsValid() ) str += ( " (found song)" ); - if( e->m_pCourse ) + if( e->m_Course.IsValid() ) str += ( " (found course)" ); LOG->Trace( "%s", str.c_str() ); } @@ -563,8 +563,8 @@ void UnlockManager::UpdateCachedPointers() break; case UnlockRewardType_Course: - e->m_pCourse = SONGMAN->FindCourse( e->m_cmd.GetArg(0).s ); - if( e->m_pCourse == NULL ) + e->m_Course.FromCourse( SONGMAN->FindCourse(e->m_cmd.GetArg(0).s) ); + if( !e->m_Course.IsValid() ) LOG->Warn( "Unlock: Cannot find course matching \"%s\"", e->m_cmd.GetArg(0).s.c_str() ); break; case UnlockRewardType_Modifier: @@ -600,8 +600,8 @@ void UnlockManager::PreferUnlockEntryID( RString sUnlockEntryID ) if( pEntry.m_Song.ToSong() != NULL ) GAMESTATE->m_pPreferredSong = pEntry.m_Song.ToSong(); - if( pEntry.m_pCourse != NULL ) - GAMESTATE->m_pPreferredCourse = pEntry.m_pCourse; + if( pEntry.m_Course.ToCourse() ) + GAMESTATE->m_pPreferredCourse = pEntry.m_Course.ToCourse(); } } diff --git a/stepmania/src/UnlockManager.h b/stepmania/src/UnlockManager.h index 0604a5516c..cdd41d9aed 100644 --- a/stepmania/src/UnlockManager.h +++ b/stepmania/src/UnlockManager.h @@ -8,6 +8,7 @@ #include #include "Difficulty.h" #include "SongUtil.h" +#include "CourseUtil.h" class Song; class Course; @@ -56,7 +57,6 @@ public: m_Type = UnlockRewardType_Invalid; m_dc = Difficulty_Invalid; - m_pCourse = NULL; ZERO( m_fRequirement ); m_bRequirePassHardSteps = false; @@ -71,7 +71,7 @@ public: * these will be non-NULL. */ SongID m_Song; Difficulty m_dc; - Course *m_pCourse; + CourseID m_Course; float m_fRequirement[NUM_UnlockRequirement]; // unlocked if any of of these are met bool m_bRequirePassHardSteps;