CachedObjectPointer<Course>, CachedObjectPointer<Trail>
This commit is contained in:
@@ -21,6 +21,8 @@
|
||||
|
||||
static Preference<int> MAX_SONGS_IN_EDIT_COURSE( "MaxSongsInEditCourse", -1 );
|
||||
|
||||
CACHED_REGISTER_CLASS(Course);
|
||||
|
||||
static const char *CourseTypeNames[] = {
|
||||
"Nonstop",
|
||||
"Oni",
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include "EnumHelper.h"
|
||||
#include "Trail.h"
|
||||
#include "RageTypes.h"
|
||||
#include "RageUtil_CachedObject.h"
|
||||
#include "SongUtil.h"
|
||||
#include "StepsUtil.h"
|
||||
#include <map>
|
||||
@@ -216,6 +217,8 @@ public:
|
||||
|
||||
/* Preferred styles: */
|
||||
set<RString> m_setStyles;
|
||||
|
||||
CachedObject<Course> m_CachedObject;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -345,6 +345,8 @@ void CourseID::FromCourse( const Course *p )
|
||||
// Strip off leading "/". 2005/05/21 file layer changes added a leading slash.
|
||||
if( sPath.Left(1) == "/" )
|
||||
sPath.erase( sPath.begin() );
|
||||
|
||||
m_Cache.Unset();
|
||||
}
|
||||
|
||||
Course *CourseID::ToCourse() const
|
||||
@@ -355,21 +357,17 @@ Course *CourseID::ToCourse() const
|
||||
if( sPath2.Left(1) != "/" )
|
||||
sPath2 = "/" + sPath2;
|
||||
|
||||
if( !sPath2.empty() )
|
||||
{
|
||||
Course *pCourse = SONGMAN->GetCourseFromPath( sPath2 );
|
||||
if( pCourse )
|
||||
return pCourse;
|
||||
}
|
||||
Course *pCourse = NULL;
|
||||
if( m_Cache.Get(&pCourse) )
|
||||
return pCourse;
|
||||
if( pCourse == NULL && !sPath2.empty() )
|
||||
pCourse = SONGMAN->GetCourseFromPath( sPath2 );
|
||||
|
||||
if( !sFullTitle.empty() )
|
||||
{
|
||||
Course *pCourse = SONGMAN->GetCourseFromName( sFullTitle );
|
||||
if( pCourse )
|
||||
return pCourse;
|
||||
}
|
||||
if( pCourse == NULL && !sFullTitle.empty() )
|
||||
pCourse = SONGMAN->GetCourseFromName( sFullTitle );
|
||||
m_Cache.Set( pCourse );
|
||||
|
||||
return NULL;
|
||||
return pCourse;
|
||||
}
|
||||
|
||||
XNode* CourseID::CreateNode() const
|
||||
@@ -391,6 +389,7 @@ void CourseID::LoadFromNode( const XNode* pNode )
|
||||
sPath = RString();
|
||||
if( !pNode->GetAttrValue("Path", sPath) )
|
||||
pNode->GetAttrValue( "FullTitle", sFullTitle );
|
||||
m_Cache.Unset();
|
||||
}
|
||||
|
||||
RString CourseID::ToString() const
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
|
||||
#include "GameConstantsAndTypes.h"
|
||||
#include "Difficulty.h"
|
||||
#include "RageUtil_CachedObject.h"
|
||||
|
||||
class Course;
|
||||
class Profile;
|
||||
@@ -58,6 +59,7 @@ public:
|
||||
private:
|
||||
RString sPath;
|
||||
RString sFullTitle;
|
||||
mutable CachedObjectPointer<Course> m_Cache;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -8,6 +8,8 @@
|
||||
#include "NoteDataUtil.h"
|
||||
#include "CommonMetrics.h"
|
||||
|
||||
CACHED_REGISTER_CLASS(Trail);
|
||||
|
||||
void TrailEntry::GetAttackArray( AttackArray &out ) const
|
||||
{
|
||||
if( !Modifiers.empty() )
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include "Attack.h"
|
||||
#include "RadarValues.h"
|
||||
#include "Difficulty.h"
|
||||
#include "RageUtil_CachedObject.h"
|
||||
|
||||
class Song;
|
||||
class Steps;
|
||||
@@ -72,6 +73,8 @@ public:
|
||||
bool IsSecret() const;
|
||||
bool ContainsSong( const Song *pSong ) const;
|
||||
|
||||
CachedObject<Trail> m_CachedObject;
|
||||
|
||||
// Lua
|
||||
void PushSelf( lua_State *L );
|
||||
};
|
||||
|
||||
@@ -18,6 +18,7 @@ void TrailID::FromTrail( const Trail *p )
|
||||
st = p->m_StepsType;
|
||||
cd = p->m_CourseDifficulty;
|
||||
}
|
||||
m_Cache.Unset();
|
||||
}
|
||||
|
||||
Trail *TrailID::ToTrail( const Course *p, bool bAllowNull ) const
|
||||
@@ -25,8 +26,13 @@ Trail *TrailID::ToTrail( const Course *p, bool bAllowNull ) const
|
||||
ASSERT( p );
|
||||
|
||||
Trail *pRet = NULL;
|
||||
if( st != StepsType_Invalid && cd != Difficulty_Invalid )
|
||||
pRet = p->GetTrail( st, cd );
|
||||
if( !m_Cache.Get(&pRet) )
|
||||
{
|
||||
if( st != StepsType_Invalid && cd != Difficulty_Invalid )
|
||||
pRet = p->GetTrail( st, cd );
|
||||
m_Cache.Set( pRet );
|
||||
}
|
||||
|
||||
if( !bAllowNull && pRet == NULL )
|
||||
RageException::Throw( "%i, %i, \"%s\"", st, cd, p->GetDisplayFullTitle().c_str() );
|
||||
|
||||
@@ -54,6 +60,7 @@ void TrailID::LoadFromNode( const XNode* pNode )
|
||||
|
||||
pNode->GetAttrValue( "CourseDifficulty", sTemp );
|
||||
cd = StringToDifficulty( sTemp );
|
||||
m_Cache.Unset();
|
||||
}
|
||||
|
||||
RString TrailID::ToString() const
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
#include "GameConstantsAndTypes.h"
|
||||
#include "Difficulty.h"
|
||||
#include "RageUtil_CachedObject.h"
|
||||
|
||||
class Song;
|
||||
class Trail;
|
||||
@@ -13,6 +14,7 @@ class TrailID
|
||||
{
|
||||
StepsType st;
|
||||
CourseDifficulty cd;
|
||||
mutable CachedObjectPointer<Trail> m_Cache;
|
||||
|
||||
public:
|
||||
TrailID() { Unset(); }
|
||||
|
||||
Reference in New Issue
Block a user