We don't need to set cached nps per player individually, just parse all of it and pass it to Steps

This commit is contained in:
Michael Votaw
2025-03-03 21:24:17 -08:00
committed by teejusb
parent 2625394ac0
commit c0db6beb9c
3 changed files with 20 additions and 22 deletions
+7 -3
View File
@@ -421,18 +421,20 @@ void SetNpsPerMeasure(StepsTagInfo& info)
LOG->Warn("#NPSPERMEASURE has more sections (%zu) than possible number of players (%d)!", valuesPerPlayer.size(), NUM_PlayerNumber); LOG->Warn("#NPSPERMEASURE has more sections (%zu) than possible number of players (%d)!", valuesPerPlayer.size(), NUM_PlayerNumber);
} }
std::vector<std::vector<float>> npsPerMeasures;
for(std::size_t pn = 0; pn < valuesPerPlayer.size() && pn < NUM_PlayerNumber; pn++) for(std::size_t pn = 0; pn < valuesPerPlayer.size() && pn < NUM_PlayerNumber; pn++)
{ {
std::vector<RString> values; std::vector<RString> values;
split(valuesPerPlayer[pn], ",", values, true); split(valuesPerPlayer[pn], ",", values, true);
std::vector<int> npsPerMeasure; std::vector<float> npsPerMeasure;
npsPerMeasure.resize(values.size()); npsPerMeasure.resize(values.size());
for(std::size_t i = 0; i < values.size(); i++) for(std::size_t i = 0; i < values.size(); i++)
{ {
npsPerMeasure[i] = StringToFloat(values[i]); npsPerMeasure[i] = StringToFloat(values[i]);
} }
info.steps->SetCachedNotesPerMeasure(npsPerMeasure, static_cast<PlayerNumber>(pn)); npsPerMeasures.push_back(npsPerMeasure);
} }
info.steps->SetCachedNpsPerMeasure(npsPerMeasures);
} }
else else
{ {
@@ -454,6 +456,7 @@ void SetNotesPerMeasure(StepsTagInfo& info)
} }
std::vector<std::vector<int>> notesPerMeasures;
for(std::size_t pn = 0; pn < valuesPerPlayer.size() && pn < NUM_PlayerNumber; pn++) for(std::size_t pn = 0; pn < valuesPerPlayer.size() && pn < NUM_PlayerNumber; pn++)
{ {
std::vector<RString> values; std::vector<RString> values;
@@ -464,8 +467,9 @@ void SetNotesPerMeasure(StepsTagInfo& info)
{ {
notesPerMeasure[i] = StringToInt(values[i]); notesPerMeasure[i] = StringToInt(values[i]);
} }
info.steps->SetCachedNotesPerMeasure(notesPerMeasure, static_cast<PlayerNumber>(pn)); notesPerMeasures.push_back(notesPerMeasure);
} }
info.steps->SetCachedNotesPerMeasure(notesPerMeasures);
} }
else else
{ {
+11 -17
View File
@@ -757,35 +757,29 @@ void Steps::SetCachedTechCounts( const TechCounts ts[NUM_PLAYERS] )
m_bAreCachedTechCountsValuesJustLoaded = true; m_bAreCachedTechCountsValuesJustLoaded = true;
} }
void Steps::SetCachedNpsPerMeasure(std::vector<float>& npsPerMeasure, PlayerNumber pn) void Steps::SetCachedNpsPerMeasure(std::vector<std::vector<float>>& npsPerMeasure)
{ {
DeAutogen(); DeAutogen();
m_CachedNpsPerMeasure.assign(npsPerMeasure.begin(), npsPerMeasure.end());
m_PeakNps.clear();
if(m_CachedNpsPerMeasure.size() <= pn) for(std::vector<float> n : npsPerMeasure)
{ {
m_CachedNpsPerMeasure.resize(pn + 1); std::vector<float>::iterator peakNps = std::max_element(n.begin(), n.end());
m_PeakNps.resize(pn + 1); if(peakNps != n.end())
{
m_PeakNps.push_back(*peakNps);
}
} }
m_CachedNpsPerMeasure[pn].assign(npsPerMeasure.begin(), npsPerMeasure.end());
std::vector<float>::iterator peakNps = std::max_element(npsPerMeasure.begin(), npsPerMeasure.end());
if(peakNps != npsPerMeasure.end())
{
m_PeakNps[pn] = *peakNps;
}
m_AreCachedNpsPerMeasureJustLoaded = true; m_AreCachedNpsPerMeasureJustLoaded = true;
} }
void Steps::SetCachedNotesPerMeasure(std::vector<int>& notesPerMeasure, PlayerNumber pn) void Steps::SetCachedNotesPerMeasure(std::vector<std::vector<int>>& notesPerMeasure)
{ {
DeAutogen(); DeAutogen();
if(m_CachedNotesPerMeasure.size() <= pn) m_CachedNotesPerMeasure.assign(notesPerMeasure.begin(), notesPerMeasure.end());
{
m_CachedNotesPerMeasure.resize(pn + 1);
}
m_CachedNotesPerMeasure[pn].assign(notesPerMeasure.begin(), notesPerMeasure.end());
m_AreCachedNotesPerMeasureJustLoaded = true; m_AreCachedNotesPerMeasureJustLoaded = true;
} }
+2 -2
View File
@@ -145,8 +145,8 @@ public:
void SetMeter( int meter ); void SetMeter( int meter );
void SetCachedRadarValues( const RadarValues v[NUM_PLAYERS] ); void SetCachedRadarValues( const RadarValues v[NUM_PLAYERS] );
void SetCachedTechCounts(const TechCounts ts[NUM_PLAYERS]); void SetCachedTechCounts(const TechCounts ts[NUM_PLAYERS]);
void SetCachedNpsPerMeasure(std::vector<float>& npsPerMeasure, PlayerNumber pn); void SetCachedNpsPerMeasure(std::vector<std::vector<float>>& npsPerMeasure);
void SetCachedNotesPerMeasure(std::vector<int>& notesPerMeasure, PlayerNumber pn); void SetCachedNotesPerMeasure(std::vector<std::vector<int>>& notesPerMeasure);
float PredictMeter() const; float PredictMeter() const;
unsigned GetHash() const; unsigned GetHash() const;