Cache NoteData inside Notes.
This commit is contained in:
+50
-6
@@ -32,7 +32,6 @@
|
||||
#define COLOR_CHALLENGE THEME->GetMetricC("Notes","ColorChallenge")
|
||||
#define COLOR_BATTLE THEME->GetMetricC("Notes","ColorBattle")
|
||||
|
||||
|
||||
Notes::Notes()
|
||||
{
|
||||
/* FIXME: should we init this to NOTES_TYPE_INVALID?
|
||||
@@ -50,32 +49,54 @@ Notes::Notes()
|
||||
m_iMaxCombo = 0;
|
||||
m_iTopScore = 0;
|
||||
m_TopGrade = GRADE_NO_DATA;
|
||||
notes = NULL;
|
||||
notes_comp = NULL;
|
||||
}
|
||||
|
||||
Notes::~Notes()
|
||||
{
|
||||
delete notes;
|
||||
delete notes_comp;
|
||||
}
|
||||
|
||||
void Notes::SetNoteData( NoteData* pNewNoteData )
|
||||
{
|
||||
ASSERT( pNewNoteData->m_iNumTracks == GameManager::NotesTypeToNumTracks(m_NotesType) );
|
||||
m_sSMNoteData = NoteDataUtil::GetSMNoteDataString(*pNewNoteData);
|
||||
|
||||
delete notes_comp;
|
||||
notes_comp = NULL;
|
||||
|
||||
delete notes;
|
||||
notes = new NoteData(*pNewNoteData);
|
||||
}
|
||||
|
||||
void Notes::GetNoteData( NoteData* pNoteDataOut ) const
|
||||
{
|
||||
pNoteDataOut->m_iNumTracks = GameManager::NotesTypeToNumTracks( m_NotesType );
|
||||
NoteDataUtil::LoadFromSMNoteDataString( *pNoteDataOut, m_sSMNoteData );
|
||||
Decompress();
|
||||
pNoteDataOut->m_iNumTracks = notes->m_iNumTracks;
|
||||
*pNoteDataOut = *notes;
|
||||
}
|
||||
|
||||
void Notes::SetSMNoteData( const CString &out )
|
||||
{
|
||||
m_sSMNoteData = out;
|
||||
delete notes;
|
||||
notes = NULL;
|
||||
|
||||
if(!notes_comp)
|
||||
notes_comp = new CString;
|
||||
|
||||
*notes_comp = out;
|
||||
}
|
||||
|
||||
CString Notes::GetSMNoteData() const
|
||||
{
|
||||
return m_sSMNoteData;
|
||||
if(!notes_comp)
|
||||
{
|
||||
if(!notes) return ""; /* no data is no data */
|
||||
notes_comp = new CString(NoteDataUtil::GetSMNoteDataString(*notes));
|
||||
}
|
||||
|
||||
return *notes_comp;
|
||||
}
|
||||
|
||||
// Color is a function of Difficulty and Intended Style
|
||||
@@ -208,3 +229,26 @@ void SortNotesArrayByDifficulty( CArray<Notes*,Notes*> &arraySteps )
|
||||
sort( arraySteps.begin(), arraySteps.end(), CompareNotesPointersByDifficulty );
|
||||
}
|
||||
|
||||
void Notes::Decompress() const
|
||||
{
|
||||
if(!notes_comp) return; /* no data is no data */
|
||||
if(notes) return;
|
||||
|
||||
notes = new NoteData;
|
||||
notes->m_iNumTracks = GameManager::NotesTypeToNumTracks(m_NotesType);
|
||||
|
||||
NoteDataUtil::LoadFromSMNoteDataString(*notes, *notes_comp);
|
||||
}
|
||||
|
||||
void Notes::Compress() const
|
||||
{
|
||||
if(!notes_comp)
|
||||
{
|
||||
if(!notes) return; /* no data is no data */
|
||||
notes_comp = new CString(NoteDataUtil::GetSMNoteDataString(*notes));
|
||||
}
|
||||
|
||||
delete notes;
|
||||
notes = NULL;
|
||||
}
|
||||
|
||||
|
||||
@@ -36,7 +36,16 @@ public:
|
||||
// Loading
|
||||
bool LoadFromNotesFile( const CString &sPath );
|
||||
|
||||
/* We can have one or both of these; if we have both, they're always identical.
|
||||
* Call Compress() to force us to only have notes_comp; otherwise, creation of
|
||||
* these is transparent. */
|
||||
mutable NoteData *notes;
|
||||
mutable CString *notes_comp;
|
||||
void Decompress() const;
|
||||
|
||||
public:
|
||||
void Compress() const;
|
||||
|
||||
NotesType m_NotesType;
|
||||
CString m_sDescription; // This text is displayed next to thte number of feet when a song is selected
|
||||
bool m_bAutoGen; // Was created by autogen?
|
||||
@@ -44,7 +53,6 @@ public:
|
||||
int m_iMeter; // difficulty rating from 1-10
|
||||
float m_fRadarValues[NUM_RADAR_VALUES]; // between 0.0-1.2 starting from 12-o'clock rotating clockwise
|
||||
|
||||
CString m_sSMNoteData;
|
||||
void GetNoteData( NoteData* pNoteDataOut ) const;
|
||||
void SetNoteData( NoteData* pNewNoteData );
|
||||
void SetSMNoteData( const CString &out );
|
||||
|
||||
Reference in New Issue
Block a user