diff --git a/src/Etterna/Models/Misc/StageStats.cpp b/src/Etterna/Models/Misc/StageStats.cpp index ec99c887bc..fa184a64d1 100644 --- a/src/Etterna/Models/Misc/StageStats.cpp +++ b/src/Etterna/Models/Misc/StageStats.cpp @@ -719,8 +719,11 @@ StageStats::FinalizeScores(bool /*bSummary*/) // happens -mina mostrecentscorekey = PlayerAI::pScoreData->GetScoreKey(); SCOREMAN->PutScoreAtTheTop(mostrecentscorekey); - SCOREMAN->GetMostRecentScore()->SetRadarValues( - hs.GetRadarValues()); + if (SCOREMAN->GetMostRecentScore() == nullptr) + Locator::getLogger()->warn("MOST RECENT SCORE WAS EMPTY."); + else + SCOREMAN->GetMostRecentScore()->SetRadarValues( + hs.GetRadarValues()); } } zzz->m_lastSong.FromSong(GAMESTATE->m_pCurSong); diff --git a/src/Etterna/Screen/Others/ScreenEvaluation.cpp b/src/Etterna/Screen/Others/ScreenEvaluation.cpp index 38cfe5fb12..c3677d6401 100644 --- a/src/Etterna/Screen/Others/ScreenEvaluation.cpp +++ b/src/Etterna/Screen/Others/ScreenEvaluation.cpp @@ -330,6 +330,11 @@ class LunaScreenEvaluation : public Luna { CHECKPOINT_M("Checking for invalid modifiers on Highscore via Lua"); HighScore* hs = SCOREMAN->GetMostRecentScore(); + if (hs == nullptr) { + Locator::getLogger()->warn("MOST RECENT SCORE WAS EMPTY."); + lua_pushboolean(L, true); + return 1; + } CHECKPOINT_M("Getting Player Options from HighScore..."); PlayerOptions potmp; potmp.FromString(hs->GetModifiers()); diff --git a/src/Etterna/Screen/Others/ScreenSelectMusic.cpp b/src/Etterna/Screen/Others/ScreenSelectMusic.cpp index 0ba141aaa2..dcc3dd618f 100644 --- a/src/Etterna/Screen/Others/ScreenSelectMusic.cpp +++ b/src/Etterna/Screen/Others/ScreenSelectMusic.cpp @@ -1868,7 +1868,7 @@ class LunaScreenSelectMusic : public Luna SCOREMAN->camefromreplay = false; // disallow viewing online score eval screens -mina auto* score = SCOREMAN->GetMostRecentScore(); - if (!score->LoadReplayData()) { + if (score == nullptr || !score->LoadReplayData()) { SCREENMAN->SystemMessage( "Failed to load Replay Data for some reason."); lua_pushboolean(L, false); diff --git a/src/Etterna/Singletons/ScoreManager.cpp b/src/Etterna/Singletons/ScoreManager.cpp index 3900fe099c..7f43eeb396 100644 --- a/src/Etterna/Singletons/ScoreManager.cpp +++ b/src/Etterna/Singletons/ScoreManager.cpp @@ -1311,7 +1311,10 @@ class LunaScoreManager : public Luna { // this _should_ always be viable if only called from eval auto* last = p->GetMostRecentScore(); - last->PushSelf(L); + if (last == nullptr) + lua_pushnil(L); + else + last->PushSelf(L); return 1; } diff --git a/src/Etterna/Singletons/ScoreManager.h b/src/Etterna/Singletons/ScoreManager.h index db72eabcc7..1a671de0f0 100644 --- a/src/Etterna/Singletons/ScoreManager.h +++ b/src/Etterna/Singletons/ScoreManager.h @@ -232,7 +232,9 @@ class ScoreManager "Temp score for Replay & Practice viewing was empty."); return tempscoreforonlinereplayviewing; } - ASSERT_M(!AllScores.empty(), "Profile has no Scores."); + // Allow Lua to receive null HS here + if (AllScores.empty()) + return nullptr; return AllScores.back(); } void PutScoreAtTheTop(const std::string& scorekey)