mirror of
https://github.com/RetroDECK/Duckstation.git
synced 2025-01-31 03:45:38 +00:00
Merge pull request #2990 from CookiePLMonster/multiple-leaderboards-fix
Achievements: Fix Leaderboard submission UI when multiple leaderboards update at once
This commit is contained in:
commit
0dee77a3ac
|
@ -104,7 +104,7 @@ static void SendPingCallback(s32 status_code, std::string content_type, Common::
|
|||
static void UnlockAchievementCallback(s32 status_code, std::string content_type,
|
||||
Common::HTTPDownloader::Request::Data data);
|
||||
static void SubmitLeaderboardCallback(s32 status_code, std::string content_type,
|
||||
Common::HTTPDownloader::Request::Data data);
|
||||
Common::HTTPDownloader::Request::Data data, u32 lboard_id);
|
||||
|
||||
static bool s_active = false;
|
||||
static bool s_logged_in = false;
|
||||
|
@ -137,7 +137,6 @@ static std::string s_rich_presence_string;
|
|||
static Common::Timer s_last_ping_time;
|
||||
|
||||
static u32 s_last_queried_lboard = 0;
|
||||
static u32 s_submitting_lboard_id = 0;
|
||||
static std::optional<std::vector<Achievements::LeaderboardEntry>> s_lboard_entries;
|
||||
|
||||
template<typename T>
|
||||
|
@ -356,7 +355,6 @@ void Achievements::ClearGameInfo(bool clear_achievements, bool clear_leaderboard
|
|||
}
|
||||
|
||||
s_last_queried_lboard = 0;
|
||||
s_submitting_lboard_id = 0;
|
||||
s_lboard_entries.reset();
|
||||
}
|
||||
|
||||
|
@ -1741,7 +1739,7 @@ void Achievements::UnlockAchievementCallback(s32 status_code, std::string conten
|
|||
}
|
||||
|
||||
void Achievements::SubmitLeaderboardCallback(s32 status_code, std::string content_type,
|
||||
Common::HTTPDownloader::Request::Data data)
|
||||
Common::HTTPDownloader::Request::Data data, u32 lboard_id)
|
||||
{
|
||||
if (!System::IsValid())
|
||||
return;
|
||||
|
@ -1755,11 +1753,7 @@ void Achievements::SubmitLeaderboardCallback(s32 status_code, std::string conten
|
|||
// Force the next leaderboard query to repopulate everything, just in case the user wants to see their new score
|
||||
s_last_queried_lboard = 0;
|
||||
|
||||
// RA API doesn't send us the leaderboard ID back.. hopefully we don't submit two at once :/
|
||||
if (s_submitting_lboard_id == 0)
|
||||
return;
|
||||
|
||||
const Leaderboard* lb = GetLeaderboardByID(std::exchange(s_submitting_lboard_id, 0u));
|
||||
const Leaderboard* lb = GetLeaderboardByID(lboard_id);
|
||||
if (!lb || !FullscreenUI::IsInitialized() || !g_settings.achievements_notifications)
|
||||
return;
|
||||
|
||||
|
@ -1870,17 +1864,16 @@ void Achievements::SubmitLeaderboard(u32 leaderboard_id, int value)
|
|||
return;
|
||||
}
|
||||
|
||||
std::unique_lock lock(s_achievements_mutex);
|
||||
|
||||
s_submitting_lboard_id = leaderboard_id;
|
||||
|
||||
RAPIRequest<rc_api_submit_lboard_entry_request_t, rc_api_init_submit_lboard_entry_request> request;
|
||||
request.username = s_username.c_str();
|
||||
request.api_token = s_api_token.c_str();
|
||||
request.game_hash = s_game_hash.c_str();
|
||||
request.leaderboard_id = leaderboard_id;
|
||||
request.score = value;
|
||||
request.Send(SubmitLeaderboardCallback);
|
||||
request.Send(
|
||||
[leaderboard_id](s32 status_code, const std::string& content_type, Common::HTTPDownloader::Request::Data data) {
|
||||
SubmitLeaderboardCallback(status_code, content_type, std::move(data), leaderboard_id);
|
||||
});
|
||||
}
|
||||
|
||||
void Achievements::AchievementPrimed(u32 achievement_id)
|
||||
|
|
Loading…
Reference in a new issue