diff --git a/stepmania/src/Trail.cpp b/stepmania/src/Trail.cpp index cdfdba6bdb..f7a528f050 100644 --- a/stepmania/src/Trail.cpp +++ b/stepmania/src/Trail.cpp @@ -46,17 +46,18 @@ void Trail::SetRadarValues( const RadarValues &rv ) m_bRadarValuesCached = true; } -RadarValues Trail::GetRadarValues() const +const RadarValues &Trail::GetRadarValues() const { + if( m_bRadarValuesCached ) + { + return m_CachedRadarValues; + } if( IsSecret() ) { // Don't calculate RadarValues for a non-fixed Course. They values are // worthless because they'll change every time this Trail is // regenerated. - return RadarValues(); - } - else if( m_bRadarValuesCached ) - { + m_CachedRadarValues = RadarValues(); return m_CachedRadarValues; } else @@ -193,11 +194,18 @@ public: static int GetCourseDifficulty( T* p, lua_State *L ) { lua_pushnumber(L, p->m_CourseDifficulty ); return 1; } static int GetStepsType( T* p, lua_State *L ) { lua_pushnumber(L, p->m_StepsType ); return 1; } + static int GetRadarValues( T* p, lua_State *L ) + { + RadarValues &rv = const_cast(p->GetRadarValues()); + rv.PushSelf(L); + return 1; + } static void Register(lua_State *L) { ADD_METHOD( GetCourseDifficulty ); ADD_METHOD( GetStepsType ); + ADD_METHOD( GetRadarValues ); Luna::Register( L ); } diff --git a/stepmania/src/Trail.h b/stepmania/src/Trail.h index 4d809c2f0f..2c2daaeff5 100644 --- a/stepmania/src/Trail.h +++ b/stepmania/src/Trail.h @@ -63,7 +63,7 @@ public: m_bRadarValuesCached = false; } - RadarValues GetRadarValues() const; + const RadarValues &GetRadarValues() const; void SetRadarValues( const RadarValues &rv ); // for pre-populating cache int GetMeter() const; int GetTotalMeter() const;