Skip to content

Commit

Permalink
Override RestartGameplay in GameplaySyncMachine for safer use
Browse files Browse the repository at this point in the history
without overriding here, it uses the natural restarting process
and because of several reasons, that crashes the game (continuity of some things is broken and we get null derefs)
  • Loading branch information
poco0317 committed Jan 9, 2021
1 parent f0951e1 commit 83b2fc1
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Etterna/Screen/Gameplay/ScreenGameplay.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ class ScreenGameplay : public ScreenWithMenuElements
virtual void StageFinished(bool bBackedOut);
bool AllAreFailing();

void RestartGameplay();
virtual void RestartGameplay();

virtual void SetupNoteDataFromRow(Steps* pSteps, int row);

Expand Down
9 changes: 9 additions & 0 deletions src/Etterna/Screen/Gameplay/ScreenGameplaySyncMachine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,15 @@ ScreenGameplaySyncMachine::ResetAndRestartCurrentSong()
AdjustSync::ResetAutosync();
}

void
ScreenGameplaySyncMachine::RestartGameplay()
{
// Override normal RestartGameplay to just do this thing
// because otherwise some weird continuity issues arise
// and we crash
ResetAndRestartCurrentSong();
}

static LocalizedString OLD_OFFSET("ScreenGameplaySyncMachine", "Old offset");
static LocalizedString NEW_OFFSET("ScreenGameplaySyncMachine", "New offset");
static LocalizedString COLLECTING_SAMPLE("ScreenGameplaySyncMachine",
Expand Down
1 change: 1 addition & 0 deletions src/Etterna/Screen/Gameplay/ScreenGameplaySyncMachine.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class ScreenGameplaySyncMachine : public ScreenGameplayNormal

void HandleScreenMessage(const ScreenMessage& SM) override;
void ResetAndRestartCurrentSong();
void RestartGameplay() override;

protected:
bool UseSongBackgroundAndForeground() const override { return false; }
Expand Down

0 comments on commit 83b2fc1

Please sign in to comment.