Skip to content

Commit

Permalink
Clean up a little more Gameplay garbage
Browse files Browse the repository at this point in the history
for constructors and practice mode update function
also set practice mode to use the non blocking stuff
  • Loading branch information
poco0317 committed Sep 22, 2019
1 parent 7f6148d commit 0952d74
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 48 deletions.
2 changes: 0 additions & 2 deletions src/Etterna/Screen/Gameplay/ScreenGameplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ ScreenGameplay::ScreenGameplay()
m_pSongBackground = NULL;
m_pSongForeground = NULL;
m_delaying_ready_announce = false;
GAMESTATE->m_AdjustTokensBySongCostForFinalStageCheck = false;
DLMAN->UpdateDLSpeed(true);
if (GamePreferences::m_AutoPlay != PC_REPLAY) {
LOG->Trace("Unloading replaydata.");
Expand Down Expand Up @@ -362,7 +361,6 @@ ScreenGameplay::InitSongQueues()

ScreenGameplay::~ScreenGameplay()
{
GAMESTATE->m_AdjustTokensBySongCostForFinalStageCheck = true;
if (this->IsFirstUpdate()) {
/* We never received any updates. That means we were deleted without
* being used, and never actually played. (This can happen when backing
Expand Down
86 changes: 66 additions & 20 deletions src/Etterna/Screen/Gameplay/ScreenGameplayPractice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "Etterna/Actor/Gameplay/Player.h"
#include "Etterna/Models/Misc/RadarValues.h"
#include "Etterna/Singletons/DownloadManager.h"
#include "Etterna/Singletons/GameSoundManager.h"

#include "Etterna/Models/Lua/LuaBinding.h"
#include "Etterna/Singletons/LuaManager.h"
Expand All @@ -35,11 +36,7 @@ ScreenGameplayPractice::FillPlayerInfo(PlayerInfo* playerInfoOut)

ScreenGameplayPractice::ScreenGameplayPractice()
{
m_pSongBackground = NULL;
m_pSongForeground = NULL;
m_delaying_ready_announce = false;
GAMESTATE->m_AdjustTokensBySongCostForFinalStageCheck = false;
DLMAN->UpdateDLSpeed(true);
// covered by base class constructor
}

void
Expand All @@ -50,26 +47,74 @@ ScreenGameplayPractice::Init()

ScreenGameplayPractice::~ScreenGameplayPractice()
{
GAMESTATE->m_AdjustTokensBySongCostForFinalStageCheck = true;
if (this->IsFirstUpdate()) {
/* We never received any updates. That means we were deleted without
* being used, and never actually played. (This can happen when backing
* out of ScreenStage.) Cancel the stage. */
GAMESTATE->CancelStage();
}

if (PREFSMAN->m_verbose_log > 1)
LOG->Trace("ScreenGameplayReplay::~ScreenGameplayReplay()");
}

void
ScreenGameplayPractice::Update(float fDeltaTime)
{
if (GAMESTATE->m_pCurSong == NULL) {
Screen::Update(fDeltaTime);
return;
}

UpdateSongPosition(fDeltaTime);

SAFE_DELETE(m_pSongBackground);
SAFE_DELETE(m_pSongForeground);
if (m_bZeroDeltaOnNextUpdate) {
Screen::Update(0);
m_bZeroDeltaOnNextUpdate = false;
} else {
Screen::Update(fDeltaTime);
}

if (m_pSoundMusic != nullptr)
m_pSoundMusic->StopPlaying();
if (SCREENMAN->GetTopScreen() != this)
return;

m_AutoKeysounds.Update(fDeltaTime);

m_vPlayerInfo.m_SoundEffectControl.Update(fDeltaTime);

{
float fSpeed = GAMESTATE->m_SongOptions.GetCurrent().m_fMusicRate;
RageSoundParams p = m_pSoundMusic->GetParams();
if (std::fabs(p.m_fSpeed - fSpeed) > 0.01f && fSpeed >= 0.0f) {
p.m_fSpeed = fSpeed;
m_pSoundMusic->SetParams(p);
}
}

switch (m_DancingState) {
case STATE_DANCING: {

// Update living players' alive time
// HACK: Don't scale alive time when using tab/tilde. Instead of
// accumulating time from a timer, this time should instead be tied
// to the music position.
float fUnscaledDeltaTime = m_timerGameplaySeconds.GetDeltaTime();
m_vPlayerInfo.GetPlayerStageStats()->m_fAliveSeconds +=
fUnscaledDeltaTime *
GAMESTATE->m_SongOptions.GetCurrent().m_fMusicRate;

// update fGameplaySeconds
STATSMAN->m_CurStageStats.m_fGameplaySeconds += fUnscaledDeltaTime;
float curBeat = GAMESTATE->m_Position.m_fSongBeat;
Song& s = *GAMESTATE->m_pCurSong;

if (curBeat >= s.GetFirstBeat() && curBeat < s.GetLastBeat()) {
STATSMAN->m_CurStageStats.m_fStepsSeconds += fUnscaledDeltaTime;
}
}
default:
break;
}

m_GameplayAssist.StopPlaying();
PlayTicks();
SendCrossedMessages();

DLMAN->UpdateDLSpeed(false);
// ArrowEffects::Update call moved because having it happen once per
// NoteField (which means twice in two player) seemed wasteful. -Kyz
ArrowEffects::Update();
}

void
Expand Down Expand Up @@ -112,7 +157,8 @@ ScreenGameplayPractice::TogglePracticePause()
void
ScreenGameplayPractice::SetPracticeSongPosition(float newPositionSeconds)
{
m_pSoundMusic->SetPositionSeconds(newPositionSeconds);
SOUND->SetSoundPosition(m_pSoundMusic, newPositionSeconds);
// m_pSoundMusic->SetPositionSeconds(newPositionSeconds);

bool isPaused = GAMESTATE->GetPaused();
m_pSoundMusic->Pause(isPaused);
Expand Down
3 changes: 1 addition & 2 deletions src/Etterna/Screen/Gameplay/ScreenGameplayPractice.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,11 @@ class ScreenGameplayPractice : public ScreenGameplay
{
public:
virtual void FillPlayerInfo(PlayerInfo* playerInfoOut);

ScreenGameplayPractice();
void Init() override;
~ScreenGameplayPractice() override;

// void Update(float fDeltaTime) override;
void Update(float fDeltaTime) override;
// bool Input(const InputEventPlus& input) override;

// Lua
Expand Down
24 changes: 0 additions & 24 deletions src/Etterna/Screen/Gameplay/ScreenGameplayReplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,6 @@ ScreenGameplayReplay::ScreenGameplayReplay()
{
ASSERT_M(PlayerAI::pScoreData != nullptr,
"Replay Highscore Info was empty.");

m_pSongBackground = NULL;
m_pSongForeground = NULL;
m_delaying_ready_announce = false;
GAMESTATE->m_AdjustTokensBySongCostForFinalStageCheck = false;
DLMAN->UpdateDLSpeed(true);
}

void
Expand All @@ -58,26 +52,8 @@ ScreenGameplayReplay::Init()

ScreenGameplayReplay::~ScreenGameplayReplay()
{
GAMESTATE->m_AdjustTokensBySongCostForFinalStageCheck = true;
if (this->IsFirstUpdate()) {
/* We never received any updates. That means we were deleted without
* being used, and never actually played. (This can happen when backing
* out of ScreenStage.) Cancel the stage. */
GAMESTATE->CancelStage();
}

if (PREFSMAN->m_verbose_log > 1)
LOG->Trace("ScreenGameplayReplay::~ScreenGameplayReplay()");

SAFE_DELETE(m_pSongBackground);
SAFE_DELETE(m_pSongForeground);

if (m_pSoundMusic != nullptr)
m_pSoundMusic->StopPlaying();

m_GameplayAssist.StopPlaying();

DLMAN->UpdateDLSpeed(false);
}

void
Expand Down

0 comments on commit 0952d74

Please sign in to comment.