Removed update_achievement_progress function

This commit is contained in:
schmurger 2024-05-19 15:01:41 +10:00 committed by otavepto
parent 6b26ca1b4c
commit e30cc2957f
3 changed files with 9 additions and 30 deletions

View File

@ -605,7 +605,7 @@ Steam_User_Stats::InternalSetResult<bool> Steam_User_Stats::set_achievement_inte
result.notify_server = !settings->disable_sharing_stats_with_gameserver;
if (!settings->disable_overlay) overlay->AddAchievementNotification(it.value());
if (!settings->disable_overlay) overlay->AddAchievementNotification(internal_name, user_achievements[internal_name]);
}
} catch (...) {}
@ -1151,10 +1151,7 @@ bool Steam_User_Stats::IndicateAchievementProgress( const char *pchName, uint32
user_achievements[actual_ach_name]["progress"] = nCurProgress;
user_achievements[actual_ach_name]["max_progress"] = nMaxProgress;
save_achievements();
if (!settings->disable_overlay) {
overlay->AddAchievementNotification(it.value());
overlay->update_achievement_progress(actual_ach_name, (int)nCurProgress);
}
if (!settings->disable_overlay) overlay->AddAchievementNotification(actual_ach_name, user_achievements[actual_ach_name]);
} catch (...) {}
{

View File

@ -253,8 +253,7 @@ public:
void FriendConnect(Friend _friend);
void FriendDisconnect(Friend _friend);
void AddAchievementNotification(nlohmann::json const& ach);
void update_achievement_progress(std::string const& ach_name, int nCurProgress);
void AddAchievementNotification(std::string ach_name, nlohmann::json const& ach);
};
#else // EMU_OVERLAY
@ -288,8 +287,7 @@ public:
void FriendConnect(Friend _friend) {}
void FriendDisconnect(Friend _friend) {}
void AddAchievementNotification(nlohmann::json const& ach) {}
void update_achievement_progress(std::string const& ach_name, int nCurProgress);
void AddAchievementNotification(std::string ach_name, nlohmann::json const& ach) {}
};
#endif // EMU_OVERLAY

View File

@ -380,19 +380,6 @@ void Steam_Overlay::load_achievements_data()
}
void Steam_Overlay::update_achievement_progress(std::string const& ach_name, int nCurProgress) {
PRINT_DEBUG_ENTRY();
std::lock_guard<std::recursive_mutex> lock(overlay_mutex);
for (auto& ach : achievements) {
if (ach.name == ach_name) {
ach.progress = (float)nCurProgress;
break;
}
}
}
void Steam_Overlay::initial_load_achievements_icons()
{
@ -1977,7 +1964,7 @@ void Steam_Overlay::FriendDisconnect(Friend _friend)
}
// show a notification when the user unlocks an achievement
void Steam_Overlay::AddAchievementNotification(nlohmann::json const &ach)
void Steam_Overlay::AddAchievementNotification(std::string ach_name, nlohmann::json const &ach)
{
PRINT_DEBUG_ENTRY();
std::lock_guard<std::recursive_mutex> lock(overlay_mutex);
@ -1989,15 +1976,12 @@ void Steam_Overlay::AddAchievementNotification(nlohmann::json const &ach)
// adjust the local 'is_achieved' and 'unlock_time'
std::lock_guard<std::recursive_mutex> lock2(global_mutex);
std::string ach_name = ach.value("name", std::string());
for (auto &a : achievements) {
if (a.name == ach_name) {
bool achieved = false;
uint32 unlock_time = 0;
get_steam_client()->steam_user_stats->GetAchievementAndUnlockTime(a.name.c_str(), &achieved, &unlock_time);
a.achieved = achieved;
a.unlock_time = unlock_time;
a.achieved = ach.value("earned", false);
a.unlock_time = ach.value("earned_time", static_cast<uint32>(0));
a.progress = ach.value("progress", static_cast<float>(0));
a.max_progress = ach.value("max_progress", static_cast<float>(0));
if (achieved) {
post_achievement_notification(a);