Skip to content

Commit

Permalink
make etterna validation much more explicit/exhaustive
Browse files Browse the repository at this point in the history
  • Loading branch information
MinaciousGrace committed Nov 20, 2017
1 parent f95c698 commit 7f038c4
Show file tree
Hide file tree
Showing 4 changed files with 96 additions and 23 deletions.
13 changes: 11 additions & 2 deletions src/Player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,7 @@ void Player::Load()
totalwifescore = m_NoteData.WifeTotalScoreCalc(m_Timing, 0, 1073741824);
curwifescore = 0.f;
maxwifescore = 0.f;

m_NoteData.LogNonEmptyRows();
nerv = m_NoteData.GetNonEmptyRowVector();
const vector<float>& etaner = m_Timing->BuildAndGetEtaner(nerv);
Expand All @@ -618,7 +618,14 @@ void Player::Load()

if (m_Timing->HasWarps())
m_pPlayerStageStats->filehadnegbpms = true;


// check before nomines transform
if(GAMESTATE->m_pCurSteps[pn]->GetRadarValues()[RadarCategory_Mines] > 0)
m_pPlayerStageStats->filegotmines = true;

// check for lua script load (technically this is redundant a little with negbpm but whatever) -mina
if (!m_Timing->ValidSequentialAssumption)
m_pPlayerStageStats->luascriptwasloaded = true;

Profile *pProfile = PROFILEMAN->GetProfile(pn);
const HighScore* pb = SCOREMAN->GetChartPBAt(GAMESTATE->m_pCurSteps[pn]->GetChartKey(), GAMESTATE->m_SongOptions.GetCurrent().m_fMusicRate);
Expand Down Expand Up @@ -862,6 +869,7 @@ void Player::Update( float fDeltaTime )
if( m_pPlayerState->m_PlayerController == PC_AUTOPLAY )
{
STATSMAN->m_CurStageStats.m_bUsedAutoplay = true;
m_pPlayerStageStats->everusedautoplay = true;
if( m_pPlayerStageStats )
m_pPlayerStageStats->m_bDisqualified = true;
}
Expand Down Expand Up @@ -1107,6 +1115,7 @@ void Player::UpdateHoldNotes( int iSongRow, float fDeltaTime, vector<TrackRowTap
if( m_pPlayerState->m_PlayerController == PC_AUTOPLAY )
{
STATSMAN->m_CurStageStats.m_bUsedAutoplay = true;
m_pPlayerStageStats->everusedautoplay = true;
if( m_pPlayerStageStats != NULL )
m_pPlayerStageStats->m_bDisqualified = true;
}
Expand Down
23 changes: 16 additions & 7 deletions src/PlayerStageStats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,12 @@ void PlayerStageStats::InternalInit()
m_iSongsPlayed = 0;
m_fLifeRemainingSeconds = 0;
m_iNumControllerSteps = 0;

// this should probably be handled better-mina
everusedautoplay = false;
luascriptwasloaded = false;
filehadnegbpms = false;
filegotmines = false;

ZERO( m_iTapNoteScores );
ZERO( m_iHoldNoteScores );
Expand Down Expand Up @@ -331,15 +336,19 @@ void PlayerStageStats::GenerateValidationKeys(HighScore& hs) const {
// just designed to catch shameless stats xml tampering by people who aren't experienced enough to look this up -mina
FOREACH_ENUM(TapNoteScore, tns)
key.append(to_string(hs.GetTapNoteScore(tns)));
FOREACH_ENUM(TapNoteScore, tns)
key.append(to_string(hs.GetTapNoteScore(tns)));
FOREACH_ENUM(HoldNoteScore, hns)
key.append(to_string(hs.GetHoldNoteScore(hns)));

key.append(hs.GetScoreKey());
key.append(to_string(lround(hs.GetWifeScore() * 1000.f)));
key.append(to_string(lround(hs.GetSSRNormPercent() * 1000.f)));
key.append(to_string(lround(hs.GetMusicRate() * 1000.f)));
key.append(to_string(lround(hs.GetJudgeScale() * 1000.f)));
key.append(to_string(hs.GetEtternaValid()));
key.append(hs.GetChartKey());
key.append(hs.GetModifiers());
key.append(to_string(static_cast<int>(hs.GetWifeScore() * 1000.f)));
key.append(to_string(static_cast<int>(hs.GetSSRNormPercent() * 1000.f)));
key.append(to_string(static_cast<int>(hs.GetMusicRate() * 1000.f)));
key.append(to_string(static_cast<int>(hs.GetJudgeScale() * 1000.f)));
key.append(to_string(static_cast<int>(hs.GetWifePoints() * 1000.f)));
key.append(to_string(static_cast<int>(!hs.GetChordCohesion())));
key.append(to_string(static_cast<int>(hs.GetEtternaValid())));

hs.SetValidationKey(ValidationKey_Brittle, BinaryToHex(CryptManager::GetSHA1ForString(key)));

Expand Down
3 changes: 3 additions & 0 deletions src/PlayerStageStats.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,10 @@ class PlayerStageStats
// workout
float m_iNumControllerSteps;

bool everusedautoplay;
bool luascriptwasloaded;
bool filehadnegbpms; // the call after gameplay is over is apparently unreliable -mina
bool filegotmines; // this needs to be set before any notedata transforms

map<float,float> m_fLifeRecord;
void SetLifeRecordAt( float fLife, float fStepsSecond );
Expand Down
80 changes: 66 additions & 14 deletions src/StageStats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,69 @@ float StageStats::GetTotalPossibleStepsSeconds() const
return fSecs / m_fMusicRate;
}

// all the dumb reasons your score doesnt matter (or at least, most of them) -mina
bool DetermineScoreEligibility(const PlayerStageStats &pss, const PlayerState &ps) {

// 4k only
if (GAMESTATE->m_pCurSteps[ps.m_PlayerNumber]->m_StepsType != StepsType_dance_single)
return false;

// chord cohesion is invalid
if (!GAMESTATE->CountNotesSeparately())
return false;

// you failed.
if (pss.GetGrade() == Grade_Failed)
return false;

// just because you had failoff, doesn't mean you didn't fail.
FOREACHM_CONST(float, float, pss.m_fLifeRecord, fail)
if (fail->second == 0.f)
return false;

// cut out stuff with under 200 notes to prevent super short vibro files from being dumb
if (pss.GetTotalTaps() < 200)
return false;

// i'm not actually sure why this is here but if you activate this you don't deserve points anyway
if (pss.m_fWifeScore < 0.1f)
return false;

// no negative bpm garbage
if (pss.filehadnegbpms)
return false;

// no lau script shenanigans
if (pss.luascriptwasloaded)
return false;

// it would take some amount of effort to abuse this but hey, whatever
if (pss.everusedautoplay)
return false;

// mods that modify notedata other than mirror (too lazy to figure out how to check for these in po)
string mods = ps.m_PlayerOptions.GetStage().GetString();

// should take care of all 3 shuffle mods
if (mods.find("Shuffle") != mods.npos)
return false;

// only do this if the file doesnt have mines
if (mods.find("NoMines") != mods.npos && pss.filegotmines)
return false;

if (mods.find("Left") != mods.npos)
return false;

if (mods.find("Right") != mods.npos)
return false;

if (mods.find("Backwards") != mods.npos)
return false;

return true;
}

static HighScore FillInHighScore(const PlayerStageStats &pss, const PlayerState &ps, RString sRankingToFillInMarker, RString sPlayerGuid)
{
HighScore hs;
Expand All @@ -149,20 +212,6 @@ static HighScore FillInHighScore(const PlayerStageStats &pss, const PlayerState
hs.SetPercentDP( pss.GetPercentDancePoints() );
hs.SetWifeScore( pss.GetWifeScore());
hs.SetWifePoints( pss.GetCurWifeScore());

// should prolly be its own fun - mina
hs.SetEtternaValid(true);
if (pss.GetGrade() == Grade_Failed || pss.m_fWifeScore < 0.1f || GAMESTATE->m_pCurSteps[ps.m_PlayerNumber]->m_StepsType != StepsType_dance_single || !GAMESTATE->CountNotesSeparately() || pss.filehadnegbpms)
hs.SetEtternaValid(false);

// cut out stuff with under 200 notes to prevent super short vibro files from being dumb -mina
if(pss.GetTotalTaps() < 200)
hs.SetEtternaValid(false);

FOREACHM_CONST(float, float, pss.m_fLifeRecord, fail)
if (fail->second == 0.f)
hs.SetEtternaValid(false);

hs.SetMusicRate( GAMESTATE->m_SongOptions.GetCurrent().m_fMusicRate);
hs.SetJudgeScale( pss.GetTimingScale());
hs.SetChordCohesion( GAMESTATE->CountNotesSeparately() );
Expand Down Expand Up @@ -192,6 +241,9 @@ static HighScore FillInHighScore(const PlayerStageStats &pss, const PlayerState
hs.SetLifeRemainingSeconds( pss.m_fLifeRemainingSeconds );
hs.SetDisqualified( pss.IsDisqualified() );

// Etterna validity check, used for ssr/eo eligibility -mina
hs.SetEtternaValid(DetermineScoreEligibility(pss, ps));

// should maybe just make the setscorekey function do this internally rather than recalling the datetime object -mina
RString ScoreKey = "S" + BinaryToHex(CryptManager::GetSHA1ForString(hs.GetDateTime().GetString()));
hs.SetScoreKey(ScoreKey);
Expand Down

0 comments on commit 7f038c4

Please sign in to comment.