store hash value in Steps for finding equivalent edits

This commit is contained in:
Chris Danford
2004-04-23 00:53:29 +00:00
parent e7983033a4
commit 83fb83d1b4
6 changed files with 30 additions and 5 deletions
+7 -3
View File
@@ -31,6 +31,7 @@ Steps::Steps()
{
m_StepsType = STEPS_TYPE_INVALID;
m_LoadedFromProfile = PROFILE_SLOT_INVALID;
m_uHash = 0;
m_Difficulty = DIFFICULTY_INVALID;
m_iMeter = 0;
@@ -51,11 +52,13 @@ void Steps::SetNoteData( const NoteData* pNewNoteData )
DeAutogen();
delete notes_comp;
notes_comp = NULL;
delete notes;
notes = new NoteData(*pNewNoteData);
delete notes_comp;
notes_comp = new CompressedNoteData;
NoteDataUtil::GetSMNoteDataString( *notes, notes_comp->notes, notes_comp->attacks );
m_uHash = GetHashForString( notes_comp->notes );
}
void Steps::GetNoteData( NoteData* pNoteDataOut ) const
@@ -84,6 +87,7 @@ void Steps::SetSMNoteData( const CString &notes_comp_, const CString &attacks_co
notes_comp->notes = notes_comp_;
notes_comp->attacks = attacks_comp_;
m_uHash = GetHashForString( notes_comp->notes );
}
void Steps::GetSMNoteData( CString &notes_comp_out, CString &attacks_comp_out ) const
+2
View File
@@ -38,6 +38,7 @@ public:
bool IsAnEdit() const { return m_Difficulty == DIFFICULTY_EDIT; }
bool WasLoadedFromProfile() const { return m_LoadedFromProfile != PROFILE_SLOT_INVALID; }
ProfileSlot GetLoadedFromProfileSlot() const { return m_LoadedFromProfile; }
unsigned GetHash() const { return Real()->m_uHash; }
CString GetDescription() const { return Real()->m_sDescription; }
Difficulty GetDifficulty() const { return Real()->m_Difficulty; }
ProfileSlot GetLoadedFromProfile() const { return m_LoadedFromProfile; }
@@ -80,6 +81,7 @@ protected:
/* These values are pulled from the autogen source first, if there is one. */
ProfileSlot m_LoadedFromProfile; // PROFILE_SLOT_INVALID if wasn't loaded from a profile
unsigned m_uHash; // only used if m_Difficulty == DIFFICULTY_EDIT
CString m_sDescription; // Step author, edit name, or something meaningful
Difficulty m_Difficulty; // difficulty classification
int m_iMeter; // difficulty rating from MIN_METER to MAX_METER
+7 -1
View File
@@ -168,7 +168,10 @@ XNode* StepsID::CreateNode() const
pNode->AppendAttr( "StepsType", GameManager::NotesTypeToString(st) );
pNode->AppendAttr( "Difficulty", DifficultyToString(dc) );
if( dc == DIFFICULTY_EDIT )
{
pNode->AppendAttr( "Description", sDescription );
pNode->AppendAttr( "Hash", uHash );
}
return pNode;
}
@@ -186,7 +189,10 @@ void StepsID::LoadFromNode( const XNode* pNode )
dc = StringToDifficulty( sTemp );
if( dc == DIFFICULTY_EDIT )
pNode->GetChildValue("Description", sDescription);
{
pNode->GetAttrValue("Description", sDescription);
pNode->GetAttrValue("Hash", uHash);
}
}
bool StepsID::IsValid() const
+2 -1
View File
@@ -37,6 +37,7 @@ class StepsID
StepsType st;
Difficulty dc;
CString sDescription;
unsigned uHash;
public:
StepsID() { Unset(); }
@@ -45,7 +46,7 @@ public:
Steps *ToSteps( const Song *p, bool bAllowNull ) const;
bool operator<( const StepsID &other ) const
{
return st < other.st || dc < other.dc || sDescription < other.sDescription;
return st < other.st || dc < other.dc || sDescription < other.sDescription || uHash < other.uHash;
}
XNode* CreateNode() const;
+6
View File
@@ -886,6 +886,11 @@ LPXNode XNode::AppendChild( const char* name /*= NULL*/, int value /*= NULL*/ )
return AppendChild( name, ssprintf("%d",value) );
}
LPXNode XNode::AppendChild( const char* name /*= NULL*/, unsigned value /*= NULL*/ )
{
return AppendChild( name, ssprintf("%u",value) );
}
//========================================================
// Name : AppendChild
// Desc : add node
@@ -1046,6 +1051,7 @@ LPXAttr XNode::AppendAttr( const char* name /*= NULL*/, const char* value /*= NU
LPXAttr XNode::AppendAttr( const char* name, float value ){ return AppendAttr(name,ssprintf("%f",value)); }
LPXAttr XNode::AppendAttr( const char* name, int value ) { return AppendAttr(name,ssprintf("%d",value)); }
LPXAttr XNode::AppendAttr( const char* name, unsigned value ) { return AppendAttr(name,ssprintf("%u",value)); }
//========================================================
// Name : DetachChild
+6
View File
@@ -106,6 +106,7 @@ struct XAttr
void GetValue(int &out) const { out = atoi(value); }
void GetValue(float &out) const { out = (float) atof(value); }
void GetValue(bool &out) const { out = atoi(value) != 0; }
void GetValue(unsigned &out) const { sscanf(value,"%u",&out); }
XNode* parent;
@@ -123,6 +124,7 @@ struct XNode
void GetValue(int &out) const { out = atoi(value); }
void GetValue(float &out) const { out = (float) atof(value); }
void GetValue(bool &out) const { out = atoi(value) != 0; }
void GetValue(unsigned &out) const { out = (unsigned)atoi(value) != 0; }
// internal variables
LPXNode parent; // parent node
@@ -145,6 +147,7 @@ struct XNode
bool GetAttrValue(const char* name,int &out) const { const XAttr* pAttr=GetAttr(name); if(pAttr==NULL) return false; pAttr->GetValue(out); return true; }
bool GetAttrValue(const char* name,float &out) const { const XAttr* pAttr=GetAttr(name); if(pAttr==NULL) return false; pAttr->GetValue(out); return true; }
bool GetAttrValue(const char* name,bool &out) const { const XAttr* pAttr=GetAttr(name); if(pAttr==NULL) return false; pAttr->GetValue(out); return true; }
bool GetAttrValue(const char* name,unsigned &out) const { const XAttr* pAttr=GetAttr(name); if(pAttr==NULL) return false; pAttr->GetValue(out); return true; }
XAttrs GetAttrs( const char* name );
// in one level child nodes
@@ -155,6 +158,7 @@ struct XNode
bool GetChildValue(const char* name,int &out) const { const XNode* pChild=GetChild(name); if(pChild==NULL) return false; pChild->GetValue(out); return true; }
bool GetChildValue(const char* name,float &out) const { const XNode* pChild=GetChild(name); if(pChild==NULL) return false; pChild->GetValue(out); return true; }
bool GetChildValue(const char* name,bool &out) const { const XNode* pChild=GetChild(name); if(pChild==NULL) return false; pChild->GetValue(out); return true; }
bool GetChildValue(const char* name,unsigned &out) const{ const XNode* pChild=GetChild(name); if(pChild==NULL) return false; pChild->GetValue(out); return true; }
XNodes GetChilds( const char* name );
XNodes GetChilds();
@@ -169,6 +173,7 @@ struct XNode
LPXNode AppendChild( const char* name = NULL, const char* value = NULL );
LPXNode AppendChild( const char* name, float value );
LPXNode AppendChild( const char* name, int value );
LPXNode AppendChild( const char* name, unsigned value );
LPXNode AppendChild( LPXNode node );
bool RemoveChild( LPXNode node );
LPXNode DetachChild( LPXNode node );
@@ -180,6 +185,7 @@ struct XNode
LPXAttr AppendAttr( const char* name = NULL, const char* value = NULL );
LPXAttr AppendAttr( const char* name, float value );
LPXAttr AppendAttr( const char* name, int value );
LPXAttr AppendAttr( const char* name, unsigned value );
LPXAttr AppendAttr( LPXAttr attr );
bool RemoveAttr( LPXAttr attr );
LPXAttr DetachAttr( LPXAttr attr );