Merge pull request #12586 from LillyJadeKatrin/retroachievements-pointspread-fix

Fixes to Achievement points count/mastery
This commit is contained in:
Admiral H. Curtiss 2024-02-19 02:41:14 +01:00 committed by GitHub
commit ccf2435047
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 28 additions and 20 deletions

View File

@ -359,11 +359,11 @@ void AchievementManager::ActivateDeactivateAchievements()
bool encore = Config::Get(Config::RA_ENCORE_ENABLED); bool encore = Config::Get(Config::RA_ENCORE_ENABLED);
for (u32 ix = 0; ix < m_game_data.num_achievements; ix++) for (u32 ix = 0; ix < m_game_data.num_achievements; ix++)
{ {
u32 points = (m_game_data.achievements[ix].category == RC_ACHIEVEMENT_CATEGORY_UNOFFICIAL) ? auto iter =
0 : m_unlock_map.insert({m_game_data.achievements[ix].id,
m_game_data.achievements[ix].points; UnlockStatus{.game_data_index = ix,
auto iter = m_unlock_map.insert( .points = m_game_data.achievements[ix].points,
{m_game_data.achievements[ix].id, UnlockStatus{.game_data_index = ix, .points = points}}); .category = m_game_data.achievements[ix].category}});
ActivateDeactivateAchievement(iter.first->first, enabled, unofficial, encore); ActivateDeactivateAchievement(iter.first->first, enabled, unofficial, encore);
} }
INFO_LOG_FMT(ACHIEVEMENTS, "Achievements (de)activated."); INFO_LOG_FMT(ACHIEVEMENTS, "Achievements (de)activated.");
@ -800,6 +800,8 @@ AchievementManager::PointSpread AchievementManager::TallyScore() const
return spread; return spread;
for (const auto& entry : m_unlock_map) for (const auto& entry : m_unlock_map)
{ {
if (entry.second.category != RC_ACHIEVEMENT_CATEGORY_CORE)
continue;
u32 points = entry.second.points; u32 points = entry.second.points;
spread.total_count++; spread.total_count++;
spread.total_points += points; spread.total_points += points;
@ -1466,8 +1468,11 @@ void AchievementManager::HandleAchievementTriggeredEvent(const rc_runtime_event_
(Config::Get(Config::RA_BADGES_ENABLED)) ? (Config::Get(Config::RA_BADGES_ENABLED)) ?
DecodeBadgeToOSDIcon(it->second.unlocked_badge.badge) : DecodeBadgeToOSDIcon(it->second.unlocked_badge.badge) :
nullptr); nullptr);
if (m_game_data.achievements[game_data_index].category == RC_ACHIEVEMENT_CATEGORY_CORE)
{
PointSpread spread = TallyScore(); PointSpread spread = TallyScore();
if (spread.hard_points == spread.total_points) if (spread.hard_points == spread.total_points &&
it->second.remote_unlock_status != UnlockStatus::UnlockType::HARDCORE)
{ {
OSD::AddMessage( OSD::AddMessage(
fmt::format("Congratulations! {} has mastered {}", m_display_name, m_game_data.title), fmt::format("Congratulations! {} has mastered {}", m_display_name, m_game_data.title),
@ -1475,7 +1480,8 @@ void AchievementManager::HandleAchievementTriggeredEvent(const rc_runtime_event_
(Config::Get(Config::RA_BADGES_ENABLED)) ? DecodeBadgeToOSDIcon(m_game_badge.badge) : (Config::Get(Config::RA_BADGES_ENABLED)) ? DecodeBadgeToOSDIcon(m_game_badge.badge) :
nullptr); nullptr);
} }
else if (spread.hard_points + spread.soft_points == spread.total_points) else if (spread.hard_points + spread.soft_points == spread.total_points &&
it->second.remote_unlock_status == UnlockStatus::UnlockType::LOCKED)
{ {
OSD::AddMessage( OSD::AddMessage(
fmt::format("Congratulations! {} has completed {}", m_display_name, m_game_data.title), fmt::format("Congratulations! {} has completed {}", m_display_name, m_game_data.title),
@ -1483,6 +1489,7 @@ void AchievementManager::HandleAchievementTriggeredEvent(const rc_runtime_event_
(Config::Get(Config::RA_BADGES_ENABLED)) ? DecodeBadgeToOSDIcon(m_game_badge.badge) : (Config::Get(Config::RA_BADGES_ENABLED)) ? DecodeBadgeToOSDIcon(m_game_badge.badge) :
nullptr); nullptr);
} }
}
ActivateDeactivateAchievement(event_id, Config::Get(Config::RA_ACHIEVEMENTS_ENABLED), ActivateDeactivateAchievement(event_id, Config::Get(Config::RA_ACHIEVEMENTS_ENABLED),
Config::Get(Config::RA_UNOFFICIAL_ENABLED), Config::Get(Config::RA_UNOFFICIAL_ENABLED),
Config::Get(Config::RA_ENCORE_ENABLED)); Config::Get(Config::RA_ENCORE_ENABLED));

View File

@ -89,6 +89,7 @@ public:
u32 points = 0; u32 points = 0;
BadgeStatus locked_badge; BadgeStatus locked_badge;
BadgeStatus unlocked_badge; BadgeStatus unlocked_badge;
u32 category = RC_ACHIEVEMENT_CATEGORY_CORE;
}; };
static constexpr std::string_view GRAY = "transparent"; static constexpr std::string_view GRAY = "transparent";