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