Skip to content

Commit

Permalink
Merge pull request #12414 from LillyJadeKatrin/retroachievements-bugfix
Browse files Browse the repository at this point in the history
Retroachievements - Fixed Login Checks
  • Loading branch information
AdmiralCurtiss committed Dec 16, 2023
2 parents 3ee44bc + aa3e1e2 commit 4b45929
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
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) {});
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

0 comments on commit 4b45929

Please sign in to comment.