From 0f010d2321a20c14674ad777a7ae16d30eedec3e Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Mon, 3 Jan 2005 23:30:56 +0000 Subject: [PATCH] add Course::FindFixedSong, Attack::FromGlobalCourseModifier --- stepmania/src/Attack.cpp | 11 +++++++++++ stepmania/src/Attack.h | 1 + stepmania/src/Course.cpp | 12 ++++++++++++ stepmania/src/Course.h | 2 ++ stepmania/src/Trail.cpp | 11 +---------- 5 files changed, 27 insertions(+), 10 deletions(-) diff --git a/stepmania/src/Attack.cpp b/stepmania/src/Attack.cpp index f58b4b1787..5019b76fe5 100644 --- a/stepmania/src/Attack.cpp +++ b/stepmania/src/Attack.cpp @@ -54,6 +54,17 @@ bool Attack::ContainsTransformOrTurn() const return po.ContainsTransformOrTurn(); } +Attack Attack::FromGlobalCourseModifier( const CString &sModifiers ) +{ + Attack a; + a.fStartSecond = 0; + a.fSecsRemaining = 10000; /* whole song */ + a.level = ATTACK_LEVEL_1; + a.sModifier = sModifiers; + a.bGlobal = true; + return a; +} + bool AttackArray::ContainsTransformOrTurn() const { FOREACH_CONST( Attack, *this, a ) diff --git a/stepmania/src/Attack.h b/stepmania/src/Attack.h index e3bcb7f0fe..88b1aa7a48 100644 --- a/stepmania/src/Attack.h +++ b/stepmania/src/Attack.h @@ -37,6 +37,7 @@ struct Attack bool IsBlank() const { return sModifier.empty(); } bool operator== ( const Attack &rhs ) const; bool ContainsTransformOrTurn() const; + static Attack FromGlobalCourseModifier( const CString &sModifiers ); }; struct AttackArray : public vector diff --git a/stepmania/src/Course.cpp b/stepmania/src/Course.cpp index 22b0c7a861..1adb9f80f4 100644 --- a/stepmania/src/Course.cpp +++ b/stepmania/src/Course.cpp @@ -1106,6 +1106,18 @@ bool Course::IsRanking() const return false; } +const CourseEntry *Course::FindFixedSong( const Song *pSong ) const +{ + for( unsigned i = 0; i < m_entries.size(); ++i ) + { + const CourseEntry *pEntry = &m_entries[i]; + if( pEntry->type == COURSE_ENTRY_FIXED && pEntry->pSong == pSong ) + return pEntry; + } + + return NULL; +} + void Course::GetAllCachedTrails( vector &out ) { TrailCache_t::iterator it; diff --git a/stepmania/src/Course.h b/stepmania/src/Course.h index b2bf676750..adc56a4fff 100644 --- a/stepmania/src/Course.h +++ b/stepmania/src/Course.h @@ -151,6 +151,8 @@ public: void GetAllCachedTrails( vector &out ); + const CourseEntry *FindFixedSong( const Song *pSong ) const; + private: bool GetTrailUnsorted( StepsType st, CourseDifficulty cd, Trail &trail ) const; bool GetTrailSorted( StepsType st, CourseDifficulty cd, Trail &trail ) const; diff --git a/stepmania/src/Trail.cpp b/stepmania/src/Trail.cpp index 8b651ea1aa..9da631ddf1 100644 --- a/stepmania/src/Trail.cpp +++ b/stepmania/src/Trail.cpp @@ -10,16 +10,7 @@ void TrailEntry::GetAttackArray( AttackArray &out ) const { if( !Modifiers.empty() ) - { - Attack a; - a.fStartSecond = 0; - a.fSecsRemaining = 10000; /* whole song */ - a.level = ATTACK_LEVEL_1; - a.sModifier = Modifiers; - a.bGlobal = true; - - out.push_back( a ); - } + out.push_back( Attack::FromGlobalCourseModifier( Modifiers ) ); out.insert( out.end(), Attacks.begin(), Attacks.end() ); }