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

View File

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