Mostly stylistic changes

This commit is contained in:
teejusb
2025-02-11 19:39:03 -08:00
parent 53ebe4cce1
commit 49263f3c3e
12 changed files with 172 additions and 194 deletions
+1 -1
View File
@@ -24,7 +24,7 @@ RString MeasureInfo::ToString() const
return join(",", asMeasureInfo);
}
void MeasureInfo::FromString(RString sValues)
void MeasureInfo::FromString(const RString& sValues)
{
std::vector<RString> asValues;
split( sValues, ",", asValues, true );
+2 -2
View File
@@ -2,7 +2,7 @@
#define MEASURE_INFO_H
#include "GameConstantsAndTypes.h"
class NoteData;
#include "NoteData.h"
/** This is a container for per-measure stats of a stepchart.
This data is calculated and saved to the song cache files as the #MEASUREINFO tag.
@@ -30,7 +30,7 @@ struct MeasureInfo
}
RString ToString() const;
void FromString( RString sValues );
void FromString(const RString& sValues );
static void CalculateMeasureInfo(const NoteData &in, MeasureInfo &out);
};
-1
View File
@@ -419,7 +419,6 @@ void SetMeasureInfo(StepsTagInfo& info)
FOREACH_PlayerNumber(pn)
{
v[pn].FromString(values[pn]);
}
info.steps->SetCachedMeasureInfo(v);
}
+1 -1
View File
@@ -448,7 +448,7 @@ static RString GetSSCNoteData( const Song &song, const Steps &in, bool bSavingCa
}
lines.push_back(ssprintf("#MEASUREINFO:%s;", join("|", asMeasureInfo).c_str()));
// MV: #STEPFILENAME has to be at the end of the cache tags,
// 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.
+1 -5
View File
@@ -6,8 +6,6 @@
namespace StepParity
{
const int DOUBLESTEP= 850;
const int BRACKETJACK= 20;
const int JACK= 30;
@@ -31,7 +29,6 @@ namespace StepParity
const float JACK_THRESHOLD = 0.1;
// 0.15 = 1/8th at 200bpm, or 3/16th at 150bpm. Below this speed, jumps should be prioritized
const float SLOW_BRACKET_THRESHOLD = 0.15;
// 0.2 = 1/8th at 150bpm. Footswitches slower than this are harder.
// Below this speed, jacks should be prioritized
const float SLOW_FOOTSWITCH_THRESHOLD = 0.2;
@@ -45,8 +42,7 @@ namespace StepParity
StageLayout layout;
public:
StepParityCost(const StageLayout& _layout): layout(_layout){
}
StepParityCost(const StageLayout& _layout): layout(_layout) {}
/// @brief Computes and returns a cost value for the player moving from initialState to resultState.
/// @param initialState The starting position of the player
+1 -17
View File
@@ -3,10 +3,7 @@
using namespace StepParity;
//
// Graph/Node methods
//
int calculateVectorHash(const std::vector<Foot> &vec)
{
int value = 0;
@@ -53,7 +50,7 @@ void State::calculateHashes()
StepParityNode * StepParityGraph::addOrGetExistingNode(const State &state)
{
// this is silly, but the start node has a rowIndex of -1
// This is silly, but the start node has a rowIndex of -1
// which doesn't work as an array index.
int rowIndex = state.rowIndex + 1;
while (static_cast<int>(stateNodeMap.size()) <= rowIndex)
@@ -74,10 +71,7 @@ StepParityNode * StepParityGraph::addOrGetExistingNode(const State &state)
return stateNodeMap[rowIndex][state];
}
//
// StageLayout
//
bool StageLayout::bracketCheck(int column1, int column2)
{
StagePoint p1 = columns[column1];
@@ -169,10 +163,7 @@ float StageLayout::getPlayerAngle(StepParity::StagePoint left, StepParity::Stage
return atan2f(det, dot);
}
//
// Row
//
void Row::setFootPlacement(const std::vector<Foot> & footPlacement)
{
for (int c = 0; c < columnCount; c++) {
@@ -185,12 +176,7 @@ void Row::setFootPlacement(const std::vector<Foot> & footPlacement)
}
}
//
// Json methods
//
template<typename Container>
Json::Value FeetToJson(const Container& feets, bool useStrings)
{
@@ -301,7 +287,6 @@ Json::Value StepParityNode::ToJson()
return root;
}
Json::Value Row::ToJsonRows(const std::vector<Row> & rows, bool useStrings)
{
Json::Value root;
@@ -327,7 +312,6 @@ Json::Value Row::ParityRowsJson(const std::vector<Row> & rows)
return root;
}
Json::Value StepParityGraph::ToJson()
{
Json::Value jsonNodes;
+34 -25
View File
@@ -8,7 +8,6 @@
#include <queue>
#include <unordered_map>
namespace StepParity {
const float CLM_SECOND_INVALID = -1;
@@ -91,7 +90,6 @@ namespace StepParity {
std::vector<int> downArrows;
std::vector<int> sideArrows;
StageLayout(StepsType t,
const std::vector<StagePoint>& c,
const std::vector<int> & u,
@@ -191,14 +189,17 @@ namespace StepParity {
/// This shouldn't be confused with the idea of "rows" elsewhere in SM. Here, we only use
/// these Rows to represent a row that isn't empty.
struct Row {
std::vector<IntermediateNoteData> notes; // notes for the given row
std::vector<IntermediateNoteData> holds; // Any active hold notes, including ones that started before this row
std::set<int> holdTails; // Column index of any holds that end on this row
std::vector<float> mines; // If a mine occurred either on this row, or on a row on its own immediately
// notes for the given row
std::vector<IntermediateNoteData> notes;
// Any active hold notes, including ones that started before this row
std::vector<IntermediateNoteData> holds;
// Column index of any holds that end on this row
std::set<int> holdTails;
// If a mine occurred either on this row, or on a row on its own immediately
// preceding this one, the time of when that mine occurred, indexed by column.
std::vector<float> fakeMines; // The same thing, but for fake mines
std::vector<float> mines;
// The same thing, but for fake mines
std::vector<float> fakeMines;
FootPlacement columns;
std::vector<int> whereTheFeetAre;
@@ -235,24 +236,30 @@ namespace StepParity {
/// @brief A counter used while creating rows
struct RowCounter
{
std::vector<IntermediateNoteData> notes; // Notes for the "current" row being generated
std::vector<IntermediateNoteData> activeHolds; // Any holds that are active for the current row
// Notes for the "current" row being generated
std::vector<IntermediateNoteData> notes;
// Any holds that are active for the current row
std::vector<IntermediateNoteData> activeHolds;
float lastColumnSecond = CLM_SECOND_INVALID;
float lastColumnBeat = CLM_SECOND_INVALID;
std::vector<float> mines; // The time at which a mine occurred for the current row,
// The time at which a mine occurred for the current row,
// indexed by column
std::vector<float> fakeMines; // The time at which a fake mine occurred for the current row,
std::vector<float> mines;
// The time at which a fake mine occurred for the current row,
// indexed by column
std::vector<float> fakeMines;
std::vector<float> nextMines; // The time at which a mine occurred in the _previous_ row,
// The time at which a mine occurred in the _previous_ row,
// indexed by column
std::vector<float> nextFakeMines; // The time at which a fake mine occurred in the _previous_ row,
std::vector<float> nextMines;
// The time at which a fake mine occurred in the _previous_ row,
// indexed by column
int noteCount = 0; // number of "notes" added to the counter for the current row.
std::vector<float> nextFakeMines;
// number of "notes" added to the counter for the current row.
int noteCount = 0;
RowCounter(int columnCount)
{
notes = std::vector<IntermediateNoteData>(columnCount);
activeHolds = std::vector<IntermediateNoteData>(columnCount);
mines = std::vector<float>(columnCount, 0);
@@ -270,10 +277,12 @@ namespace StepParity {
/// following row of the step chart.
struct StepParityNode
{
int id = 0; // The index of this node in its graph
// The index of this node in its graph
int id = 0;
State state;
std::unordered_map<StepParityNode *, float*> neighbors; // Connections to, and the cost of moving to, the connected nodes
// Connections to, and the cost of moving to, the connected nodes
std::unordered_map<StepParityNode *, float*> neighbors;
~StepParityNode()
{
@@ -313,8 +322,10 @@ namespace StepParity {
std::vector<std::map<State, StepParityNode *, StateComparator>> stateNodeMap;
public:
StepParityNode * startNode; // This represents the very start of the song, before any notes
StepParityNode *endNode; // This represents the end of the song, after all of the notes
// This represents the very start of the song, before any notes
StepParityNode * startNode;
// This represents the end of the song, after all of the notes
StepParityNode *endNode;
~StepParityGraph()
{
@@ -323,7 +334,6 @@ namespace StepParity {
{
delete node;
}
}
/// @brief Returns a pointer to a StepParityNode that represents the given state within the graph.
@@ -332,7 +342,8 @@ namespace StepParity {
/// @return
StepParityNode *addOrGetExistingNode(const State &state);
void addEdge(StepParityNode* from, StepParityNode* to, float* costs) {
void addEdge(StepParityNode* from, StepParityNode* to, float* costs)
{
from->neighbors[to] = costs;
}
@@ -348,8 +359,6 @@ namespace StepParity {
return nodes[index];
}
};
};
#endif
+22 -20
View File
@@ -5,11 +5,8 @@
#include "TechCounts.h"
#include "GameState.h"
using namespace StepParity;
void StepParityGenerator::analyzeNoteData(const NoteData &in)
{
columnCount = in.GetNumTracks();
@@ -25,7 +22,6 @@ void StepParityGenerator::analyzeNoteData(const NoteData &in)
analyzeGraph();
}
void StepParityGenerator::analyzeGraph() {
nodes_for_rows = computeCheapestPath();
ASSERT_M(nodes_for_rows.size() == rows.size(), "nodes_for_rows should be the same length as rows!");
@@ -37,7 +33,6 @@ void StepParityGenerator::analyzeGraph() {
}
}
void StepParityGenerator::buildStateGraph()
{
// The first node of the graph is beginningState, which represents the time before
@@ -105,7 +100,6 @@ void StepParityGenerator::buildStateGraph()
}
}
State StepParityGenerator::initResultState(State &initialState, Row &row, const FootPlacement &columns)
{
State resultState(row.columnCount);
@@ -148,7 +142,6 @@ State StepParityGenerator::initResultState(State &initialState, Row &row, const
return resultState;
}
std::vector<FootPlacement>* StepParityGenerator::getFootPlacementPermutations(const Row &row)
{
int cacheKey = getPermuteCacheKey(row);
@@ -175,16 +168,26 @@ std::vector<FootPlacement> StepParityGenerator::PermuteFootPlacements(const Row
for (unsigned long i = 0; i < columns.size(); i++)
{
if (columns[i] == NONE)
{
continue;
}
if (columns[i] == LEFT_HEEL)
{
leftHeelIndex = i;
}
if (columns[i] == LEFT_TOE)
{
leftToeIndex = i;
}
if (columns[i] == RIGHT_HEEL)
{
rightHeelIndex = i;
}
if (columns[i] == RIGHT_TOE)
{
rightToeIndex = i;
}
}
if (
(leftHeelIndex == -1 && leftToeIndex != -1) ||
(rightHeelIndex == -1 && rightToeIndex != -1))
@@ -194,19 +197,24 @@ std::vector<FootPlacement> StepParityGenerator::PermuteFootPlacements(const Row
if (leftHeelIndex != -1 && leftToeIndex != -1)
{
if (!layout.bracketCheck(leftHeelIndex, leftToeIndex))
{
return std::vector<FootPlacement>();
}
}
if (rightHeelIndex != -1 && rightToeIndex != -1)
{
if (!layout.bracketCheck(rightHeelIndex, rightToeIndex))
{
return std::vector<FootPlacement>();
}
}
return {columns};
}
std::vector<FootPlacement> permutations;
if (row.notes[column].type != TapNoteType_Empty || row.holds[column].type != TapNoteType_Empty) {
if (row.notes[column].type != TapNoteType_Empty ||
row.holds[column].type != TapNoteType_Empty)
{
for (StepParity::Foot foot: FEET) {
if(std::find(columns.begin(), columns.end(), foot) != columns.end())
{
@@ -224,7 +232,6 @@ std::vector<FootPlacement> StepParityGenerator::PermuteFootPlacements(const Row
return PermuteFootPlacements(row, columns, column + 1);
}
std::vector<int> StepParityGenerator::computeCheapestPath()
{
int start = graph.startNode->id;
@@ -241,7 +248,6 @@ std::vector<int> StepParityGenerator::computeCheapestPath()
{
int neighbor_id = neighbor.first->id;
float weight = neighbor.second[COST_TOTAL];
// printf("computeCheapestPath:: weight = %f", weight);
if(cost[i] + weight < cost[neighbor_id])
{
cost[neighbor_id] = cost[i] + weight;
@@ -264,8 +270,8 @@ std::vector<int> StepParityGenerator::computeCheapestPath()
return shortest_path;
}
void StepParityGenerator::CreateIntermediateNoteData(const NoteData &in, std::vector<IntermediateNoteData> &out)
void StepParityGenerator::CreateIntermediateNoteData(
const NoteData &in, std::vector<IntermediateNoteData> &out)
{
TimingData *timing = GAMESTATE->GetProcessedTimingData();
int columnCount = in.GetNumTracks();
@@ -302,7 +308,6 @@ void StepParityGenerator::CreateIntermediateNoteData(const NoteData &in, std::ve
out.assign(notes.begin(), notes.end());
}
void StepParityGenerator::CreateRows(const NoteData &in)
{
TimingData *timing = GAMESTATE->GetProcessedTimingData();
@@ -332,7 +337,6 @@ void StepParityGenerator::CreateRows(const NoteData &in)
// before checking whether or not this note represens a new row.
// But we only want to create a new Row if it has at least one note.
// So probably something like
/*
for(note of notes)
@@ -349,7 +353,6 @@ void StepParityGenerator::CreateRows(const NoteData &in)
check if note is a mine or fake mine
if note is fake continue
put note into counter.notes
}
*/
if (note.second == counter.lastColumnSecond && rows.size() > 0)
@@ -384,14 +387,13 @@ void StepParityGenerator::CreateRows(const NoteData &in)
if (counter.lastColumnSecond != note.second)
{
// we're past the previous row, so save all of the previous row's data
// We're past the previous row, so save all of the previous row's data.
if (counter.lastColumnSecond != CLM_SECOND_INVALID)
{
AddRow(counter);
}
// Move mines and fakeMines to "next", and reset counters
// Move mines and fakeMines to "next", and reset counters.
counter.lastColumnSecond = note.second;
counter.lastColumnBeat = note.beat;
counter.nextMines.assign(counter.mines.begin(), counter.mines.end());
@@ -400,7 +402,7 @@ void StepParityGenerator::CreateRows(const NoteData &in)
counter.mines = std::vector<float>(columnCount);
counter.fakeMines = std::vector<float>(columnCount);
// reset any now-inactive holds to empty values
// Reset any now-inactive holds to empty values.
for (int c = 0; c < columnCount; c++)
{
if (counter.activeHolds[c].type == TapNoteType_Empty || note.beat > counter.activeHolds[c].beat + counter.activeHolds[c].hold_length)
+1 -2
View File
@@ -332,8 +332,7 @@ void Steps::CalculateRadarValues( float fMusicLengthSeconds )
this->GetNoteData( tempNoteData );
FOREACH_PlayerNumber(pn)
m_CachedRadarValues[pn]
.Zero();
m_CachedRadarValues[pn].Zero();
GAMESTATE->SetProcessedTimingData(this->GetTimingData());
if( tempNoteData.IsComposite() )
+9 -19
View File
@@ -8,7 +8,6 @@
#include "GameState.h"
#include "RageTimer.h"
static const char *TechCountsCategoryNames[] = {
"Crossovers",
"HalfCrossovers",
@@ -27,7 +26,6 @@ XToLocalizedString( TechCountsCategory );
LuaFunction(TechCountsCategoryToLocalizedString, TechCountsCategoryToLocalizedString(Enum::Check<TechCountsCategory>(L, 1)) );
LuaXType( TechCountsCategory );
// 0.176 ~= 1/8th at 175bpm
// Anything slower isn't counted as a jack
const float JACK_CUTOFF = 0.176;
@@ -90,10 +88,8 @@ void TechCounts::FromString( RString sTechCounts )
{
(*this)[rc] = StringToFloat(saValues[rc]);
}
}
void TechCounts::CalculateTechCountsFromRows(const std::vector<StepParity::Row> &rows, StepParity::StageLayout & layout, TechCounts &out)
{
for (unsigned long i = 1; i < rows.size(); i++)
@@ -103,17 +99,15 @@ void TechCounts::CalculateTechCountsFromRows(const std::vector<StepParity::Row>
float elapsedTime = currentRow.second - previousRow.second;
/*
Jacks are same arrow same foot
Doublestep is same foot on successive arrows
Brackets are jumps with one foot
// Jacks are same arrow same foot
// Doublestep is same foot on successive arrows
// Brackets are jumps with one foot
Footswitch is different foot on the up or down arrow
Sideswitch is footswitch on left or right arrow
Crossovers are left foot on right arrow or vice versa
*/
// Footswitch is different foot on the up or down arrow
// Sideswitch is footswitch on left or right arrow
// Crossovers are left foot on right arrow or vice versa
// check for jacks and doublesteps
// Check for jacks and doublesteps
if(currentRow.noteCount == 1 && previousRow.noteCount == 1)
{
for (StepParity::Foot foot: StepParity::FEET)
@@ -140,7 +134,7 @@ void TechCounts::CalculateTechCountsFromRows(const std::vector<StepParity::Row>
}
}
// check for brackets
// Check for brackets
if(currentRow.noteCount >= 2)
{
if(currentRow.whereTheFeetAre[StepParity::LEFT_HEEL] != -1 && currentRow.whereTheFeetAre[StepParity::LEFT_TOE] != -1)
@@ -183,7 +177,6 @@ void TechCounts::CalculateTechCountsFromRows(const std::vector<StepParity::Row>
}
// Check for crossovers
int leftHeel = currentRow.whereTheFeetAre[StepParity::LEFT_HEEL];
int leftToe = currentRow.whereTheFeetAre[StepParity::LEFT_TOE];
int rightHeel = currentRow.whereTheFeetAre[StepParity::RIGHT_HEEL];
@@ -235,7 +228,7 @@ void TechCounts::CalculateTechCountsFromRows(const std::vector<StepParity::Row>
}
}
}
// and check the same thing, starting with left foot
// And check the same thing, starting with left foot
else if(leftHeel != -1 && previousRightHeel != -1 && previousLeftHeel == -1)
{
StepParity::StagePoint leftPos = layout.averagePoint(leftHeel, leftToe);
@@ -287,12 +280,9 @@ bool TechCounts::isFootswitch(int c, const StepParity::Row & currentRow, const S
}
// lua start
class LunaTechCounts: public Luna<TechCounts>
{
public:
static int GetValue( T* p, lua_State *L ) { lua_pushnumber( L, (*p)[Enum::Check<TechCountsCategory>(L, 1)] ); return 1; }
LunaTechCounts()
+1 -2
View File
@@ -3,8 +3,7 @@
#include "GameConstantsAndTypes.h"
#include "StepParityGenerator.h"
class NoteData;
#include "NoteData.h"
/** @brief Unknown radar values are given a default value. */
#define TECHCOUNTS_VAL_UNKNOWN -1