Online protocol improvements (#1393)
* Chartkey generation * Simfile filehash generation * Read filehash on NSCRSG. Add FLU packets and friendlist vectors. Add getserverversion method. Send chartkey, filehash and rate on start request. * Use filehash to find the selected song if it is not empty. * Friendlist update broadcast. * Send note row size if it's bigger than 1 * Used for chartkey generation * Define the ReportScore function with numNotes when WITHOUT_NETWORKING is defined
This commit is contained in:
@@ -33,6 +33,9 @@
|
||||
/* register DisplayBPM with StringConversion */
|
||||
#include "EnumHelper.h"
|
||||
|
||||
// For hashing hart keys - Mina
|
||||
#include "CryptManager.h"
|
||||
|
||||
static const char *DisplayBPMNames[] =
|
||||
{
|
||||
"Actual",
|
||||
@@ -614,6 +617,77 @@ void Steps::SetCachedRadarValues( const RadarValues v[NUM_PLAYERS] )
|
||||
m_bAreCachedRadarValuesJustLoaded = true;
|
||||
}
|
||||
|
||||
RString Steps::GenerateChartKey()
|
||||
{
|
||||
ChartKey = this->GenerateChartKey(*m_pNoteData, this->GetTimingData());
|
||||
return ChartKey;
|
||||
}
|
||||
RString Steps::GetChartKey()
|
||||
{
|
||||
if (ChartKey.empty()) {
|
||||
this->Decompress();
|
||||
ChartKey = this->GenerateChartKey(*m_pNoteData, this->GetTimingData());
|
||||
this->Compress();
|
||||
}
|
||||
return ChartKey;
|
||||
}
|
||||
RString Steps::GenerateChartKey(NoteData &nd, TimingData *td)
|
||||
{
|
||||
RString k = "";
|
||||
RString o = "";
|
||||
float bpm;
|
||||
nd.LogNonEmptyRows();
|
||||
std::vector<int>& nerv = nd.GetNonEmptyRowVector();
|
||||
|
||||
|
||||
RString firstHalf = "";
|
||||
RString secondHalf = "";
|
||||
|
||||
#pragma omp parallel sections
|
||||
{
|
||||
#pragma omp section
|
||||
{
|
||||
for (size_t r = 0; r < nerv.size() / 2; r++) {
|
||||
int row = nerv[r];
|
||||
for (int t = 0; t < nd.GetNumTracks(); ++t) {
|
||||
const TapNote &tn = nd.GetTapNote(t, row);
|
||||
std::ostringstream os;
|
||||
os << tn.type;
|
||||
firstHalf.append(os.str());
|
||||
}
|
||||
bpm = td->GetBPMAtRow(row);
|
||||
std::ostringstream os;
|
||||
os << static_cast<int>(bpm + 0.374643f);
|
||||
firstHalf.append(os.str());
|
||||
}
|
||||
}
|
||||
|
||||
#pragma omp section
|
||||
{
|
||||
for (size_t r = nerv.size() / 2; r < nerv.size(); r++) {
|
||||
int row = nerv[r];
|
||||
for (int t = 0; t < nd.GetNumTracks(); ++t) {
|
||||
const TapNote &tn = nd.GetTapNote(t, row);
|
||||
std::ostringstream os;
|
||||
os << tn.type;
|
||||
secondHalf.append(os.str());
|
||||
}
|
||||
bpm = td->GetBPMAtRow(row);
|
||||
std::ostringstream os;
|
||||
os << static_cast<int>(bpm + 0.374643f);
|
||||
firstHalf.append(os.str());
|
||||
}
|
||||
}
|
||||
}
|
||||
k = firstHalf + secondHalf;
|
||||
|
||||
//ChartKeyRecord = k;
|
||||
o.append("X"); // I was thinking of using "C" to indicate chart.. however.. X is cooler... - Mina
|
||||
o.append(BinaryToHex(CryptManager::GetSHA1ForString(k)));
|
||||
return o;
|
||||
}
|
||||
|
||||
|
||||
// lua start
|
||||
#include "LuaBinding.h"
|
||||
/** @brief Allow Lua to have access to the Steps. */
|
||||
|
||||
Reference in New Issue
Block a user