Skip to content

Commit

Permalink
Remove PlayerState SongPosition
Browse files Browse the repository at this point in the history
whats this do lets get rid of it haha
  • Loading branch information
poco0317 committed Jul 9, 2020
1 parent 88ceddf commit 37cf739
Show file tree
Hide file tree
Showing 11 changed files with 56 additions and 83 deletions.
12 changes: 5 additions & 7 deletions src/Etterna/Actor/Gameplay/ArrowEffects.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,7 @@ ArrowEffects::Update()

auto pStyle = GAMESTATE->GetCurrentStyle(PLAYER_1);
auto pCols = pStyle->m_ColumnInfo;
const auto& position = GAMESTATE->m_bIsUsingStepTiming
? GAMESTATE->m_pPlayerState->m_Position
: GAMESTATE->m_Position;
const auto& position = GAMESTATE->m_Position;
const auto field_zoom = GAMESTATE->m_pPlayerState->m_NotefieldZoom;
const float* effects =
GAMESTATE->m_pPlayerState->m_PlayerOptions.GetCurrent().m_fEffects;
Expand Down Expand Up @@ -339,7 +337,7 @@ ArrowEffects::GetYOffset(const PlayerState* pPlayerState,
bIsPastPeakOut = true;

float fYOffset = 0;
const auto& position = pPlayerState->GetDisplayedPosition();
const auto& position = GAMESTATE->m_Position;

const auto fSongBeat = position.m_fSongBeatVisible;
auto pn = pPlayerState->m_PlayerNumber;
Expand Down Expand Up @@ -680,7 +678,7 @@ ArrowEffects::GetRotationZ(const PlayerState* pPlayerState,
// As usual, enable dizzy hold heads at your own risk. -Wolfman2000
if (fEffects[PlayerOptions::EFFECT_DIZZY] != 0 &&
(DIZZY_HOLD_HEADS || !bIsHoldHead)) {
const auto fSongBeat = pPlayerState->m_Position.m_fSongBeatVisible;
const auto fSongBeat = GAMESTATE->m_Position.m_fSongBeatVisible;
auto fDizzyRotation = fNoteBeat - fSongBeat;
fDizzyRotation *= fEffects[PlayerOptions::EFFECT_DIZZY];
fDizzyRotation = fmodf(fDizzyRotation, 2 * PI);
Expand All @@ -697,7 +695,7 @@ ArrowEffects::ReceptorGetRotationZ(const PlayerState* pPlayerState)
float fRotation = 0;

if (fEffects[PlayerOptions::EFFECT_CONFUSION] != 0) {
auto fConfRotation = pPlayerState->m_Position.m_fSongBeatVisible;
auto fConfRotation = GAMESTATE->m_Position.m_fSongBeatVisible;
fConfRotation *= fEffects[PlayerOptions::EFFECT_CONFUSION];
fConfRotation = fmodf(fConfRotation, 2 * PI);
fConfRotation *= -180 / PI;
Expand Down Expand Up @@ -887,7 +885,7 @@ ArrowEffects::GetGlow(int iCol,
float
ArrowEffects::GetBrightness(const PlayerState* pPlayerState, float fNoteBeat)
{
const auto fSongBeat = pPlayerState->m_Position.m_fSongBeatVisible;
const auto fSongBeat = GAMESTATE->m_Position.m_fSongBeatVisible;
const auto fBeatsUntilStep = fNoteBeat - fSongBeat;

auto fBrightness = SCALE(fBeatsUntilStep, 0, -1, 1.f, 0.f);
Expand Down
26 changes: 11 additions & 15 deletions src/Etterna/Actor/Gameplay/NoteDisplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -630,7 +630,7 @@ NoteDisplay::DrawHoldsInRange(

const auto note_upcoming =
NoteRowToBeat(start_row) >
m_pPlayerState->GetDisplayedPosition().m_fSongBeat;
GAMESTATE->m_Position.m_fSongBeat;
any_upcoming |= note_upcoming;
}
return any_upcoming;
Expand All @@ -656,12 +656,11 @@ NoteDisplay::DrawTapsInRange(
// was in NoteField, but those aren't available here.
// Well, anyone who has to investigate hitting it can use a debugger to
// discover the values, hopefully. -Kyz
ASSERT_M(
NoteRowToBeat(tap_row) > -2000,
ssprintf("Invalid tap_row: %i, %f %f",
tap_row,
m_pPlayerState->GetDisplayedPosition().m_fSongBeat,
m_pPlayerState->GetDisplayedPosition().m_fMusicSeconds));
ASSERT_M(NoteRowToBeat(tap_row) > -2000,
ssprintf("Invalid tap_row: %i, %f %f",
tap_row,
GAMESTATE->m_Position.m_fSongBeat,
GAMESTATE->m_Position.m_fMusicSeconds));

// See if there is a hold step that begins on this index.
// Only do this if the noteskin cares.
Expand Down Expand Up @@ -710,7 +709,7 @@ NoteDisplay::DrawTapsInRange(
: field_args.fail_fade);

any_upcoming |= NoteRowToBeat(tap_row) >
m_pPlayerState->GetDisplayedPosition().m_fSongBeat;
GAMESTATE->m_Position.m_fSongBeat;

if (!PREFSMAN->m_FastNoteRendering) {
DISPLAY->ClearZBuffer();
Expand Down Expand Up @@ -752,8 +751,8 @@ NoteDisplay::SetActiveFrame(float fNoteBeat,

/* -inf ... inf */
const auto fBeatOrSecond = cache->m_bAnimationBasedOnBeats
? m_pPlayerState->m_Position.m_fSongBeat
: m_pPlayerState->m_Position.m_fMusicSeconds;
? GAMESTATE->m_Position.m_fSongBeat
: GAMESTATE->m_Position.m_fMusicSeconds;
/* -len ... +len */
auto fPercentIntoAnimation = fmodf(fBeatOrSecond, fAnimationLength);
/* -1 ... 1 */
Expand Down Expand Up @@ -1815,8 +1814,7 @@ void
NoteColumnRenderer::UpdateReceptorGhostStuff(Actor* receptor) const
{
const auto* const player_state = m_field_render_args->player_state;
const auto song_beat =
player_state->GetDisplayedPosition().m_fSongBeatVisible;
const auto song_beat = GAMESTATE->m_Position.m_fSongBeatVisible;
// sp_* will be filled with the settings from the splines.
// ae_* will be filled with the settings from ArrowEffects.
// The two together will be applied to the actor.
Expand Down Expand Up @@ -1890,9 +1888,7 @@ NoteColumnRenderer::UpdateReceptorGhostStuff(Actor* receptor) const
void
NoteColumnRenderer::DrawPrimitives()
{
m_column_render_args.song_beat =
m_field_render_args->player_state->GetDisplayedPosition()
.m_fSongBeatVisible;
m_column_render_args.song_beat = GAMESTATE->m_Position.m_fSongBeatVisible;
m_column_render_args.pos_handler = &NCR_current.m_pos_handler;
m_column_render_args.rot_handler = &NCR_current.m_rot_handler;
m_column_render_args.zoom_handler = &NCR_current.m_zoom_handler;
Expand Down
16 changes: 6 additions & 10 deletions src/Etterna/Actor/Gameplay/NoteField.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -344,8 +344,7 @@ NoteField::Update(float fDeltaTime)

// update m_fBoardOffsetPixels, m_fCurrentBeatLastUpdate,
// m_fYPosCurrentBeatLastUpdate
const auto fCurrentBeat =
m_pPlayerState->GetDisplayedPosition().m_fSongBeat;
const auto fCurrentBeat = GAMESTATE->m_Position.m_fSongBeat;
const auto bTweeningOn =
m_sprBoard->GetCurrentDiffuseAlpha() >= 0.98 &&
m_sprBoard->GetCurrentDiffuseAlpha() < 1.00; // HACK
Expand Down Expand Up @@ -634,13 +633,12 @@ FindDisplayedBeats(const PlayerState* pPlayerState,
int iDrawDistanceAfterTargetsPixels,
int iDrawDistanceBeforeTargetsPixels)
{
auto fFirstBeatToDraw =
pPlayerState->GetDisplayedPosition().m_fSongBeatVisible;
auto fFirstBeatToDraw = GAMESTATE->m_Position.m_fSongBeatVisible;
auto fLastBeatToDraw = fFirstBeatToDraw;
const auto fSpeedMultiplier =
pPlayerState->GetDisplayedTiming().GetDisplayedSpeedPercent(
pPlayerState->GetDisplayedPosition().m_fSongBeatVisible,
pPlayerState->GetDisplayedPosition().m_fMusicSecondsVisible);
GAMESTATE->m_Position.m_fSongBeatVisible,
GAMESTATE->m_Position.m_fMusicSecondsVisible);

bool bBoomerang;
{
Expand Down Expand Up @@ -696,11 +694,9 @@ FindDisplayedBeats(const PlayerState* pPlayerState,

if (fSpeedMultiplier < 0.75f) {
fFirstBeatToDraw =
std::min(fFirstBeatToDraw,
pPlayerState->GetDisplayedPosition().m_fSongBeat + 16);
std::min(fFirstBeatToDraw, GAMESTATE->m_Position.m_fSongBeat + 16);
fLastBeatToDraw =
std::min(fLastBeatToDraw,
pPlayerState->GetDisplayedPosition().m_fSongBeat + 16);
std::min(fLastBeatToDraw, GAMESTATE->m_Position.m_fSongBeat + 16);
}

firstBeat = fFirstBeatToDraw;
Expand Down
37 changes: 18 additions & 19 deletions src/Etterna/Actor/Gameplay/Player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,7 @@ Player::Load()

m_LastTapNoteScore = TNS_None;
// The editor can start playing in the middle of the song.
const auto iNoteRow = BeatToNoteRow(m_pPlayerState->m_Position.m_fSongBeat);
const auto iNoteRow = BeatToNoteRow(GAMESTATE->m_Position.m_fSongBeat);
m_iFirstUncrossedRow = iNoteRow - 1;
m_pJudgedRows->Reset(iNoteRow);

Expand Down Expand Up @@ -734,7 +734,7 @@ Player::Reload()

m_LastTapNoteScore = TNS_None;

const auto iNoteRow = BeatToNoteRow(m_pPlayerState->m_Position.m_fSongBeat);
const auto iNoteRow = BeatToNoteRow(GAMESTATE->m_Position.m_fSongBeat);
m_iFirstUncrossedRow = iNoteRow - 1;
m_pJudgedRows->Reset(iNoteRow);

Expand Down Expand Up @@ -934,7 +934,7 @@ void
Player::UpdateHoldsAndRolls(float fDeltaTime,
const std::chrono::steady_clock::time_point& now)
{
const auto fSongBeat = m_pPlayerState->m_Position.m_fSongBeat;
const auto fSongBeat = GAMESTATE->m_Position.m_fSongBeat;
const auto iSongRow = BeatToNoteRow(fSongBeat);
// handle Autoplay for rolls
if (m_pPlayerState->m_PlayerController != PC_HUMAN) {
Expand Down Expand Up @@ -1036,10 +1036,10 @@ Player::UpdateHoldsAndRolls(float fDeltaTime,
void
Player::UpdateCrossedRows(const std::chrono::steady_clock::time_point& now)
{
const auto iRowNow = BeatToNoteRow(m_pPlayerState->m_Position.m_fSongBeat);
const auto iRowNow = BeatToNoteRow(GAMESTATE->m_Position.m_fSongBeat);
if (iRowNow >= 0) {
if (GAMESTATE->IsPlayerEnabled(m_pPlayerState)) {
if (m_pPlayerState->m_Position.m_bDelay) {
if (GAMESTATE->m_Position.m_bDelay) {
if (!m_bDelay) {
m_bDelay = true;
}
Expand Down Expand Up @@ -1727,7 +1727,7 @@ Player::GetClosestNote(int col,
}

// Get the current time, previous time, and next time.
const auto fNoteTime = m_pPlayerState->m_Position.m_fMusicSeconds;
const auto fNoteTime = GAMESTATE->m_Position.m_fMusicSeconds;
const auto fNextTime = m_Timing->WhereUAtBro(iNextIndex);
const auto fPrevTime = m_Timing->WhereUAtBro(iPrevIndex);

Expand Down Expand Up @@ -1813,7 +1813,7 @@ Player::GetClosestNonEmptyRow(int iNoteRow,
}

// Get the current time, previous time, and next time.
const auto fNoteTime = m_pPlayerState->m_Position.m_fMusicSeconds;
const auto fNoteTime = GAMESTATE->m_Position.m_fMusicSeconds;
const auto fNextTime = m_Timing->WhereUAtBro(iNextRow);
const auto fPrevTime = m_Timing->WhereUAtBro(iPrevRow);

Expand Down Expand Up @@ -1850,7 +1850,7 @@ Player::DoTapScoreNone()
}

if (PENALIZE_TAP_SCORE_NONE && m_pPlayerState != nullptr) {
SetJudgment(BeatToNoteRow(m_pPlayerState->m_Position.m_fSongBeat),
SetJudgment(BeatToNoteRow(GAMESTATE->m_Position.m_fSongBeat),
-1,
TAP_EMPTY,
TNS_Miss,
Expand All @@ -1863,7 +1863,7 @@ void
Player::ScoreAllActiveHoldsLetGo()
{
if (PENALIZE_TAP_SCORE_NONE) {
const auto fSongBeat = m_pPlayerState->m_Position.m_fSongBeat;
const auto fSongBeat = GAMESTATE->m_Position.m_fSongBeat;
const auto iSongRow = BeatToNoteRow(fSongBeat);

// Score all active holds to NotHeld
Expand Down Expand Up @@ -1962,17 +1962,16 @@ Player::Step(int col,
std::chrono::steady_clock::now() - tm;
auto stepAgo = stepDelta.count() - padStickSeconds;

const auto fLastBeatUpdate =
m_pPlayerState->m_Position.m_LastBeatUpdate.Ago();
const auto fLastBeatUpdate = GAMESTATE->m_Position.m_LastBeatUpdate.Ago();
const auto fPositionSeconds =
m_pPlayerState->m_Position.m_fMusicSeconds - stepAgo;
GAMESTATE->m_Position.m_fMusicSeconds - stepAgo;
const auto fTimeSinceStep = stepAgo;

// idk if this is the correct value for input logs but we'll use them to
// test -mina ok this is 100% not the place to do this
// m_pPlayerStageStats->InputData.emplace_back(fPositionSeconds);

auto fSongBeat = m_pPlayerState->m_Position.m_fSongBeat;
auto fSongBeat = GAMESTATE->m_Position.m_fSongBeat;

if (GAMESTATE->m_pCurSteps != nullptr) {
fSongBeat = m_Timing->GetBeatFromElapsedTime(fPositionSeconds);
Expand Down Expand Up @@ -2077,11 +2076,11 @@ Player::Step(int col,
if (iSongRow < skipstart || iSongRow > static_cast<int>(nerv.size()) - 10) {
iStepSearchRows =
max(BeatToNoteRow(m_Timing->GetBeatFromElapsedTime(
m_pPlayerState->m_Position.m_fMusicSeconds +
GAMESTATE->m_Position.m_fMusicSeconds +
StepSearchDistance)) -
iSongRow,
iSongRow - BeatToNoteRow(m_Timing->GetBeatFromElapsedTime(
m_pPlayerState->m_Position.m_fMusicSeconds -
GAMESTATE->m_Position.m_fMusicSeconds -
StepSearchDistance))) +
ROWS_PER_BEAT;
} else {
Expand Down Expand Up @@ -2148,7 +2147,7 @@ Player::Step(int col,
* GAMESTATE->m_LastBeatUpdate. Figure out what the music time
* is as of now. */
const auto fCurrentMusicSeconds =
m_pPlayerState->m_Position.m_fMusicSeconds +
GAMESTATE->m_Position.m_fMusicSeconds +
(fLastBeatUpdate *
GAMESTATE->m_SongOptions.GetCurrent().m_fMusicRate);

Expand Down Expand Up @@ -2648,7 +2647,7 @@ Player::UpdateTapNotesMissedOlderThan(float fMissIfOlderThanSeconds)
// fMissIfOlderThanThisBeat );
int iMissIfOlderThanThisRow;
const auto fEarliestTime =
m_pPlayerState->m_Position.m_fMusicSeconds - fMissIfOlderThanSeconds;
GAMESTATE->m_Position.m_fMusicSeconds - fMissIfOlderThanSeconds;
{
TimingData::GetBeatArgs beat_info;
beat_info.elapsed_time = fEarliestTime;
Expand Down Expand Up @@ -2710,7 +2709,7 @@ Player::UpdateJudgedRows(float /*fDeltaTime*/)
{
// Look into the future only as far as we need to
const auto iEndRow = BeatToNoteRow(m_Timing->GetBeatFromElapsedTime(
m_pPlayerState->m_Position.m_fMusicSeconds +
GAMESTATE->m_Position.m_fMusicSeconds +
GetMaxStepDistanceSeconds()));
auto bAllJudged = true;

Expand Down Expand Up @@ -3379,7 +3378,7 @@ Player::SetCombo(unsigned int iCombo, unsigned int iMisses)
auto bPastBeginning = false;

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

if (m_bSendJudgmentAndComboMessages) {
Expand Down
18 changes: 9 additions & 9 deletions src/Etterna/Actor/Gameplay/PlayerReplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ PlayerReplay::UpdateHoldsAndRolls(
float fDeltaTime,
const std::chrono::steady_clock::time_point& now)
{
const auto fSongBeat = m_pPlayerState->m_Position.m_fSongBeat;
const auto fSongBeat = GAMESTATE->m_Position.m_fSongBeat;
const auto iSongRow = BeatToNoteRow(fSongBeat);

// Auto tap rolls
Expand Down Expand Up @@ -229,7 +229,7 @@ PlayerReplay::Update(float fDeltaTime)

ActorFrame::Update(fDeltaTime);

const auto fSongBeat = m_pPlayerState->m_Position.m_fSongBeat;
const auto fSongBeat = GAMESTATE->m_Position.m_fSongBeat;
const auto iSongRow = BeatToNoteRow(fSongBeat);

ArrowEffects::SetCurrentOptions(
Expand Down Expand Up @@ -401,7 +401,7 @@ PlayerReplay::UpdateTapNotesMissedOlderThan(float fMissIfOlderThanSeconds)
{
int iMissIfOlderThanThisRow;
const auto fEarliestTime =
m_pPlayerState->m_Position.m_fMusicSeconds - fMissIfOlderThanSeconds;
GAMESTATE->m_Position.m_fMusicSeconds - fMissIfOlderThanSeconds;
{
TimingData::GetBeatArgs beat_info;
beat_info.elapsed_time = fEarliestTime;
Expand Down Expand Up @@ -466,9 +466,9 @@ PlayerReplay::Step(int col,
const auto stepAgo = stepDelta.count() - padStickSeconds;

const auto fLastBeatUpdate =
m_pPlayerState->m_Position.m_LastBeatUpdate.Ago();
GAMESTATE->m_Position.m_LastBeatUpdate.Ago();
const auto fPositionSeconds =
m_pPlayerState->m_Position.m_fMusicSeconds - stepAgo;
GAMESTATE->m_Position.m_fMusicSeconds - stepAgo;
const auto fTimeSinceStep = stepAgo;

// LOG->Trace(ssprintf("col %d\n\trow %d", col, row));
Expand All @@ -477,7 +477,7 @@ PlayerReplay::Step(int col,
// test -mina ok this is 100% not the place to do this
// m_pPlayerStageStats->InputData.emplace_back(fPositionSeconds);

auto fSongBeat = m_pPlayerState->m_Position.m_fSongBeat;
auto fSongBeat = GAMESTATE->m_Position.m_fSongBeat;

if (GAMESTATE->m_pCurSteps)
fSongBeat = m_Timing->GetBeatFromElapsedTime(fPositionSeconds);
Expand Down Expand Up @@ -561,11 +561,11 @@ PlayerReplay::Step(int col,
if (iSongRow < skipstart || iSongRow > static_cast<int>(nerv.size()) - 10) {
iStepSearchRows =
std::max(BeatToNoteRow(m_Timing->GetBeatFromElapsedTime(
m_pPlayerState->m_Position.m_fMusicSeconds +
GAMESTATE->m_Position.m_fMusicSeconds +
StepSearchDistance)) -
iSongRow,
iSongRow - BeatToNoteRow(m_Timing->GetBeatFromElapsedTime(
m_pPlayerState->m_Position.m_fMusicSeconds -
GAMESTATE->m_Position.m_fMusicSeconds -
StepSearchDistance))) +
ROWS_PER_BEAT;
} else {
Expand Down Expand Up @@ -625,7 +625,7 @@ PlayerReplay::Step(int col,
* GAMESTATE->m_LastBeatUpdate. Figure out what the music time is as
* of now. */
const auto fCurrentMusicSeconds =
m_pPlayerState->m_Position.m_fMusicSeconds +
GAMESTATE->m_Position.m_fMusicSeconds +
(fLastBeatUpdate *
GAMESTATE->m_SongOptions.GetCurrent().m_fMusicRate);

Expand Down
2 changes: 1 addition & 1 deletion src/Etterna/Models/Misc/GameplayAssist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ GameplayAssist::PlayTicks(const NoteData& nd, const PlayerState* ps)
* fPositionSeconds ahead. This is just to make sure that we request the
* sound early enough for it to come out on time; the actual precise timing
* is handled by SetStartTime. */
auto& position = GAMESTATE->m_pPlayerState->m_Position;
auto& position = GAMESTATE->m_Position;
auto fPositionSeconds = position.m_fMusicSeconds;

// float fPositionSeconds = GAMESTATE->m_Position.m_fMusicSeconds;
Expand Down
Loading

0 comments on commit 37cf739

Please sign in to comment.