Skip to content

Commit

Permalink
Remove most extraneous instances of fMusicLengthSeconds
Browse files Browse the repository at this point in the history
replacing them with either nothing or calls to Steps' specific length calls should fix any issues that may have existed or appeared as a result

this also fixes the lack of fadeout for charts that are shorter than normal
  • Loading branch information
poco0317 committed Jul 9, 2020
1 parent 872b54c commit 97d1611
Show file tree
Hide file tree
Showing 14 changed files with 34 additions and 53 deletions.
2 changes: 1 addition & 1 deletion src/Etterna/Actor/Gameplay/Player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3380,7 +3380,7 @@ Player::SetCombo(unsigned int iCombo, unsigned int iMisses)

bPastBeginning =
m_pPlayerState->m_Position.m_fMusicSeconds >
GAMESTATE->m_pCurSong->m_fMusicLengthSeconds * PERCENT_UNTIL_COLOR_COMBO;
GAMESTATE->m_pCurSteps->GetLengthSeconds() * PERCENT_UNTIL_COLOR_COMBO;

if (m_bSendJudgmentAndComboMessages) {
Message msg("Combo");
Expand Down
1 change: 0 additions & 1 deletion src/Etterna/Models/NoteData/NoteDataUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1092,7 +1092,6 @@ DoRowEndRadarCalc(crv_state& state, RadarValues& out)

void
NoteDataUtil::CalculateRadarValues(const NoteData& in,
float fSongSeconds,
RadarValues& out,
TimingData* td)
{
Expand Down
1 change: 0 additions & 1 deletion src/Etterna/Models/NoteData/NoteDataUtil.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ InsertHoldTails(NoteData& inout);

void
CalculateRadarValues(const NoteData& in,
float fSongSeconds,
RadarValues& out,
TimingData* td = nullptr);

Expand Down
1 change: 0 additions & 1 deletion src/Etterna/Models/NoteData/NoteDataWithScoring.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,6 @@ UpdateHittable(const int& curr_row, int& first, int& last)
void
NoteDataWithScoring::GetActualRadarValues(const NoteData& in,
const PlayerStageStats& pss,
const float& song_seconds,
RadarValues& out)
{
// Anybody editing this function should also examine
Expand Down
1 change: 0 additions & 1 deletion src/Etterna/Models/NoteData/NoteDataWithScoring.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ LastTapNoteWithResult(const NoteData& in, const unsigned& row)
void
GetActualRadarValues(const NoteData& in,
const PlayerStageStats& pss,
const float& song_seconds,
RadarValues& out);
} // namespace NoteDataWithScoring

Expand Down
1 change: 0 additions & 1 deletion src/Etterna/Models/NoteLoaders/NotesLoaderOSU.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,6 @@ OsuLoader::LoadNoteDataFromParsedData(
TAP_ORIGINAL_LIFT);
}

// out->m_pSong->m_fMusicLengthSeconds = 80; // what's going on with this
out->m_pSong->m_SongTiming.m_fBeat0OffsetInSeconds = -firstTap / 1000.0f;

out->SetNoteData(newNoteData);
Expand Down
30 changes: 12 additions & 18 deletions src/Etterna/Models/ScoreKeepers/ScoreKeeperNormal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,13 +124,11 @@ ScoreKeeperNormal::Load(const vector<Song*>& apSongs,
iTotalPossibleDancePoints +=
this->GetPossibleDancePoints(&ndPre,
&ndPost,
pSteps->GetTimingData(),
pSong->m_fMusicLengthSeconds);
pSteps->GetTimingData());
iTotalPossibleGradePoints +=
this->GetPossibleGradePoints(&ndPre,
&ndPost,
pSteps->GetTimingData(),
pSong->m_fMusicLengthSeconds);
pSteps->GetTimingData());
GAMESTATE->SetProcessedTimingData(nullptr);
}

Expand Down Expand Up @@ -698,14 +696,13 @@ ScoreKeeperNormal::HandleHoldScore(const TapNote& tn)

int
ScoreKeeperNormal::GetPossibleDancePoints(NoteData* nd,
const TimingData* td,
float fSongSeconds)
const TimingData* td)
{
/* Note: If W1 timing is disabled or not active (not course mode),
* W2 will be used instead. */
// XXX: That's not actually implemented!
RadarValues radars;
NoteDataUtil::CalculateRadarValues(*nd, fSongSeconds, radars);
NoteDataUtil::CalculateRadarValues(*nd, radars);

auto ret = 0;

Expand All @@ -731,26 +728,24 @@ ScoreKeeperNormal::GetPossibleDancePoints(NoteData* nd,
int
ScoreKeeperNormal::GetPossibleDancePoints(NoteData* ndPre,
NoteData* ndPost,
const TimingData* td,
float fSongSeconds)
const TimingData* td)
{
/* The logic here is that if you use a modifier that adds notes, you should
* have to hit the new notes to get a high grade. However, if you use one
* that removes notes, they should simply be counted as misses. */
return std::max(GetPossibleDancePoints(ndPre, td, fSongSeconds),
GetPossibleDancePoints(ndPost, td, fSongSeconds));
return std::max(GetPossibleDancePoints(ndPre, td),
GetPossibleDancePoints(ndPost, td));
}

int
ScoreKeeperNormal::GetPossibleGradePoints(NoteData* nd,
const TimingData* td,
float fSongSeconds)
const TimingData* td)
{
/* Note: if W1 timing is disabled or not active (not course mode),
* W2 will be used instead. */
// XXX: That's not actually implemented!
RadarValues radars;
NoteDataUtil::CalculateRadarValues(*nd, fSongSeconds, radars);
NoteDataUtil::CalculateRadarValues(*nd, radars);

auto ret = 0;

Expand All @@ -770,14 +765,13 @@ ScoreKeeperNormal::GetPossibleGradePoints(NoteData* nd,
int
ScoreKeeperNormal::GetPossibleGradePoints(NoteData* ndPre,
NoteData* ndPost,
const TimingData* td,
float fSongSeconds)
const TimingData* td)
{
/* The logic here is that if you use a modifier that adds notes, you should
* have to hit the new notes to get a high grade. However, if you use one
* that removes notes, they should simply be counted as misses. */
return std::max(GetPossibleGradePoints(ndPre, td, fSongSeconds),
GetPossibleGradePoints(ndPost, td, fSongSeconds));
return std::max(GetPossibleGradePoints(ndPre, td),
GetPossibleGradePoints(ndPost, td));
}

int
Expand Down
12 changes: 4 additions & 8 deletions src/Etterna/Models/ScoreKeepers/ScoreKeeperNormal.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,19 +83,15 @@ class ScoreKeeperNormal : public ScoreKeeper
// This must be calculated using only cached radar values so that we can
// do it quickly.
static auto GetPossibleDancePoints(NoteData* nd,
const TimingData* td,
float fSongSeconds) -> int;
const TimingData* td) -> int;
static auto GetPossibleDancePoints(NoteData* ndPre,
NoteData* ndPost,
const TimingData* td,
float fSongSeconds) -> int;
const TimingData* td) -> int;
static auto GetPossibleGradePoints(NoteData* nd,
const TimingData* td,
float fSongSeconds) -> int;
const TimingData* td) -> int;
static auto GetPossibleGradePoints(NoteData* ndPre,
NoteData* ndPost,
const TimingData* td,
float fSongSeconds) -> int;
const TimingData* td) -> int;

auto TapNoteScoreToDancePoints(TapNoteScore tns) const -> int;
auto HoldNoteScoreToDancePoints(HoldNoteScore hns) const -> int;
Expand Down
2 changes: 1 addition & 1 deletion src/Etterna/Models/Songs/Song.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1091,7 +1091,7 @@ Song::ReCalculateRadarValuesAndLastSecond(bool fromCache,
// string with a compressed format for both cache and internal
// use but not yet
n->CalcEtternaMetadata(calc);
n->CalculateRadarValues(m_fMusicLengthSeconds);
n->CalculateRadarValues();

// calculate lastSecond
localFirst = std::min(localFirst, n->firstsecond);
Expand Down
9 changes: 4 additions & 5 deletions src/Etterna/Models/StepsAndStyles/Steps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ Steps::TidyUpData()
}

void
Steps::CalculateRadarValues(float fMusicLengthSeconds)
Steps::CalculateRadarValues()
{
if (m_bAreCachedRadarValuesJustLoaded) {
m_bAreCachedRadarValuesJustLoaded = false;
Expand All @@ -312,7 +312,7 @@ Steps::CalculateRadarValues(float fMusicLengthSeconds)
auto td = this->GetTimingData();
GAMESTATE->SetProcessedTimingData(td);
NoteDataUtil::CalculateRadarValues(
*m_pNoteData, fMusicLengthSeconds, m_CachedRadarValues, td);
*m_pNoteData, m_CachedRadarValues, td);

GAMESTATE->SetProcessedTimingData(nullptr);
}
Expand Down Expand Up @@ -579,8 +579,7 @@ Steps::Compress() const

void
Steps::CopyFrom(Steps* pSource,
StepsType ntTo,
float fMusicLengthSeconds) // pSource does not have to be of the
StepsType ntTo) // pSource does not have to be of the
// same StepsType
{
m_StepsType = ntTo;
Expand All @@ -594,7 +593,7 @@ Steps::CopyFrom(Steps* pSource,
this->SetDescription(pSource->GetDescription());
this->SetDifficulty(pSource->GetDifficulty());
this->SetMeter(pSource->GetMeter());
this->CalculateRadarValues(fMusicLengthSeconds);
this->CalculateRadarValues();
}

void
Expand Down
4 changes: 2 additions & 2 deletions src/Etterna/Models/StepsAndStyles/Steps.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class Steps
~Steps();

// initializers
void CopyFrom(Steps* pSource, StepsType ntTo, float fMusicLengthSeconds);
void CopyFrom(Steps* pSource, StepsType ntTo);
void CreateBlank(StepsType ntTo);

void Compress() const;
Expand Down Expand Up @@ -149,7 +149,7 @@ class Steps

void GetETTNoteData(std::string& notes_comp_out) const;
void TidyUpData();
void CalculateRadarValues(float fMusicLengthSeconds);
void CalculateRadarValues();

/**
* @brief The TimingData used by the Steps.
Expand Down
14 changes: 6 additions & 8 deletions src/Etterna/Screen/Gameplay/ScreenGameplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -712,7 +712,7 @@ ScreenGameplay::StartPlayingSong(float fMinTimeToNotes, float fMinTimeToMusic)
fSecondsToStartTransitioningOut);

if (fSecondsToStartFadingOutMusic <
GAMESTATE->m_pCurSong->m_fMusicLengthSeconds) {
GAMESTATE->m_pCurSteps->lastsecond) {
p.m_fFadeOutSeconds = MUSIC_FADE_OUT_SECONDS;
p.m_LengthSeconds = fSecondsToStartFadingOutMusic +
MUSIC_FADE_OUT_SECONDS - p.m_StartSecond;
Expand Down Expand Up @@ -837,7 +837,7 @@ void
ScreenGameplay::GetMusicEndTiming(float& fSecondsToStartFadingOutMusic,
float& fSecondsToStartTransitioningOut)
{
float fLastStepSeconds = GAMESTATE->m_pCurSong->GetLastSecond();
float fLastStepSeconds = GAMESTATE->m_pCurSteps->lastsecond;
fLastStepSeconds += Player::GetMaxStepDistanceSeconds();

float fTransitionLength;
Expand All @@ -849,12 +849,12 @@ ScreenGameplay::GetMusicEndTiming(float& fSecondsToStartFadingOutMusic,
float fSecondsToFinishFadingOutMusic =
fSecondsToStartTransitioningOut + fTransitionLength;
if (fSecondsToFinishFadingOutMusic <
GAMESTATE->m_pCurSong->m_fMusicLengthSeconds)
GAMESTATE->m_pCurSteps->GetLengthSeconds())
fSecondsToStartFadingOutMusic =
fSecondsToFinishFadingOutMusic - MUSIC_FADE_OUT_SECONDS;
else
fSecondsToStartFadingOutMusic =
GAMESTATE->m_pCurSong->m_fMusicLengthSeconds; // don't fade
GAMESTATE->m_pCurSteps->GetLengthSeconds(); // don't fade

/* Make sure we keep going long enough to register a miss for the last note,
* and never start fading before the last note. */
Expand Down Expand Up @@ -1434,8 +1434,6 @@ ScreenGameplay::Input(const InputEventPlus& input)
void
ScreenGameplay::SaveStats()
{
float fMusicLen = GAMESTATE->m_pCurSong->m_fMusicLengthSeconds;

/* Note that adding stats is only meaningful for the counters (eg.
* RadarCategory_Jumps), not for the percentages (RadarCategory_Air). */
RadarValues rv;
Expand All @@ -1444,9 +1442,9 @@ ScreenGameplay::SaveStats()
PlayerNumber pn = m_vPlayerInfo.m_pn;

GAMESTATE->SetProcessedTimingData(GAMESTATE->m_pCurSteps->GetTimingData());
NoteDataUtil::CalculateRadarValues(nd, fMusicLen, rv);
NoteDataUtil::CalculateRadarValues(nd, rv);
pss.m_radarPossible += rv;
NoteDataWithScoring::GetActualRadarValues(nd, pss, fMusicLen, rv);
NoteDataWithScoring::GetActualRadarValues(nd, pss, rv);
pss.m_radarActual += rv;
GAMESTATE->SetProcessedTimingData(nullptr);
}
Expand Down
6 changes: 3 additions & 3 deletions src/Etterna/Screen/Gameplay/ScreenGameplayReplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ ScreenGameplayReplay::SetRate(float newRate)
// Set up the music so we don't wait for an Etternaty when messing around
// near the end of the song.
if (fSecondsToStartFadingOutMusic <
GAMESTATE->m_pCurSong->m_fMusicLengthSeconds) {
GAMESTATE->m_pCurSteps->lastsecond) {
p.m_fFadeOutSeconds = MUSIC_FADE_OUT_SECONDS;
p.m_LengthSeconds = fSecondsToStartFadingOutMusic +
MUSIC_FADE_OUT_SECONDS - p.m_StartSecond;
Expand Down Expand Up @@ -508,7 +508,7 @@ ScreenGameplayReplay::TogglePause()
p.m_StartSecond = fSeconds - 0.25f;
p.m_fSpeed = rate;
if (fSecondsToStartFadingOutMusic <
GAMESTATE->m_pCurSong->m_fMusicLengthSeconds) {
GAMESTATE->m_pCurSteps->lastsecond) {
p.m_fFadeOutSeconds = MUSIC_FADE_OUT_SECONDS;
p.m_LengthSeconds = fSecondsToStartFadingOutMusic +
MUSIC_FADE_OUT_SECONDS - p.m_StartSecond;
Expand All @@ -530,7 +530,7 @@ ScreenGameplayReplay::TogglePause()
RageSoundParams p;
p.m_fSpeed = rate;
if (fSecondsToStartFadingOutMusic <
GAMESTATE->m_pCurSong->m_fMusicLengthSeconds) {
GAMESTATE->m_pCurSteps->lastsecond) {
p.m_fFadeOutSeconds = MUSIC_FADE_OUT_SECONDS;
p.m_LengthSeconds = fSecondsToStartFadingOutMusic +
MUSIC_FADE_OUT_SECONDS - p.m_StartSecond;
Expand Down
3 changes: 1 addition & 2 deletions src/Etterna/Screen/Others/ScreenSelectMusic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1859,7 +1859,6 @@ class LunaScreenSelectMusic : public Luna<ScreenSelectMusic>
NoteData nd;
Steps* steps = GAMESTATE->m_pCurSteps;
steps->GetNoteData(nd);
float songlength = GAMESTATE->m_pCurSong->m_fMusicLengthSeconds;
ss.Init();
SCOREMAN->camefromreplay =
false; // disallow viewing online score eval screens -mina
Expand Down Expand Up @@ -1889,7 +1888,7 @@ class LunaScreenSelectMusic : public Luna<ScreenSelectMusic>
pss.m_iSongsPlayed = 1;
GAMESTATE->SetProcessedTimingData(
GAMESTATE->m_pCurSteps->GetTimingData());
NoteDataUtil::CalculateRadarValues(nd, songlength, rv);
NoteDataUtil::CalculateRadarValues(nd, rv);
pss.m_radarPossible += rv;
RadarValues realRV;
PlayerAI::CalculateRadarValuesForReplay(realRV, rv);
Expand Down

0 comments on commit 97d1611

Please sign in to comment.