diff --git a/src/NotesLoaderSSC.cpp b/src/NotesLoaderSSC.cpp index c257033130..8db68cc5d3 100644 --- a/src/NotesLoaderSSC.cpp +++ b/src/NotesLoaderSSC.cpp @@ -513,6 +513,17 @@ void SetGrooveStatsHash(StepsTagInfo& info) info.ssc_format = true; } +void SetGrooveStatsHashVersion(StepsTagInfo& info) +{ + if (info.from_cache || info.for_load_edit) + { + RString value = (*info.params)[1]; + int hashVersion = StringToInt(value); + info.steps->SetCachedGrooveStatsHashVersion(hashVersion); + } + info.ssc_format = true; +} + void SetCredit(StepsTagInfo& info) { info.steps->SetCredit((*info.params)[1]); @@ -758,6 +769,8 @@ struct ssc_parser_helper_t steps_tag_handlers["NOTESPERMEASURE"] = &SetNotesPerMeasure; steps_tag_handlers["PEAKNPS"] = &SetPeakNps; steps_tag_handlers["GROOVESTATSHASH"] = &SetGrooveStatsHash; + steps_tag_handlers["GROOVESTATSHASHVERSION"] = &SetGrooveStatsHashVersion; + /* If this is called, the chart does not use the same attacks * as the Song's timing. No other changes are required. */ steps_tag_handlers["ATTACKS"]= &SetStepsAttacks; diff --git a/src/NotesWriterSSC.cpp b/src/NotesWriterSSC.cpp index 808ff8e32c..048178cb67 100644 --- a/src/NotesWriterSSC.cpp +++ b/src/NotesWriterSSC.cpp @@ -470,8 +470,13 @@ static RString GetSSCNoteData( const Song &song, const Steps &in, bool bSavingCa RString GrooveStatsHash = in.GetGrooveStatsHash(); lines.push_back(ssprintf("#GROOVESTATSHASH:%s;", GrooveStatsHash.c_str())); + + int GrooveStatsHashVersion = in.GetGrooveStatsHashVersion(); + lines.push_back(ssprintf("#GROOVESTATSHASHVERSION:%d;", GrooveStatsHashVersion)); // NOTE(MV): #STEPFILENAME has to be at the end of the cache tags, + + // MV: #STEPFILENAME has to be at the end of the cache tags, // because it's used in SSCLoader::LoadFromSimfile to determine when // to switch the state back to GETTING_SONG_INFO, which means any tags // after it will be ignored. diff --git a/src/Steps.cpp b/src/Steps.cpp index a582c8adbd..dd96bfa52a 100644 --- a/src/Steps.cpp +++ b/src/Steps.cpp @@ -783,9 +783,16 @@ const RString Steps::GetGrooveStatsHash() const return GrooveStatsHash; } +int Steps::GetGrooveStatsHashVersion() const +{ + return GrooveStatsHashVersion; +} + void Steps::CalculateGrooveStatsHash(bool forceRecalculate) { - if (!forceRecalculate && m_bIsCachedGrooveStatsHashJustLoaded == true) + if (!forceRecalculate + && GrooveStatsHashVersion == CURRENT_GROOVE_STATS_HASH_VERSION + && m_bIsCachedGrooveStatsHashJustLoaded == true) { m_bIsCachedGrooveStatsHashJustLoaded = false; return; @@ -912,6 +919,10 @@ void Steps::SetCachedGrooveStatsHash(const RString key) m_bIsCachedGrooveStatsHashJustLoaded = true; } +void Steps::SetCachedGrooveStatsHashVersion(int version) +{ + GrooveStatsHashVersion = version; +} RString Steps::GenerateChartKey() { diff --git a/src/Steps.h b/src/Steps.h index 2c0de51616..535b306c1d 100644 --- a/src/Steps.h +++ b/src/Steps.h @@ -26,6 +26,12 @@ struct lua_State; */ const int MAX_STEPS_DESCRIPTION_LENGTH = 255; +/** + * @brief Current version of GrooveStats hash. + * Increment this to invalidate previously cached values + */ +const int CURRENT_GROOVE_STATS_HASH_VERSION = 3; + /** @brief The different ways of displaying the BPM. */ enum DisplayBPM { @@ -142,6 +148,7 @@ public: /** @brief Generates a hash used for GrooveStats integration. */ void CalculateGrooveStatsHash(bool forceRecalculate); const RString GetGrooveStatsHash() const; + int GetGrooveStatsHashVersion() const; /** @brief Produces a chart that's reduced to it's smallest unique representable form. */ RString MinimizedChartString(); @@ -156,6 +163,7 @@ public: void SetCachedNotesPerMeasure(std::vector>& notesPerMeasure); void SetPeakNps(std::vector& peakNps); void SetCachedGrooveStatsHash(const RString key); + void SetCachedGrooveStatsHashVersion(int version); float PredictMeter() const; unsigned GetHash() const; @@ -306,7 +314,8 @@ private: RString GrooveStatsHash; bool m_bIsCachedGrooveStatsHashJustLoaded; - + int GrooveStatsHashVersion = 0; + /** @brief The name of the person who created the Steps. */ RString m_sCredit; /** @brief The name of the chart. */