Skip to content

Commit

Permalink
remove the concept of persistent profiles from the codebase
Browse files Browse the repository at this point in the history
  • Loading branch information
MinaciousGrace committed Jul 2, 2020
1 parent beed404 commit 52f2434
Show file tree
Hide file tree
Showing 10 changed files with 41 additions and 100 deletions.
59 changes: 26 additions & 33 deletions src/Etterna/Actor/Menus/MusicWheelItem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -279,10 +279,7 @@ MusicWheelItem::RefreshGrades()
dc = GAMESTATE->m_PreferredDifficulty;

ProfileSlot ps;
if (PROFILEMAN->IsPersistentProfile(PLAYER_1))
ps = static_cast<ProfileSlot>(PLAYER_1);
else
return;
ps = static_cast<ProfileSlot>(PLAYER_1);

StepsType st;
if (GAMESTATE->m_pCurSteps)
Expand All @@ -295,37 +292,33 @@ MusicWheelItem::RefreshGrades()
HighScoreList* BestpHSL = NULL;
Grade gradeBest = Grade_Invalid;
Difficulty dcBest = Difficulty_Invalid;
if (PROFILEMAN->IsPersistentProfile(ps)) {
if (pWID->m_pSong != nullptr) {
bool hasCurrentStyleSteps = false;
FOREACH_ENUM_N(Difficulty, 6, i)
{
Steps* pSteps =
SongUtil::GetStepsByDifficulty(pWID->m_pSong, st, i);
if (pSteps != NULL) {
hasCurrentStyleSteps = true;
Grade dcg =
SCOREMAN->GetBestGradeFor(pSteps->GetChartKey());
if (gradeBest >= dcg) {
dcBest = i;
gradeBest = dcg;
}
if (pWID->m_pSong != nullptr) {
bool hasCurrentStyleSteps = false;
FOREACH_ENUM_N(Difficulty, 6, i)
{
Steps* pSteps =
SongUtil::GetStepsByDifficulty(pWID->m_pSong, st, i);
if (pSteps != NULL) {
hasCurrentStyleSteps = true;
Grade dcg = SCOREMAN->GetBestGradeFor(pSteps->GetChartKey());
if (gradeBest >= dcg) {
dcBest = i;
gradeBest = dcg;
}
}
// If no grade was found for the current style/stepstype
if (!hasCurrentStyleSteps) {
// Get the best grade among all steps
auto& allSteps = pWID->m_pSong->GetAllSteps();
for (auto& stepsPtr : allSteps) {
if (stepsPtr->m_StepsType ==
st) // Skip already checked steps of type st
continue;
Grade dcg =
SCOREMAN->GetBestGradeFor(stepsPtr->GetChartKey());
if (gradeBest >= dcg) {
dcBest = stepsPtr->GetDifficulty();
gradeBest = dcg;
}
}
// If no grade was found for the current style/stepstype
if (!hasCurrentStyleSteps) {
// Get the best grade among all steps
auto& allSteps = pWID->m_pSong->GetAllSteps();
for (auto& stepsPtr : allSteps) {
if (stepsPtr->m_StepsType ==
st) // Skip already checked steps of type st
continue;
Grade dcg = SCOREMAN->GetBestGradeFor(stepsPtr->GetChartKey());
if (gradeBest >= dcg) {
dcBest = stepsPtr->GetDifficulty();
gradeBest = dcg;
}
}
}
Expand Down
4 changes: 1 addition & 3 deletions src/Etterna/Models/Misc/StageStats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -647,9 +647,7 @@ StageStats::FinalizeScores(bool bSummary)

// whether or not to save scores when the stage was failed depends on if
// this is a course or not... it's handled below in the switch.
RString sPlayerGuid = PROFILEMAN->IsPersistentProfile(PLAYER_1)
? PROFILEMAN->GetProfile(PLAYER_1)->m_sGuid
: RString("");
RString sPlayerGuid = PROFILEMAN->GetProfile(PLAYER_1)->m_sGuid;
m_player.m_HighScore = FillInHighScore(m_player,
*GAMESTATE->m_pPlayerState,
RANKING_TO_FILL_IN_MARKER,
Expand Down
2 changes: 0 additions & 2 deletions src/Etterna/Models/Songs/SongUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -595,8 +595,6 @@ SongUtil::SortSongPointerArrayByNumPlays(vector<Song*>& vpSongsInOut,
ProfileSlot slot,
bool bDescending)
{
if (!PROFILEMAN->IsPersistentProfile(slot))
return; // nothing to do since we don't have data
Profile* pProfile = PROFILEMAN->GetProfile(slot);
SortSongPointerArrayByNumPlays(vpSongsInOut, pProfile, bDescending);
}
Expand Down
2 changes: 0 additions & 2 deletions src/Etterna/Models/StepsAndStyles/StepsUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ StepsUtil::SortStepsPointerArrayByNumPlays(vector<Steps*>& vStepsPointers,
ProfileSlot slot,
bool bDescending)
{
if (!PROFILEMAN->IsPersistentProfile(slot))
return; // nothing to do since we don't have data
Profile* pProfile = PROFILEMAN->GetProfile(slot);
SortStepsPointerArrayByNumPlays(vStepsPointers, pProfile, bDescending);
}
Expand Down
14 changes: 4 additions & 10 deletions src/Etterna/Screen/Others/ScreenDebugOverlay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -884,12 +884,6 @@ class DebugLineShowMasks : public IDebugLine
};

static ProfileSlot g_ProfileSlot = ProfileSlot_Player1;
static bool
IsSelectProfilePersistent()
{
return PROFILEMAN->IsPersistentProfile(
static_cast<PlayerNumber>(g_ProfileSlot));
}

class DebugLineProfileSlot : public IDebugLine
{
Expand All @@ -905,7 +899,7 @@ class DebugLineProfileSlot : public IDebugLine
return RString();
}
}
bool IsEnabled() override { return IsSelectProfilePersistent(); }
bool IsEnabled() override { return true; }
RString GetPageName() const override { return "Profiles"; }
void DoAndLog(RString& sMessageOut) override
{
Expand All @@ -924,7 +918,7 @@ class DebugLineClearProfileStats : public IDebugLine
return CLEAR_PROFILE_STATS.GetValue();
}
RString GetDisplayValue() override { return RString(); }
bool IsEnabled() override { return IsSelectProfilePersistent(); }
bool IsEnabled() override { return true; }
RString GetPageName() const override { return "Profiles"; }
void DoAndLog(RString& sMessageOut) override
{
Expand Down Expand Up @@ -1004,7 +998,7 @@ class DebugLineFillProfileStats : public IDebugLine
{
RString GetDisplayTitle() override { return FILL_PROFILE_STATS.GetValue(); }
RString GetDisplayValue() override { return RString(); }
bool IsEnabled() override { return IsSelectProfilePersistent(); }
bool IsEnabled() override { return true; }
RString GetPageName() const override { return "Profiles"; }
void DoAndLog(RString& sMessageOut) override
{
Expand Down Expand Up @@ -1237,7 +1231,7 @@ class DebugLineWriteProfiles : public IDebugLine
{
RString GetDisplayTitle() override { return WRITE_PROFILES.GetValue(); }
RString GetDisplayValue() override { return RString(); }
bool IsEnabled() override { return IsSelectProfilePersistent(); }
bool IsEnabled() override { return true; }
RString GetPageName() const override { return "Profiles"; }
void DoAndLog(RString& sMessageOut) override
{
Expand Down
2 changes: 1 addition & 1 deletion src/Etterna/Screen/Others/ScreenEvaluation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ ScreenEvaluation::Input(const InputEventPlus& input)
// with an inflated profile size
// Otherwise, you can tap away at the screenshot button without
// holding shift.
if (bHoldingShift && PROFILEMAN->IsPersistentProfile(pn)) {
if (bHoldingShift) {
if (!m_bSavedScreenshot) {
Profile* pProfile = PROFILEMAN->GetProfile(pn);
sDir = PROFILEMAN->GetProfileDir((ProfileSlot)pn) +
Expand Down
8 changes: 1 addition & 7 deletions src/Etterna/Screen/Others/ScreenSystemLayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,7 @@ GetCreditsMessage(PlayerNumber pn)
CREDITS_LOADED_FROM_LAST_GOOD_APPEND.GetValue();
else if (PROFILEMAN->LastLoadWasTamperedOrCorrupt(pn))
return CREDITS_LOAD_FAILED.GetValue();
// Prefer the name of the profile over the name of the card.
else if (PROFILEMAN->IsPersistentProfile(pn))
return pProfile->GetDisplayNameOrHighScoreName();
else if (GAMESTATE->PlayersCanJoin())
return CREDITS_INSERT_CARD.GetValue();
else
return RString();
return pProfile->GetDisplayNameOrHighScoreName();
}
return RString();
}
Expand Down
22 changes: 1 addition & 21 deletions src/Etterna/Singletons/GameState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -421,11 +421,6 @@ GameState::BeginGame()
void
GameState::LoadProfiles(bool bLoadEdits)
{
// If a profile is already loaded, this was already called.
bool bPersistent = PROFILEMAN->IsPersistentProfile(PLAYER_1);
if (!bPersistent)
return;

bool bSuccess = PROFILEMAN->LoadFirstAvailableProfile(
PLAYER_1, bLoadEdits); // load full profile

Expand All @@ -448,9 +443,6 @@ GameState::SavePlayerProfiles()
void
GameState::SavePlayerProfile(PlayerNumber pn)
{
if (!PROFILEMAN->IsPersistentProfile(pn))
return;

// AutoplayCPU should not save scores. -aj
// xxx: this MAY cause issues with Multiplayer. However, without a working
// Multiplayer build, we'll never know. -aj
Expand All @@ -463,10 +455,6 @@ GameState::SavePlayerProfile(PlayerNumber pn)
bool
GameState::HaveProfileToLoad()
{
// We won't load this profile if it's already loaded.
if (PROFILEMAN->IsPersistentProfile(PLAYER_1))
return false;

if (!PROFILEMAN->m_sDefaultLocalProfileID[PLAYER_1].Get().empty())
return true;

Expand All @@ -476,9 +464,7 @@ GameState::HaveProfileToLoad()
bool
GameState::HaveProfileToSave()
{
if (PROFILEMAN->IsPersistentProfile(PLAYER_1))
return true;
return false;
return true;
}

int
Expand Down Expand Up @@ -593,9 +579,6 @@ GameState::FinishStage()
void
GameState::LoadCurrentSettingsFromProfile(PlayerNumber pn)
{
if (!PROFILEMAN->IsPersistentProfile(pn))
return;

const Profile* pProfile = PROFILEMAN->GetProfile(pn);

// apply saved default modifiers if any
Expand Down Expand Up @@ -630,9 +613,6 @@ GameState::LoadCurrentSettingsFromProfile(PlayerNumber pn)
void
GameState::SaveCurrentSettingsToProfile(PlayerNumber pn)
{
if (!PROFILEMAN->IsPersistentProfile(pn))
return;

Profile* pProfile = PROFILEMAN->GetProfile(pn);

pProfile->SetDefaultModifiers(
Expand Down
22 changes: 7 additions & 15 deletions src/Etterna/Singletons/ProfileManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -571,8 +571,7 @@ ProfileManager::MoveProfilePriority(int index, bool up)
void
ProfileManager::IncrementToastiesCount(PlayerNumber pn)
{
if (IsPersistentProfile(pn))
++GetProfile(pn)->m_iNumToasties;
++GetProfile(pn)->m_iNumToasties;
}

void
Expand All @@ -585,10 +584,9 @@ ProfileManager::AddStepTotals(PlayerNumber pn,
int iNumHands,
int iNumLifts)
{
if (IsPersistentProfile(pn))
GetProfile(pn)->AddStepTotals(iNumTapsAndHolds,
iNumJumps,
iNumHolds,
GetProfile(pn)->AddStepTotals(iNumTapsAndHolds,
iNumJumps,
iNumHolds,
iNumRolls,
iNumMines,
iNumHands,
Expand Down Expand Up @@ -642,14 +640,7 @@ ProfileManager::IncrementStepsPlayCount(const Song* pSong,
const Steps* pSteps,
PlayerNumber pn)
{
if (IsPersistentProfile(pn))
GetProfile(pn)->IncrementStepsPlayCount(pSong, pSteps);
}

bool
ProfileManager::IsPersistentProfile(ProfileSlot slot) const
{
return true;
GetProfile(pn)->IncrementStepsPlayCount(pSong, pSteps);
}

void
Expand Down Expand Up @@ -731,9 +722,10 @@ class LunaProfileManager : public Luna<ProfileManager>
p->SetStatsPrefix(prefix);
COMMON_RETURN_SELF;
}
// concept of persistent profiles is deprecated
static int IsPersistentProfile(T* p, lua_State* L)
{
lua_pushboolean(L, p->IsPersistentProfile(PLAYER_1));
lua_pushboolean(L, true);
return 1;
}
static int GetProfile(T* p, lua_State* L)
Expand Down
6 changes: 0 additions & 6 deletions src/Etterna/Singletons/ProfileManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,6 @@ class ProfileManager
int iNumHands,
int iNumLifts);

bool IsPersistentProfile(PlayerNumber pn) const
{
return !m_sProfileDir.empty();
}
bool IsPersistentProfile(ProfileSlot slot) const;

// return a profile even if !IsUsingProfile
const Profile* GetProfile(PlayerNumber pn) const;
Profile* GetProfile(PlayerNumber pn)
Expand Down

0 comments on commit 52f2434

Please sign in to comment.