Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Retroachievements - Fixed Login Checks #12414

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
29 changes: 28 additions & 1 deletion Source/Core/Core/AchievementManager.cpp
Expand Up @@ -43,7 +43,8 @@ void AchievementManager::Init()
m_queue.Reset("AchievementManagerQueue", [](const std::function<void()>& func) { func(); });
m_image_queue.Reset("AchievementManagerImageQueue",
[](const std::function<void()>& func) { func(); });
LoginAsync("", [](ResponseType r_type) {});
if (IsLoggedIn())
LoginAsync("", [](ResponseType r_type) {});
Comment on lines +46 to +47
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically not a problem with this PR... but this looks really confusing even if it's technically correct. IsLoggedIn() should probably be renamed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Believe me when I say I had the same reaction to writing this. Software development at its finest.

INFO_LOG_FMT(ACHIEVEMENTS, "Achievement Manager Initialized");
}
}
Expand Down Expand Up @@ -93,6 +94,11 @@ bool AchievementManager::IsLoggedIn() const

void AchievementManager::HashGame(const std::string& file_path, const ResponseCallback& callback)
{
if (!Config::Get(Config::RA_ENABLED) || !IsLoggedIn())
{
callback(AchievementManager::ResponseType::NOT_ENABLED);
return;
}
if (!m_is_runtime_initialized)
{
ERROR_LOG_FMT(ACHIEVEMENTS,
Expand Down Expand Up @@ -143,6 +149,11 @@ void AchievementManager::HashGame(const std::string& file_path, const ResponseCa

void AchievementManager::HashGame(const DiscIO::Volume* volume, const ResponseCallback& callback)
{
if (!Config::Get(Config::RA_ENABLED) || !IsLoggedIn())
{
callback(AchievementManager::ResponseType::NOT_ENABLED);
return;
}
if (!m_is_runtime_initialized)
{
ERROR_LOG_FMT(ACHIEVEMENTS,
Expand Down Expand Up @@ -219,6 +230,11 @@ void AchievementManager::HashGame(const DiscIO::Volume* volume, const ResponseCa

void AchievementManager::LoadGameSync(const ResponseCallback& callback)
{
if (!Config::Get(Config::RA_ENABLED) || !IsLoggedIn())
{
callback(AchievementManager::ResponseType::NOT_ENABLED);
return;
}
u32 new_game_id = 0;
Hash current_hash;
{
Expand Down Expand Up @@ -311,6 +327,11 @@ bool AchievementManager::IsGameLoaded() const

void AchievementManager::LoadUnlockData(const ResponseCallback& callback)
{
if (!Config::Get(Config::RA_ENABLED) || !IsLoggedIn())
{
callback(AchievementManager::ResponseType::NOT_ENABLED);
return;
}
m_queue.EmplaceItem([this, callback] {
const auto hardcore_unlock_response = FetchUnlockData(true);
if (hardcore_unlock_response != ResponseType::SUCCESS)
Expand All @@ -329,6 +350,8 @@ void AchievementManager::LoadUnlockData(const ResponseCallback& callback)

void AchievementManager::ActivateDeactivateAchievements()
{
if (!Config::Get(Config::RA_ENABLED) || !IsLoggedIn())
return;
bool enabled = Config::Get(Config::RA_ACHIEVEMENTS_ENABLED);
bool unofficial = Config::Get(Config::RA_UNOFFICIAL_ENABLED);
bool encore = Config::Get(Config::RA_ENCORE_ENABLED);
Expand All @@ -346,6 +369,8 @@ void AchievementManager::ActivateDeactivateAchievements()

void AchievementManager::ActivateDeactivateLeaderboards()
{
if (!Config::Get(Config::RA_ENABLED) || !IsLoggedIn())
return;
bool leaderboards_enabled = Config::Get(Config::RA_LEADERBOARDS_ENABLED);
for (u32 ix = 0; ix < m_game_data.num_leaderboards; ix++)
{
Expand All @@ -370,6 +395,8 @@ void AchievementManager::ActivateDeactivateLeaderboards()

void AchievementManager::ActivateDeactivateRichPresence()
{
if (!Config::Get(Config::RA_ENABLED) || !IsLoggedIn())
return;
rc_runtime_activate_richpresence(
&m_runtime,
(m_is_game_loaded && Config::Get(Config::RA_RICH_PRESENCE_ENABLED)) ?
Expand Down
1 change: 1 addition & 0 deletions Source/Core/Core/AchievementManager.h
Expand Up @@ -37,6 +37,7 @@ class AchievementManager
enum class ResponseType
{
SUCCESS,
NOT_ENABLED,
MANAGER_NOT_INITIALIZED,
INVALID_REQUEST,
INVALID_CREDENTIALS,
Expand Down