Added methods for writing/loading #GROOVESTATSHASH to cache. When calling Lua GetGrooveStatsHash(), calculate it if it's not already been calculated.

This commit is contained in:
Michael Votaw
2024-07-23 17:20:40 -05:00
committed by teejusb
parent 632f456ea0
commit 25a3979975
4 changed files with 20 additions and 3 deletions
+11 -1
View File
@@ -412,7 +412,6 @@ void SetNpsPerMeasure(StepsTagInfo& info)
{
if (info.from_cache || info.for_load_edit)
{
std::vector<RString> valuesPerPlayer;
split((*info.params)[1], "|", valuesPerPlayer, true);
@@ -504,6 +503,16 @@ void SetPeakNps(StepsTagInfo& info)
info.ssc_format= true;
}
void SetGrooveStatsHash(StepsTagInfo& info)
{
if (info.from_cache || info.for_load_edit)
{
RString value = (*info.params)[1];
info.steps->SetCachedGrooveStatsHash(value);
}
info.ssc_format = true;
}
void SetCredit(StepsTagInfo& info)
{
info.steps->SetCredit((*info.params)[1]);
@@ -748,6 +757,7 @@ struct ssc_parser_helper_t
steps_tag_handlers["NPSPERMEASURE"] = &SetNpsPerMeasure;
steps_tag_handlers["NOTESPERMEASURE"] = &SetNotesPerMeasure;
steps_tag_handlers["PEAKNPS"] = &SetPeakNps;
steps_tag_handlers["GROOVESTATSHASH"] = &SetGrooveStatsHash;
/* 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;
+4 -2
View File
@@ -429,6 +429,7 @@ static RString GetSSCNoteData( const Song &song, const Steps &in, bool bSavingCa
if (bSavingCache)
{
lines.push_back( ssprintf( "// step cache tags:" ) );
std::vector<RString> asTechCounts;
FOREACH_PlayerNumber( pn )
{
@@ -452,7 +453,6 @@ static RString GetSSCNoteData( const Song &song, const Steps &in, bool bSavingCa
{
npsPerMeasureStrings.push_back(serialize(npsPerMeasure, ",", 3));
}
lines.push_back( ssprintf( "#NPSPERMEASURE:%s;", join("|",npsPerMeasureStrings).c_str() ) );
const std::vector<std::vector<int>> &allNotesPerMeasures = in.GetAllNotesPerMeasures();
@@ -468,11 +468,13 @@ static RString GetSSCNoteData( const Song &song, const Steps &in, bool bSavingCa
const std::vector<float> &peakNps = in.GetAllPeakNps();
lines.push_back("#PEAKNPS:" + serialize(peakNps, "|", 3) + ";");
RString GrooveStatsHash = in.GetGrooveStatsHash();
lines.push_back(ssprintf("#GROOVESTATSHASH:%s;", GrooveStatsHash.c_str()));
// NOTE(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.
lines.push_back(ssprintf("#STEPFILENAME:%s;", in.GetFilename().c_str()));
lines.push_back( ssprintf( "// end step cache tags" ) );
}
+4
View File
@@ -1157,6 +1157,10 @@ public:
static int GetGrooveStatsHash(T *p, lua_State *L)
{
if(p->GetGrooveStatsHash().empty())
{
p->CalculateGrooveStatsHash();
}
lua_pushstring(L, p->GetGrooveStatsHash());
return 1;
}
+1
View File
@@ -155,6 +155,7 @@ public:
void SetCachedNpsPerMeasure(std::vector<std::vector<float>>& npsPerMeasure);
void SetCachedNotesPerMeasure(std::vector<std::vector<int>>& notesPerMeasure);
void SetPeakNps(std::vector<float>& peakNps);
void SetCachedGrooveStatsHash(const RString key);
float PredictMeter() const;
unsigned GetHash() const;